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)); }
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 keyspace = Keyspace.open(ksName); keyspace.dropCf(cfm.cfId); MigrationManager.instance.notifyDropColumnFamily(keyspace.getMetadata(), cfm); CommitLog.instance.forceRecycleAllSegments(Collections.singleton(cfm.cfId)); }
public void dropView(String ksName, String viewName) { KeyspaceMetadata oldKsm = getKSMetaData(ksName); assert oldKsm != null; ColumnFamilyStore cfs = Keyspace.open(ksName).getColumnFamilyStore(viewName); assert cfs != null; // make sure all the indexes are dropped, or else. cfs.indexManager.markAllIndexesRemoved(); // reinitialize the keyspace. ViewDefinition view = oldKsm.views.get(viewName).get(); KeyspaceMetadata newKsm = oldKsm.withSwapped(oldKsm.views.without(viewName)); unload(view); setKeyspaceMetadata(newKsm); CompactionManager.instance.interruptCompactionFor(Collections.singleton(view.metadata), true); if (DatabaseDescriptor.isAutoSnapshot()) cfs.snapshot(Keyspace.getTimestampedSnapshotName(cfs.name)); Keyspace.open(ksName).dropCf(view.metadata.cfId); Keyspace.open(ksName).viewManager.reload(); MigrationManager.instance.notifyDropView(view); CommitLog.instance.forceRecycleAllSegments(Collections.singleton(view.metadata.cfId)); }
public void dropView(String ksName, String viewName) { KeyspaceMetadata oldKsm = getKSMetaData(ksName); assert oldKsm != null; ColumnFamilyStore cfs = Keyspace.open(ksName).getColumnFamilyStore(viewName); assert cfs != null; // make sure all the indexes are dropped, or else. cfs.indexManager.markAllIndexesRemoved(); // reinitialize the keyspace. ViewDefinition view = oldKsm.views.get(viewName).get(); KeyspaceMetadata newKsm = oldKsm.withSwapped(oldKsm.views.without(viewName)); unload(view); setKeyspaceMetadata(newKsm); CompactionManager.instance.interruptCompactionFor(Collections.singleton(view.metadata), true); if (DatabaseDescriptor.isAutoSnapshot()) cfs.snapshot(Keyspace.getTimestampedSnapshotName(cfs.name)); Keyspace.open(ksName).dropCf(view.metadata.cfId); Keyspace.open(ksName).viewManager.reload(); MigrationManager.instance.notifyDropView(view); CommitLog.instance.forceRecycleAllSegments(Collections.singleton(view.metadata.cfId)); }
Keyspace.open(ksm.name).dropCf(cfm.cfId);
public void dropView(String ksName, String viewName) { KeyspaceMetadata oldKsm = getKSMetaData(ksName); assert oldKsm != null; ColumnFamilyStore cfs = Keyspace.open(ksName).getColumnFamilyStore(viewName); assert cfs != null; // make sure all the indexes are dropped, or else. cfs.indexManager.markAllIndexesRemoved(); // reinitialize the keyspace. ViewDefinition view = oldKsm.views.get(viewName).get(); KeyspaceMetadata newKsm = oldKsm.withSwapped(oldKsm.views.without(viewName)); unload(view); setKeyspaceMetadata(newKsm); CompactionManager.instance.interruptCompactionFor(Collections.singleton(view.metadata), true); if (DatabaseDescriptor.isAutoSnapshot()) cfs.snapshot(Keyspace.getTimestampedSnapshotName(cfs.name)); Keyspace.open(ksName).dropCf(view.metadata.cfId); Keyspace.open(ksName).viewManager.reload(); MigrationManager.instance.notifyDropView(view); CommitLog.instance.forceRecycleAllSegments(Collections.singleton(view.metadata.cfId)); }
public void dropKeyspace(String ksName) { KeyspaceMetadata ksm = Schema.instance.getKSMetaData(ksName); String snapshotName = Keyspace.getTimestampedSnapshotNameWithPrefix(ksName, ColumnFamilyStore.SNAPSHOT_DROP_PREFIX); CompactionManager.instance.interruptCompactionFor(ksm.tablesAndViews(), true); Keyspace keyspace = Keyspace.open(ksm.name); // remove all cfs from the keyspace instance. List<UUID> droppedCfs = new ArrayList<>(); for (CFMetaData cfm : ksm.tablesAndViews()) { ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfm.cfName); unload(cfm); if (DatabaseDescriptor.isAutoSnapshot()) cfs.snapshot(snapshotName); Keyspace.open(ksm.name).dropCf(cfm.cfId); droppedCfs.add(cfm.cfId); } // remove the keyspace from the static instances. Keyspace.clear(ksm.name); clearKeyspaceMetadata(ksm); Keyspace.writeOrder.awaitNewBarrier(); // force a new segment in the CL CommitLog.instance.forceRecycleAllSegments(droppedCfs); MigrationManager.instance.notifyDropKeyspace(ksm); }
public void dropKeyspace(String ksName) { KeyspaceMetadata ksm = Schema.instance.getKSMetaData(ksName); String snapshotName = Keyspace.getTimestampedSnapshotNameWithPrefix(ksName, ColumnFamilyStore.SNAPSHOT_DROP_PREFIX); CompactionManager.instance.interruptCompactionFor(ksm.tablesAndViews(), true); Keyspace keyspace = Keyspace.open(ksm.name); // remove all cfs from the keyspace instance. List<UUID> droppedCfs = new ArrayList<>(); for (CFMetaData cfm : ksm.tablesAndViews()) { ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfm.cfName); unload(cfm); if (DatabaseDescriptor.isAutoSnapshot()) cfs.snapshot(snapshotName); Keyspace.open(ksm.name).dropCf(cfm.cfId); droppedCfs.add(cfm.cfId); } // remove the keyspace from the static instances. Keyspace.clear(ksm.name); clearKeyspaceMetadata(ksm); Keyspace.writeOrder.awaitNewBarrier(); // force a new segment in the CL CommitLog.instance.forceRecycleAllSegments(droppedCfs); MigrationManager.instance.notifyDropKeyspace(ksm); }
public void dropKeyspace(String ksName) { KeyspaceMetadata ksm = Schema.instance.getKSMetaData(ksName); String snapshotName = Keyspace.getTimestampedSnapshotNameWithPrefix(ksName, ColumnFamilyStore.SNAPSHOT_DROP_PREFIX); CompactionManager.instance.interruptCompactionFor(ksm.tablesAndViews(), true); Keyspace keyspace = Keyspace.open(ksm.name); // remove all cfs from the keyspace instance. List<UUID> droppedCfs = new ArrayList<>(); for (CFMetaData cfm : ksm.tablesAndViews()) { ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfm.cfName); unload(cfm); if (DatabaseDescriptor.isAutoSnapshot()) cfs.snapshot(snapshotName); Keyspace.open(ksm.name).dropCf(cfm.cfId); droppedCfs.add(cfm.cfId); } // remove the keyspace from the static instances. Keyspace.clear(ksm.name); clearKeyspaceMetadata(ksm); Keyspace.writeOrder.awaitNewBarrier(); // force a new segment in the CL CommitLog.instance.forceRecycleAllSegments(droppedCfs); MigrationManager.instance.notifyDropKeyspace(ksm); }