private static void dropColumnFamily(String ksName, String cfName) { KSMetaData ksm = Schema.instance.getKSMetaData(ksName); assert ksm != null; ColumnFamilyStore cfs = Keyspace.open(ksName).getColumnFamilyStore(cfName); assert cfs != null; // reinitialize the keyspace. CFMetaData cfm = ksm.cfMetaData().get(cfName); Schema.instance.purge(cfm); Schema.instance.setKeyspaceDefinition(makeNewKeyspaceDefinition(ksm, cfm)); CompactionManager.instance.interruptCompactionFor(Arrays.asList(cfm), true); if (!StorageService.instance.isClientMode()) { if (DatabaseDescriptor.isAutoSnapshot()) cfs.snapshot(Keyspace.getTimestampedSnapshotName(cfs.name)); Keyspace.open(ksm.name).dropCf(cfm.cfId); MigrationManager.instance.notifyDropColumnFamily(cfm); CommitLog.instance.forceRecycleAllSegments(Collections.singleton(cfm.cfId)); } }
public void dropTable(String ksName, String tableName) { KeyspaceMetadata oldKsm = getKSMetaData(ksName); assert oldKsm != null; ColumnFamilyStore cfs = Keyspace.open(ksName).getColumnFamilyStore(tableName); assert cfs != null; // make sure all the indexes are dropped, or else. cfs.indexManager.markAllIndexesRemoved(); // reinitialize the keyspace. CFMetaData cfm = oldKsm.tables.get(tableName).get(); KeyspaceMetadata newKsm = oldKsm.withSwapped(oldKsm.tables.without(tableName)); unload(cfm); setKeyspaceMetadata(newKsm); CompactionManager.instance.interruptCompactionFor(Collections.singleton(cfm), true); if (DatabaseDescriptor.isAutoSnapshot()) cfs.snapshot(Keyspace.getTimestampedSnapshotNameWithPrefix(cfs.name, ColumnFamilyStore.SNAPSHOT_DROP_PREFIX)); Keyspace.open(ksName).dropCf(cfm.cfId); MigrationManager.instance.notifyDropColumnFamily(cfm); CommitLog.instance.forceRecycleAllSegments(Collections.singleton(cfm.cfId)); }
public void dropTable(String ksName, String tableName) { KeyspaceMetadata oldKsm = getKSMetaData(ksName); assert oldKsm != null; ColumnFamilyStore cfs = Keyspace.open(ksName).getColumnFamilyStore(tableName); assert cfs != null; // make sure all the indexes are dropped, or else. cfs.indexManager.markAllIndexesRemoved(); // reinitialize the keyspace. CFMetaData cfm = oldKsm.tables.get(tableName).get(); KeyspaceMetadata newKsm = oldKsm.withSwapped(oldKsm.tables.without(tableName)); unload(cfm); setKeyspaceMetadata(newKsm); CompactionManager.instance.interruptCompactionFor(Collections.singleton(cfm), true); if (DatabaseDescriptor.isAutoSnapshot()) cfs.snapshot(Keyspace.getTimestampedSnapshotNameWithPrefix(cfs.name, ColumnFamilyStore.SNAPSHOT_DROP_PREFIX)); Keyspace.open(ksName).dropCf(cfm.cfId); MigrationManager.instance.notifyDropColumnFamily(cfm); CommitLog.instance.forceRecycleAllSegments(Collections.singleton(cfm.cfId)); }
public void dropTable(String ksName, String tableName) { KeyspaceMetadata oldKsm = getKSMetaData(ksName); assert oldKsm != null; ColumnFamilyStore cfs = Keyspace.open(ksName).getColumnFamilyStore(tableName); assert cfs != null; // make sure all the indexes are dropped, or else. cfs.indexManager.markAllIndexesRemoved(); // reinitialize the keyspace. CFMetaData cfm = oldKsm.tables.get(tableName).get(); KeyspaceMetadata newKsm = oldKsm.withSwapped(oldKsm.tables.without(tableName)); unload(cfm); setKeyspaceMetadata(newKsm); CompactionManager.instance.interruptCompactionFor(Collections.singleton(cfm), true); if (DatabaseDescriptor.isAutoSnapshot()) cfs.snapshot(Keyspace.getTimestampedSnapshotNameWithPrefix(cfs.name, ColumnFamilyStore.SNAPSHOT_DROP_PREFIX)); Keyspace keyspace = Keyspace.open(ksName); keyspace.dropCf(cfm.cfId); MigrationManager.instance.notifyDropColumnFamily(keyspace.getMetadata(), cfm); CommitLog.instance.forceRecycleAllSegments(Collections.singleton(cfm.cfId)); }