@Override public String toString() { return "CFS(" + "Keyspace='" + keyspace.getName() + '\'' + ", ColumnFamily='" + name + '\'' + ')'; }
/** * This method returns the N endpoints that are responsible for storing the * specified key i.e for replication. * * @param keyspaceName keyspace name also known as keyspace * @param pos position for which we need to find the endpoint * @return the endpoint responsible for this token */ public List<InetAddress> getNaturalEndpoints(String keyspaceName, RingPosition pos) { return Keyspace.open(keyspaceName).getReplicationStrategy().getNaturalEndpoints(pos); }
/** * See #{@code StorageService.loadNewSSTables(String, String)} for more info * * @param ksName The keyspace name * @param cfName The columnFamily name */ public static void loadNewSSTables(String ksName, String cfName) { /** ks/cf existence checks will be done by open and getCFS methods for us */ Keyspace keyspace = Keyspace.open(ksName); keyspace.getColumnFamilyStore(cfName).loadNewSSTables(); }
public CompletableFuture<?> applyFuture() { Keyspace ks = Keyspace.open(keyspaceName); return ks.applyFuture(this, Keyspace.open(keyspaceName).getMetadata().params.durableWrites, true); }
public void apply() { Keyspace ks = Keyspace.open(keyspaceName); ks.apply(this, ks.getMetadata().durableWrites); }
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); }
Keyspace.setInitialized(); logger.debug("opening keyspace {}", keyspaceName); for (ColumnFamilyStore cfs : Keyspace.open(keyspaceName).getColumnFamilyStores()) for (Keyspace keyspace : Keyspace.all()) for (ColumnFamilyStore cfs : keyspace.getColumnFamilyStores())
private static void dropKeyspace(String ksName) String snapshotName = Keyspace.getTimestampedSnapshotName(ksName); Keyspace keyspace = Keyspace.open(ksm.name); for (CFMetaData cfm : ksm.cfMetaData().values()) ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfm.cfName); Keyspace.open(ksm.name).dropCf(cfm.cfId); Keyspace.clear(ksm.name); Schema.instance.clearKeyspaceDefinition(ksm);
public void run() { for (Keyspace keyspace : Keyspace.all()) for (ColumnFamilyStore cfs : keyspace.getColumnFamilyStores()) CompactionManager.instance.submitBackground(cfs); } };
public void updateTable(CFMetaData table) { CFMetaData current = getCFMetaData(table.ksName, table.cfName); assert current != null; boolean changeAffectsStatements = current.apply(table); Keyspace keyspace = Keyspace.open(current.ksName); keyspace.getColumnFamilyStore(current.cfName).reload(); MigrationManager.instance.notifyUpdateColumnFamily(keyspace.getMetadata(), current, changeAffectsStatements); }
public void apply() { apply(Keyspace.open(keyspaceName).getMetadata().params.durableWrites); }
System.exit(1); Keyspace.setInitialized(); Keyspace keyspace = Keyspace.open(descriptor.ksname); try cfStore = keyspace.getColumnFamilyStore(baseName);
public void addTable(CFMetaData cfm) { assert getCFMetaData(cfm.ksName, cfm.cfName) == null; // Make sure the keyspace is initialized // and init the new CF before switching the KSM to the new one // to avoid races as in CASSANDRA-10761 Keyspace keyspace = Keyspace.open(cfm.ksName); keyspace.initCf(cfm, true); // Update the keyspaces map with the updated metadata update(cfm.ksName, ks -> ks.withSwapped(ks.tables.with(cfm))); // Update the table ID <-> table name map (cfIdMap) load(cfm); MigrationManager.instance.notifyCreateColumnFamily(keyspace.getMetadata(), cfm); }
public ColumnFamilyStore getColumnFamilyStore(String cfName) { UUID id = Schema.instance.getId(getName(), cfName); if (id == null) throw new IllegalArgumentException(String.format("Unknown keyspace/cf pair (%s.%s)", getName(), cfName)); return getColumnFamilyStore(id); }
public Double getValue() { List<SSTableReader> sstables = new ArrayList<>(); Keyspace.all().forEach(ks -> sstables.addAll(ks.getAllSSTables(SSTableSet.CANONICAL))); return computeCompressionRatio(sstables); } });
private int localQuorumFor(Keyspace keyspace, String dc) { return (keyspace.getReplicationStrategy() instanceof NetworkTopologyStrategy) ? (((NetworkTopologyStrategy) keyspace.getReplicationStrategy()).getReplicationFactor(dc) / 2) + 1 : quorumFor(keyspace); }
public void apply(final Mutation mutation, final boolean writeCommitLog) { apply(mutation, writeCommitLog, true, true); }
public static Keyspace mockKS(KeyspaceMetadata metadata) { return new Keyspace(metadata); }
public void update(String viewName) { View view = viewsByName.get(viewName); assert view != null : "When updating a view, it should already be in the ViewManager"; view.build(); // We provide the new definition from the base metadata Optional<ViewDefinition> viewDefinition = keyspace.getMetadata().views.get(viewName); assert viewDefinition.isPresent() : "When updating a view, it should still be in the Keyspaces views"; view.updateDefinition(viewDefinition.get()); }