org.apache.cassandra.db

## Class Keyspace

- java.lang.Object
- - org.apache.cassandra.db.Keyspace

    public class Keyspace
    extends java.lang.Object

It represents a Keyspace.

### Field Summary

Fields
`static com.google.common.base.Function<java.lang.String,Keyspace>` `keyspaceTransformer`
`KeyspaceMetrics` `metric`
`ViewManager` `viewManager`
`static OpOrder` `writeOrder`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static java.lang.Iterable<Keyspace>` `all()`
`void` `apply(Mutation mutation, boolean writeCommitLog)`
`void` `apply(Mutation mutation, boolean writeCommitLog, boolean updateIndexes)`
`void` `apply(Mutation mutation, boolean writeCommitLog, 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.
`java.util.concurrent.CompletableFuture<?>` `applyFuture(Mutation mutation, boolean writeCommitLog, boolean updateIndexes)`
`java.util.concurrent.CompletableFuture<?>` `applyFuture(Mutation mutation, boolean writeCommitLog, boolean updateIndexes, boolean isDroppable, boolean isDeferrable)`
`static Keyspace` `clear(java.lang.String keyspaceName)`
`static Keyspace` `clear(java.lang.String keyspaceName, Schema schema)`
`static void` `clearSnapshot(java.lang.String snapshotName, java.lang.String keyspace)` Clear all the snapshots for a given keyspace.
`void` `dropCf(java.util.UUID cfId)`
`java.util.List<java.util.concurrent.Future<?>>` `flush()`
`java.util.List<SSTableReader>` `getAllSSTables(SSTableSet sstableSet)`
`ColumnFamilyStore` `getColumnFamilyStore(java.lang.String cfName)`
`ColumnFamilyStore` `getColumnFamilyStore(java.util.UUID id)`
`java.util.Collection<ColumnFamilyStore>` `getColumnFamilyStores()`
`KeyspaceMetadata` `getMetadata()`
`java.lang.String` `getName()`
`AbstractReplicationStrategy` `getReplicationStrategy()`
`static java.lang.String` `getTimestampedSnapshotName(java.lang.String clientSuppliedName)`
`static java.lang.String` `getTimestampedSnapshotNameWithPrefix(java.lang.String clientSuppliedName, java.lang.String prefix)`
`java.lang.Iterable<ColumnFamilyStore>` `getValidColumnFamilies(boolean allowIndexes, boolean autoAddIndexes, java.lang.String... cfNames)`
`boolean` `hasColumnFamilyStore(java.util.UUID id)`
`void` `initCf(CFMetaData metadata, boolean loadSSTables)` adds a cf to internal structures, ends up creating disk files).
`void` `initCfCustom(ColumnFamilyStore newCfs)` Registers a custom cf instance with this keyspace.
`static Keyspace` `mockKS(KeyspaceMetadata metadata)`
`static java.lang.Iterable<Keyspace>` `nonLocalStrategy()`
`static java.lang.Iterable<Keyspace>` `nonSystem()`
`static Keyspace` `open(java.lang.String keyspaceName)`
`static ColumnFamilyStore` `openAndGetStore(CFMetaData cfm)`
`static Keyspace` `openWithoutSSTables(java.lang.String keyspaceName)`
`static void` `removeUnreadableSSTables(java.io.File directory)` Removes every SSTable in the directory from the appropriate Tracker's view.
`static void` `setInitialized()`
`void` `setMetadata(KeyspaceMetadata metadata)`
`void` `snapshot(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 timestamp
`void` `snapshot(java.lang.String snapshotName, java.lang.String columnFamilyName, boolean skipFlush)` Take a snapshot of the specific column family, or the entire set of column families if columnFamily is null with a given timestamp
`boolean` `snapshotExists(java.lang.String snapshotName)` Check whether snapshots already exists for a given name.
`static java.lang.Iterable<Keyspace>` `system()`
`java.lang.String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### metric

    public final KeyspaceMetrics metric

#### writeOrder

    public static final OpOrder writeOrder

#### viewManager

    public final ViewManager viewManager

#### keyspaceTransformer

    public static final com.google.common.base.Function<java.lang.String,Keyspace> keyspaceTransformer

### Method Detail

#### setInitialized

    public static void setInitialized()

#### open

    public static Keyspace open(java.lang.String keyspaceName)

#### openWithoutSSTables

    public static Keyspace openWithoutSSTables(java.lang.String keyspaceName)

#### clear

    public static Keyspace clear(java.lang.String keyspaceName)

#### clear

    public static Keyspace clear(java.lang.String keyspaceName,
                                 Schema schema)

#### openAndGetStore

    public static ColumnFamilyStore openAndGetStore(CFMetaData cfm)

#### removeUnreadableSSTables

    public static void removeUnreadableSSTables(java.io.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(java.util.UUID id)

#### hasColumnFamilyStore

    public boolean hasColumnFamilyStore(java.util.UUID id)

#### snapshot

    public void snapshot(java.lang.String snapshotName,
                         java.lang.String columnFamilyName,
                         boolean skipFlush)
                  throws java.io.IOException

Take 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 null
  `columnFamilyName` - the column family to snapshot or all on null
  `skipFlush` - Skip blocking flush of memtable
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.IOException

Take 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 null
  `columnFamilyName` - 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

#### mockKS

    public static Keyspace mockKS(KeyspaceMetadata metadata)

#### dropCf

    public void dropCf(java.util.UUID cfId)

#### 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.

#### initCf

    public void initCf(CFMetaData metadata,
                       boolean loadSSTables)

adds a cf to internal structures, ends up creating disk files).

#### applyFuture

    public java.util.concurrent.CompletableFuture<?> applyFuture(Mutation mutation,
                                                                 boolean writeCommitLog,
                                                                 boolean updateIndexes)

#### applyFuture

    public java.util.concurrent.CompletableFuture<?> 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 writeCommitLog,
                      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.
  `writeCommitLog` - false to disable commitlog append entirely
  `updateIndexes` - 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_in_ms
Throws:
  `java.util.concurrent.ExecutionException`

#### getReplicationStrategy

    public AbstractReplicationStrategy getReplicationStrategy()

#### flush

    public java.util.List<java.util.concurrent.Future<?>> flush()

#### 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()

#### nonSystem

    public static java.lang.Iterable<Keyspace> nonSystem()

#### nonLocalStrategy

    public static java.lang.Iterable<Keyspace> nonLocalStrategy()

#### system

    public static java.lang.Iterable<Keyspace> system()

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### getName

    public java.lang.String getName()