Package org.apache.cassandra.db
Class Keyspace
- java.lang.Object
-
- org.apache.cassandra.db.Keyspace
-
public class Keyspace extends java.lang.ObjectIt represents a Keyspace.
-
-
Field Summary
Fields Modifier and Type Field Description KeyspaceMetricsmetricViewManagerviewManagerstatic OpOrderwriteOrder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.Iterable<Keyspace>all()static java.util.stream.Stream<Keyspace>allExisting()voidapply(Mutation mutation, boolean writeCommitLog)voidapply(Mutation mutation, boolean writeCommitLog, boolean updateIndexes)voidapply(Mutation mutation, boolean makeDurable, boolean updateIndexes, boolean isDroppable)If apply is blocking, apply must not be deferred Otherwise there is a race condition where ALL mutation workers are beeing blocked ending in a complete deadlock of the mutation stage.Future<?>applyFuture(Mutation mutation, boolean writeCommitLog, boolean updateIndexes)Future<?>applyFuture(Mutation mutation, boolean writeCommitLog, boolean updateIndexes, boolean isDroppable, boolean isDeferrable)static voidclearSnapshot(java.lang.String snapshotName, java.lang.String keyspace)Clear all the snapshots for a given keyspace.voiddropCf(TableId tableId, boolean dropData)java.util.List<Future<?>>flush(ColumnFamilyStore.FlushReason reason)java.util.stream.Stream<TableSnapshot>getAllSnapshots()java.util.List<SSTableReader>getAllSSTables(SSTableSet sstableSet)ColumnFamilyStoregetColumnFamilyStore(java.lang.String cfName)ColumnFamilyStoregetColumnFamilyStore(TableId id)java.util.Collection<ColumnFamilyStore>getColumnFamilyStores()ColumnFamilyStoregetIfExists(TableId id)KeyspaceMetadatagetMetadata()java.lang.StringgetName()KeyspaceRepairManagergetRepairManager()AbstractReplicationStrategygetReplicationStrategy()static java.lang.StringgetTimestampedSnapshotName(java.lang.String clientSuppliedName)static java.lang.StringgetTimestampedSnapshotNameWithPrefix(java.lang.String clientSuppliedName, java.lang.String prefix)java.lang.Iterable<ColumnFamilyStore>getValidColumnFamilies(boolean allowIndexes, boolean autoAddIndexes, java.lang.String... cfNames)KeyspaceWriteHandlergetWriteHandler()booleanhasColumnFamilyStore(TableId id)voidinitCf(TableMetadataRef metadata, boolean loadSSTables)adds a cf to internal structures, ends up creating disk files).voidinitCfCustom(ColumnFamilyStore newCfs)Registers a custom cf instance with this keyspace.static booleanisInitialized()static KeyspacemockKS(KeyspaceMetadata metadata)static java.lang.Iterable<Keyspace>nonLocalStrategy()static Keyspaceopen(java.lang.String keyspaceName)static Keyspaceopen(java.lang.String keyspaceName, SchemaProvider schema, boolean loadSSTables)static ColumnFamilyStoreopenAndGetStore(TableMetadata table)static ColumnFamilyStoreopenAndGetStore(TableMetadataRef tableRef)static ColumnFamilyStoreopenAndGetStoreIfExists(TableMetadata table)static KeyspaceopenWithoutSSTables(java.lang.String keyspaceName)static voidremoveUnreadableSSTables(File directory)Removes every SSTable in the directory from the appropriate Tracker's view.static voidsetInitialized()voidsetMetadata(KeyspaceMetadata metadata)voidsnapshot(java.lang.String snapshotName, java.lang.String columnFamilyName)Take a snapshot of the specific column family, or the entire set of column families if columnFamily is null with a given timestampvoidsnapshot(java.lang.String snapshotName, java.lang.String columnFamilyName, boolean skipFlush, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, java.time.Instant creationTime)Take a snapshot of the specific column family, or the entire set of column families if columnFamily is null with a given timestampbooleansnapshotExists(java.lang.String snapshotName)Check whether snapshots already exists for a given name.static java.lang.Iterable<Keyspace>system()java.lang.StringtoString()voidunload(boolean dropData)Unloads all column family stores and releases metrics.static voidunsetInitialized()Never use it in production code.
-
-
-
Field Detail
-
metric
public final KeyspaceMetrics metric
-
writeOrder
public static final OpOrder writeOrder
-
viewManager
public final ViewManager viewManager
-
-
Method Detail
-
isInitialized
public static boolean isInitialized()
-
setInitialized
public static void setInitialized()
-
unsetInitialized
public static void unsetInitialized()
Never use it in production code. Useful when creating a fake Schema so that it does not manage Keyspace instances (and CFS)
-
open
public static Keyspace open(java.lang.String keyspaceName)
-
openWithoutSSTables
public static Keyspace openWithoutSSTables(java.lang.String keyspaceName)
-
open
public static Keyspace open(java.lang.String keyspaceName, SchemaProvider schema, boolean loadSSTables)
-
openAndGetStore
public static ColumnFamilyStore openAndGetStore(TableMetadataRef tableRef)
-
openAndGetStore
public static ColumnFamilyStore openAndGetStore(TableMetadata table)
-
openAndGetStoreIfExists
public static ColumnFamilyStore openAndGetStoreIfExists(TableMetadata table)
-
removeUnreadableSSTables
public static void removeUnreadableSSTables(File directory)
Removes every SSTable in the directory from the appropriate Tracker's view.- Parameters:
directory- the unreadable directory, possibly with SSTables in it, but not necessarily.
-
setMetadata
public void setMetadata(KeyspaceMetadata metadata)
-
getMetadata
public KeyspaceMetadata getMetadata()
-
getColumnFamilyStores
public java.util.Collection<ColumnFamilyStore> getColumnFamilyStores()
-
getColumnFamilyStore
public ColumnFamilyStore getColumnFamilyStore(java.lang.String cfName)
-
getColumnFamilyStore
public ColumnFamilyStore getColumnFamilyStore(TableId id)
-
getIfExists
public ColumnFamilyStore getIfExists(TableId id)
-
hasColumnFamilyStore
public boolean hasColumnFamilyStore(TableId id)
-
snapshot
public void snapshot(java.lang.String snapshotName, java.lang.String columnFamilyName, boolean skipFlush, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, java.time.Instant creationTime) throws java.io.IOExceptionTake a snapshot of the specific column family, or the entire set of column families if columnFamily is null with a given timestamp- Parameters:
snapshotName- the tag associated with the name of the snapshot. This value may not be nullcolumnFamilyName- the column family to snapshot or all on nullskipFlush- Skip blocking flush of memtablerateLimiter- Rate limiter for hardlinks-per-second- Throws:
java.io.IOException- if the column family doesn't exist
-
snapshot
public void snapshot(java.lang.String snapshotName, java.lang.String columnFamilyName) throws java.io.IOExceptionTake a snapshot of the specific column family, or the entire set of column families if columnFamily is null with a given timestamp- Parameters:
snapshotName- the tag associated with the name of the snapshot. This value may not be nullcolumnFamilyName- the column family to snapshot or all on null- Throws:
java.io.IOException- if the column family doesn't exist
-
getTimestampedSnapshotName
public static java.lang.String getTimestampedSnapshotName(java.lang.String clientSuppliedName)
- Parameters:
clientSuppliedName- may be null.- Returns:
- the name of the snapshot
-
getTimestampedSnapshotNameWithPrefix
public static java.lang.String getTimestampedSnapshotNameWithPrefix(java.lang.String clientSuppliedName, java.lang.String prefix)
-
snapshotExists
public boolean snapshotExists(java.lang.String snapshotName)
Check whether snapshots already exists for a given name.- Parameters:
snapshotName- the user supplied snapshot name- Returns:
- true if the snapshot exists
-
clearSnapshot
public static void clearSnapshot(java.lang.String snapshotName, java.lang.String keyspace)Clear all the snapshots for a given keyspace.- Parameters:
snapshotName- the user supplied snapshot name. It empty or null, all the snapshots will be cleaned
-
getAllSSTables
public java.util.List<SSTableReader> getAllSSTables(SSTableSet sstableSet)
- Returns:
- A list of open SSTableReaders
-
getAllSnapshots
public java.util.stream.Stream<TableSnapshot> getAllSnapshots()
-
getRepairManager
public KeyspaceRepairManager getRepairManager()
-
mockKS
public static Keyspace mockKS(KeyspaceMetadata metadata)
-
dropCf
public void dropCf(TableId tableId, boolean dropData)
-
unload
public void unload(boolean dropData)
Unloads all column family stores and releases metrics.
-
initCfCustom
public void initCfCustom(ColumnFamilyStore newCfs)
Registers a custom cf instance with this keyspace. This is required for offline tools what use non-standard directories.
-
getWriteHandler
public KeyspaceWriteHandler getWriteHandler()
-
initCf
public void initCf(TableMetadataRef metadata, boolean loadSSTables)
adds a cf to internal structures, ends up creating disk files).
-
applyFuture
public Future<?> applyFuture(Mutation mutation, boolean writeCommitLog, boolean updateIndexes)
-
applyFuture
public Future<?> applyFuture(Mutation mutation, boolean writeCommitLog, boolean updateIndexes, boolean isDroppable, boolean isDeferrable)
-
apply
public void apply(Mutation mutation, boolean writeCommitLog, boolean updateIndexes)
-
apply
public void apply(Mutation mutation, boolean writeCommitLog)
-
apply
public void apply(Mutation mutation, boolean makeDurable, boolean updateIndexes, boolean isDroppable)
If apply is blocking, apply must not be deferred Otherwise there is a race condition where ALL mutation workers are beeing blocked ending in a complete deadlock of the mutation stage. See CASSANDRA-12689.- Parameters:
mutation- the row to write. Must not be modified after calling apply, since commitlog append may happen concurrently, depending on the CL Executor type.makeDurable- if true, don't return unless write has been made durableupdateIndexes- false to disable index updates (used by CollationController "defragmenting")isDroppable- true if this should throw WriteTimeoutException if it does not acquire lock within write_request_timeout
-
getReplicationStrategy
public AbstractReplicationStrategy getReplicationStrategy()
-
flush
public java.util.List<Future<?>> flush(ColumnFamilyStore.FlushReason reason)
-
getValidColumnFamilies
public java.lang.Iterable<ColumnFamilyStore> getValidColumnFamilies(boolean allowIndexes, boolean autoAddIndexes, java.lang.String... cfNames) throws java.io.IOException
- Throws:
java.io.IOException
-
all
public static java.lang.Iterable<Keyspace> all()
-
allExisting
public static java.util.stream.Stream<Keyspace> allExisting()
- Returns:
- a
Streamof all existing/openKeyspaceinstances
-
nonLocalStrategy
public static java.lang.Iterable<Keyspace> nonLocalStrategy()
-
system
public static java.lang.Iterable<Keyspace> system()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getName
public java.lang.String getName()
-
-