org.apache.cassandra.db

## Class SystemKeyspace

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

    public final class SystemKeyspace
    extends java.lang.Object

### Nested Class Summary

Nested Classes
`static class` `SystemKeyspace.BootstrapState`

### Field Summary

Fields
`static java.lang.String` `AVAILABLE_RANGES`
`static CFMetaData` `Batches`
`static java.lang.String` `BATCHES`
`static java.lang.String` `BUILT_INDEXES`
`static java.lang.String` `BUILT_VIEWS`
`static java.lang.String` `COMPACTION_HISTORY`
`static java.lang.String` `LEGACY_AGGREGATES` Deprecated.
`static java.lang.String` `LEGACY_BATCHLOG` Deprecated.
`static java.lang.String` `LEGACY_COLUMNFAMILIES` Deprecated.
`static java.lang.String` `LEGACY_COLUMNS` Deprecated.
`static java.lang.String` `LEGACY_FUNCTIONS` Deprecated.
`static java.lang.String` `LEGACY_HINTS` Deprecated.
`static java.lang.String` `LEGACY_KEYSPACES` Deprecated.
`static java.lang.String` `LEGACY_TRIGGERS` Deprecated.
`static java.lang.String` `LEGACY_USERTYPES` Deprecated.
`static CFMetaData` `LegacyAggregates` Deprecated.
`static CFMetaData` `LegacyBatchlog` Deprecated.
`static CFMetaData` `LegacyColumnfamilies` Deprecated.
`static CFMetaData` `LegacyColumns` Deprecated.
`static CFMetaData` `LegacyFunctions` Deprecated.
`static CFMetaData` `LegacyHints` Deprecated.
`static CFMetaData` `LegacyKeyspaces` Deprecated.
`static CFMetaData` `LegacyTriggers` Deprecated.
`static CFMetaData` `LegacyUsertypes` Deprecated.
`static java.lang.String` `LOCAL`
`static CassandraVersion` `NULL_VERSION`
`static java.lang.String` `PAXOS`
`static java.lang.String` `PEER_EVENTS`
`static java.lang.String` `PEERS`
`static java.lang.String` `PREPARED_STATEMENTS`
`static java.lang.String` `RANGE_XFERS`
`static java.lang.String` `SIZE_ESTIMATES`
`static java.lang.String` `SSTABLE_ACTIVITY`
`static java.lang.String` `TRANSFERRED_RANGES`
`static CassandraVersion` `UNREADABLE_VERSION`
`static java.lang.String` `VIEWS_BUILDS_IN_PROGRESS`

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `beginViewBuild(java.lang.String ksname, java.lang.String viewName, int generationNumber)`
`static boolean` `bootstrapComplete()`
`static boolean` `bootstrapInProgress()`
`static void` `checkHealth()` One of three things will happen if you try to read the system keyspace: 1.
`static void` `clearSizeEstimates(java.lang.String keyspace, java.lang.String table)` Clears size estimates for a table (on table drop)
`static void` `clearSSTableReadMeter(java.lang.String keyspace, java.lang.String table, int generation)` Clears persisted read rates from system.sstable_activity for SSTables that have been deleted.
`static void` `finishStartup()`
`static void` `finishViewBuildStatus(java.lang.String ksname, java.lang.String viewName)`
`static void` `forceBlockingFlush(java.lang.String cfname)`
`static java.util.Set<Range<Token>>` `getAvailableRanges(java.lang.String keyspace, IPartitioner partitioner)`
`static SystemKeyspace.BootstrapState` `getBootstrapState()`
`static java.util.List<java.lang.String>` `getBuiltIndexes(java.lang.String keyspaceName, java.util.Set<java.lang.String> indexNames)`
`static javax.management.openmbean.TabularData` `getCompactionHistory()`
`static java.lang.String` `getDatacenter()` Gets the stored data center for the local node, or null if none have been set yet.
`static java.util.UUID` `getLocalHostId()` Read the host ID from the system keyspace, creating (and storing) one if none exists.
`static java.net.InetAddress` `getPreferredIP(java.net.InetAddress ep)` Get preferred IP for given endpoint if it is known.
`static java.lang.String` `getRack()` Gets the stored rack for the local node, or null if none have been set yet.
`static CassandraVersion` `getReleaseVersion(java.net.InetAddress ep)` Get release version for given endpoint.
`static java.util.Collection<Token>` `getSavedTokens()`
`static RestorableMeter` `getSSTableReadMeter(java.lang.String keyspace, java.lang.String table, int generation)` Returns a RestorableMeter tracking the average read rate of a particular SSTable, restoring the last-seen rate from values in system.sstable_activity if present.
`static java.util.Map<java.net.InetAddress,java.util.Set<Range<Token>>>` `getTransferredRanges(java.lang.String description, java.lang.String keyspace, IPartitioner partitioner)`
`static long` `getTruncatedAt(java.util.UUID cfId)`
`static CommitLogPosition` `getTruncatedPosition(java.util.UUID cfId)`
`static Pair<java.lang.Integer,Token>` `getViewBuildStatus(java.lang.String ksname, java.lang.String viewName)`
`static int` `incrementAndGetGeneration()`
`static boolean` `isIndexBuilt(java.lang.String keyspaceName, java.lang.String indexName)`
`static boolean` `isViewBuilt(java.lang.String keyspaceName, java.lang.String viewName)`
`static boolean` `isViewStatusReplicated(java.lang.String keyspaceName, java.lang.String viewName)`
`static java.util.Map<java.net.InetAddress,java.util.Map<java.lang.String,java.lang.String>>` `loadDcRackInfo()` Return a map of IP addresses containing a map of dc and rack info
`static java.util.Map<java.net.InetAddress,java.util.UUID>` `loadHostIds()` Return a map of store host_ids to IP addresses
`static PaxosState` `loadPaxosState(DecoratedKey key, CFMetaData metadata, int nowInSec)`
`static java.util.List<Pair<java.lang.String,java.lang.String>>` `loadPreparedStatements()`
`static com.google.common.collect.SetMultimap<java.net.InetAddress,Token>` `loadTokens()` Return a map of stored tokens to IP addresses
`static KeyspaceMetadata` `metadata()`
`static void` `migrateDataDirs()` Check data directories for old files that can be removed when migrating from 2.1 or 2.2 to 3.0, these checks can be removed in 4.0, see CASSANDRA-7066
`static int` `paxosTtlSec(CFMetaData metadata)`
`static void` `persistLocalMetadata()`
`static void` `persistSSTableReadMeter(java.lang.String keyspace, java.lang.String table, int generation, RestorableMeter meter)` Writes the current read rates for a given SSTable to system.sstable_activity
`static void` `removeEndpoint(java.net.InetAddress ep)` Remove stored tokens being used by another node
`static void` `removePreparedStatement(MD5Digest key)`
`static void` `removeTruncationRecord(java.util.UUID cfId)` This method is used to remove information about truncation time for specified column family
`static void` `resetAvailableRanges()`
`static void` `resetPreparedStatements()`
`static void` `savePaxosCommit(Commit commit)`
`static void` `savePaxosPromise(Commit promise)`
`static void` `savePaxosProposal(Commit proposal)`
`static void` `saveTruncationRecord(ColumnFamilyStore cfs, long truncatedAt, CommitLogPosition position)`
`static void` `setBootstrapState(SystemKeyspace.BootstrapState state)`
`static void` `setIndexBuilt(java.lang.String keyspaceName, java.lang.String indexName)`
`static void` `setIndexRemoved(java.lang.String keyspaceName, java.lang.String indexName)`
`static java.util.UUID` `setLocalHostId(java.util.UUID hostId)` Sets the local host ID explicitly.
`static void` `setViewBuilt(java.lang.String keyspaceName, java.lang.String viewName, boolean replicated)`
`static void` `setViewBuiltReplicated(java.lang.String ksname, java.lang.String viewName)`
`static void` `setViewRemoved(java.lang.String keyspaceName, java.lang.String viewName)`
`static boolean` `snapshotOnVersionChange()` Compare the release version in the system.local table with the one included in the distro.
`static void` `updateAvailableRanges(java.lang.String keyspace, java.util.Collection<Range<Token>> completedRanges)`
`static void` `updateCompactionHistory(java.lang.String ksname, java.lang.String cfname, long compactedAt, long bytesIn, long bytesOut, java.util.Map<java.lang.Integer,java.lang.Long> rowsMerged)`
`static void` `updateHintsDropped(java.net.InetAddress ep, java.util.UUID timePeriod, int value)`
`static java.util.concurrent.Future<?>` `updatePeerInfo(java.net.InetAddress ep, java.lang.String columnName, java.lang.Object value, java.util.concurrent.ExecutorService executorService)`
`static void` `updatePreferredIP(java.net.InetAddress ep, java.net.InetAddress preferred_ip)`
`static void` `updateSchemaVersion(java.util.UUID version)`
`static void` `updateSizeEstimates(java.lang.String keyspace, java.lang.String table, java.util.Map<Range<Token>,Pair<java.lang.Long,java.lang.Long>> estimates)` Writes the current partition count and size estimates into SIZE_ESTIMATES_CF
`static void` `updateTokens(java.util.Collection<Token> tokens)` This method is used to update the System Keyspace with the new tokens for this node
`static java.util.concurrent.Future<?>` `updateTokens(java.net.InetAddress ep, java.util.Collection<Token> tokens, java.util.concurrent.ExecutorService executorService)` Record tokens being used by another node
`static void` `updateTransferredRanges(java.lang.String description, java.net.InetAddress peer, java.lang.String keyspace, java.util.Collection<Range<Token>> streamedRanges)`
`static void` `updateViewBuildStatus(java.lang.String ksname, java.lang.String viewName, Token token)`
`static boolean` `wasDecommissioned()`
`static void` `writePreparedStatement(java.lang.String loggedKeyspace, MD5Digest key, java.lang.String cql)`

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

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

### Field Detail

#### UNREADABLE_VERSION

    public static final CassandraVersion UNREADABLE_VERSION

#### NULL_VERSION

    public static final CassandraVersion NULL_VERSION

#### BATCHES

    public static final java.lang.String BATCHES

See Also:
  Constant Field Values

#### PAXOS

    public static final java.lang.String PAXOS

See Also:
  Constant Field Values

#### BUILT_INDEXES

    public static final java.lang.String BUILT_INDEXES

See Also:
  Constant Field Values

#### LOCAL

    public static final java.lang.String LOCAL

See Also:
  Constant Field Values

#### PEERS

    public static final java.lang.String PEERS

See Also:
  Constant Field Values

#### PEER_EVENTS

    public static final java.lang.String PEER_EVENTS

See Also:
  Constant Field Values

#### RANGE_XFERS

    public static final java.lang.String RANGE_XFERS

See Also:
  Constant Field Values

#### COMPACTION_HISTORY

    public static final java.lang.String COMPACTION_HISTORY

See Also:
  Constant Field Values

#### SSTABLE_ACTIVITY

    public static final java.lang.String SSTABLE_ACTIVITY

See Also:
  Constant Field Values

#### SIZE_ESTIMATES

    public static final java.lang.String SIZE_ESTIMATES

See Also:
  Constant Field Values

#### AVAILABLE_RANGES

    public static final java.lang.String AVAILABLE_RANGES

See Also:
  Constant Field Values

#### TRANSFERRED_RANGES

    public static final java.lang.String TRANSFERRED_RANGES

See Also:
  Constant Field Values

#### VIEWS_BUILDS_IN_PROGRESS

    public static final java.lang.String VIEWS_BUILDS_IN_PROGRESS

See Also:
  Constant Field Values

#### BUILT_VIEWS

    public static final java.lang.String BUILT_VIEWS

See Also:
  Constant Field Values

#### PREPARED_STATEMENTS

    public static final java.lang.String PREPARED_STATEMENTS

See Also:
  Constant Field Values

#### LEGACY_HINTS

    @Deprecated
    public static final java.lang.String LEGACY_HINTS

Deprecated.

See Also:
  Constant Field Values

#### LEGACY_BATCHLOG

    @Deprecated
    public static final java.lang.String LEGACY_BATCHLOG

Deprecated.

See Also:
  Constant Field Values

#### LEGACY_KEYSPACES

    @Deprecated
    public static final java.lang.String LEGACY_KEYSPACES

Deprecated.

See Also:
  Constant Field Values

#### LEGACY_COLUMNFAMILIES

    @Deprecated
    public static final java.lang.String LEGACY_COLUMNFAMILIES

Deprecated.

See Also:
  Constant Field Values

#### LEGACY_COLUMNS

    @Deprecated
    public static final java.lang.String LEGACY_COLUMNS

Deprecated.

See Also:
  Constant Field Values

#### LEGACY_TRIGGERS

    @Deprecated
    public static final java.lang.String LEGACY_TRIGGERS

Deprecated.

See Also:
  Constant Field Values

#### LEGACY_USERTYPES

    @Deprecated
    public static final java.lang.String LEGACY_USERTYPES

Deprecated.

See Also:
  Constant Field Values

#### LEGACY_FUNCTIONS

    @Deprecated
    public static final java.lang.String LEGACY_FUNCTIONS

Deprecated.

See Also:
  Constant Field Values

#### LEGACY_AGGREGATES

    @Deprecated
    public static final java.lang.String LEGACY_AGGREGATES

Deprecated.

See Also:
  Constant Field Values

#### Batches

    public static final CFMetaData Batches

#### LegacyHints

    @Deprecated
    public static final CFMetaData LegacyHints

Deprecated.

#### LegacyBatchlog

    @Deprecated
    public static final CFMetaData LegacyBatchlog

Deprecated.

#### LegacyKeyspaces

    @Deprecated
    public static final CFMetaData LegacyKeyspaces

Deprecated.

#### LegacyColumnfamilies

    @Deprecated
    public static final CFMetaData LegacyColumnfamilies

Deprecated.

#### LegacyColumns

    @Deprecated
    public static final CFMetaData LegacyColumns

Deprecated.

#### LegacyTriggers

    @Deprecated
    public static final CFMetaData LegacyTriggers

Deprecated.

#### LegacyUsertypes

    @Deprecated
    public static final CFMetaData LegacyUsertypes

Deprecated.

#### LegacyFunctions

    @Deprecated
    public static final CFMetaData LegacyFunctions

Deprecated.

#### LegacyAggregates

    @Deprecated
    public static final CFMetaData LegacyAggregates

Deprecated.

### Method Detail

#### metadata

    public static KeyspaceMetadata metadata()

#### finishStartup

    public static void finishStartup()

#### persistLocalMetadata

    public static void persistLocalMetadata()

#### updateCompactionHistory

    public static void updateCompactionHistory(java.lang.String ksname,
                                               java.lang.String cfname,
                                               long compactedAt,
                                               long bytesIn,
                                               long bytesOut,
                                               java.util.Map<java.lang.Integer,java.lang.Long> rowsMerged)

#### getCompactionHistory

    public static javax.management.openmbean.TabularData getCompactionHistory()
                                                                       throws javax.management.openmbean.OpenDataException

Throws:
  `javax.management.openmbean.OpenDataException`

#### isViewBuilt

    public static boolean isViewBuilt(java.lang.String keyspaceName,
                                      java.lang.String viewName)

#### isViewStatusReplicated

    public static boolean isViewStatusReplicated(java.lang.String keyspaceName,
                                                 java.lang.String viewName)

#### setViewBuilt

    public static void setViewBuilt(java.lang.String keyspaceName,
                                    java.lang.String viewName,
                                    boolean replicated)

#### setViewRemoved

    public static void setViewRemoved(java.lang.String keyspaceName,
                                      java.lang.String viewName)

#### beginViewBuild

    public static void beginViewBuild(java.lang.String ksname,
                                      java.lang.String viewName,
                                      int generationNumber)

#### finishViewBuildStatus

    public static void finishViewBuildStatus(java.lang.String ksname,
                                             java.lang.String viewName)

#### setViewBuiltReplicated

    public static void setViewBuiltReplicated(java.lang.String ksname,
                                              java.lang.String viewName)

#### updateViewBuildStatus

    public static void updateViewBuildStatus(java.lang.String ksname,
                                             java.lang.String viewName,
                                             Token token)

#### getViewBuildStatus

    public static Pair<java.lang.Integer,Token> getViewBuildStatus(java.lang.String ksname,
                                                                   java.lang.String viewName)

#### saveTruncationRecord

    public static void saveTruncationRecord(ColumnFamilyStore cfs,
                                            long truncatedAt,
                                            CommitLogPosition position)

#### removeTruncationRecord

    public static void removeTruncationRecord(java.util.UUID cfId)

This method is used to remove information about truncation time for specified column family

#### getTruncatedPosition

    public static CommitLogPosition getTruncatedPosition(java.util.UUID cfId)

#### getTruncatedAt

    public static long getTruncatedAt(java.util.UUID cfId)

#### updateTokens

    public static java.util.concurrent.Future<?> updateTokens(java.net.InetAddress ep,
                                                              java.util.Collection<Token> tokens,
                                                              java.util.concurrent.ExecutorService executorService)

Record tokens being used by another node

#### updatePreferredIP

    public static void updatePreferredIP(java.net.InetAddress ep,
                                         java.net.InetAddress preferred_ip)

#### updatePeerInfo

    public static java.util.concurrent.Future<?> updatePeerInfo(java.net.InetAddress ep,
                                                                java.lang.String columnName,
                                                                java.lang.Object value,
                                                                java.util.concurrent.ExecutorService executorService)

#### updateHintsDropped

    public static void updateHintsDropped(java.net.InetAddress ep,
                                          java.util.UUID timePeriod,
                                          int value)

#### updateSchemaVersion

    public static void updateSchemaVersion(java.util.UUID version)

#### removeEndpoint

    public static void removeEndpoint(java.net.InetAddress ep)

Remove stored tokens being used by another node

#### updateTokens

    public static void updateTokens(java.util.Collection<Token> tokens)

This method is used to update the System Keyspace with the new tokens for this node

#### forceBlockingFlush

    public static void forceBlockingFlush(java.lang.String cfname)

#### loadTokens

    public static com.google.common.collect.SetMultimap<java.net.InetAddress,Token> loadTokens()

Return a map of stored tokens to IP addresses

#### loadHostIds

    public static java.util.Map<java.net.InetAddress,java.util.UUID> loadHostIds()

Return a map of store host_ids to IP addresses

#### getPreferredIP

    public static java.net.InetAddress getPreferredIP(java.net.InetAddress ep)

Get preferred IP for given endpoint if it is known. Otherwise this returns given endpoint itself.

Parameters:
  `ep` - endpoint address to check
Returns:
  Preferred IP for given endpoint if present, otherwise returns given ep

#### loadDcRackInfo

    public static java.util.Map<java.net.InetAddress,java.util.Map<java.lang.String,java.lang.String>> loadDcRackInfo()

Return a map of IP addresses containing a map of dc and rack info

#### getReleaseVersion

    public static CassandraVersion getReleaseVersion(java.net.InetAddress ep)

Get release version for given endpoint. If release version is unknown, then this returns null.

Parameters:
  `ep` - endpoint address to check
Returns:
  Release version or null if version is unknown.

#### checkHealth

    public static void checkHealth()
                            throws ConfigurationException

One of three things will happen if you try to read the system keyspace: 1. files are present and you can read them: great 2. no files are there: great (new node is assumed) 3. files are present but you can't read them: bad

Throws:
  `ConfigurationException`

#### getSavedTokens

    public static java.util.Collection<Token> getSavedTokens()

#### incrementAndGetGeneration

    public static int incrementAndGetGeneration()

#### getBootstrapState

    public static SystemKeyspace.BootstrapState getBootstrapState()

#### bootstrapComplete

    public static boolean bootstrapComplete()

#### bootstrapInProgress

    public static boolean bootstrapInProgress()

#### wasDecommissioned

    public static boolean wasDecommissioned()

#### setBootstrapState

    public static void setBootstrapState(SystemKeyspace.BootstrapState state)

#### isIndexBuilt

    public static boolean isIndexBuilt(java.lang.String keyspaceName,
                                       java.lang.String indexName)

#### setIndexBuilt

    public static void setIndexBuilt(java.lang.String keyspaceName,
                                     java.lang.String indexName)

#### setIndexRemoved

    public static void setIndexRemoved(java.lang.String keyspaceName,
                                       java.lang.String indexName)

#### getBuiltIndexes

    public static java.util.List<java.lang.String> getBuiltIndexes(java.lang.String keyspaceName,
                                                                   java.util.Set<java.lang.String> indexNames)

#### getLocalHostId

    public static java.util.UUID getLocalHostId()

Read the host ID from the system keyspace, creating (and storing) one if none exists.

#### setLocalHostId

    public static java.util.UUID setLocalHostId(java.util.UUID hostId)

Sets the local host ID explicitly. Should only be called outside of SystemTable when replacing a node.

#### getRack

    public static java.lang.String getRack()

Gets the stored rack for the local node, or null if none have been set yet.

#### getDatacenter

    public static java.lang.String getDatacenter()

Gets the stored data center for the local node, or null if none have been set yet.

#### loadPaxosState

    public static PaxosState loadPaxosState(DecoratedKey key,
                                            CFMetaData metadata,
                                            int nowInSec)

#### savePaxosPromise

    public static void savePaxosPromise(Commit promise)

#### savePaxosProposal

    public static void savePaxosProposal(Commit proposal)

#### paxosTtlSec

    public static int paxosTtlSec(CFMetaData metadata)

#### savePaxosCommit

    public static void savePaxosCommit(Commit commit)

#### getSSTableReadMeter

    public static RestorableMeter getSSTableReadMeter(java.lang.String keyspace,
                                                      java.lang.String table,
                                                      int generation)

Returns a RestorableMeter tracking the average read rate of a particular SSTable, restoring the last-seen rate from values in system.sstable_activity if present.

Parameters:
  `keyspace` - the keyspace the sstable belongs to
  `table` - the table the sstable belongs to
  `generation` - the generation number for the sstable

#### persistSSTableReadMeter

    public static void persistSSTableReadMeter(java.lang.String keyspace,
                                               java.lang.String table,
                                               int generation,
                                               RestorableMeter meter)

Writes the current read rates for a given SSTable to system.sstable_activity

#### clearSSTableReadMeter

    public static void clearSSTableReadMeter(java.lang.String keyspace,
                                             java.lang.String table,
                                             int generation)

Clears persisted read rates from system.sstable_activity for SSTables that have been deleted.

#### updateSizeEstimates

    public static void updateSizeEstimates(java.lang.String keyspace,
                                           java.lang.String table,
                                           java.util.Map<Range<Token>,Pair<java.lang.Long,java.lang.Long>> estimates)

Writes the current partition count and size estimates into SIZE_ESTIMATES_CF

#### clearSizeEstimates

    public static void clearSizeEstimates(java.lang.String keyspace,
                                          java.lang.String table)

Clears size estimates for a table (on table drop)

#### updateAvailableRanges

    public static void updateAvailableRanges(java.lang.String keyspace,
                                             java.util.Collection<Range<Token>> completedRanges)

#### getAvailableRanges

    public static java.util.Set<Range<Token>> getAvailableRanges(java.lang.String keyspace,
                                                                 IPartitioner partitioner)

#### resetAvailableRanges

    public static void resetAvailableRanges()

#### updateTransferredRanges

    public static void updateTransferredRanges(java.lang.String description,
                                               java.net.InetAddress peer,
                                               java.lang.String keyspace,
                                               java.util.Collection<Range<Token>> streamedRanges)

#### getTransferredRanges

    public static java.util.Map<java.net.InetAddress,java.util.Set<Range<Token>>> getTransferredRanges(java.lang.String description,
                                                                                                       java.lang.String keyspace,
                                                                                                       IPartitioner partitioner)

#### snapshotOnVersionChange

    public static boolean snapshotOnVersionChange()
                                           throws java.io.IOException

Compare the release version in the system.local table with the one included in the distro. If they don't match, snapshot all tables in the system keyspace. This is intended to be called at startup to create a backup of the system tables during an upgrade

Throws:
  `java.io.IOException`

#### migrateDataDirs

    public static void migrateDataDirs()

Check data directories for old files that can be removed when migrating from 2.1 or 2.2 to 3.0, these checks can be removed in 4.0, see CASSANDRA-7066

#### writePreparedStatement

    public static void writePreparedStatement(java.lang.String loggedKeyspace,
                                              MD5Digest key,
                                              java.lang.String cql)

#### removePreparedStatement

    public static void removePreparedStatement(MD5Digest key)

#### resetPreparedStatements

    public static void resetPreparedStatements()

#### loadPreparedStatements

    public static java.util.List<Pair<java.lang.String,java.lang.String>> loadPreparedStatements()