org.apache.cassandra.db

## Class SystemKeyspace

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

-     public class SystemKeyspace
      extends java.lang.Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SystemKeyspace.BootstrapState`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.util.List<java.lang.String>` | `allSchemaCfs`
    `static java.lang.String` | `BATCHLOG_CF`
    `static java.lang.String` | `COMPACTION_HISTORY_CF`
    `static java.lang.String` | `COMPACTION_LOG`
    `static java.lang.String` | `HINTS_CF`
    `static java.lang.String` | `INDEX_CF`
    `static java.lang.String` | `LOCAL_CF`
    `static java.lang.String` | `PAXOS_CF`
    `static java.lang.String` | `PEER_EVENTS_CF`
    `static java.lang.String` | `PEERS_CF`
    `static java.lang.String` | `RANGE_XFERS_CF`
    `static java.lang.String` | `SCHEMA_COLUMNFAMILIES_CF`
    `static java.lang.String` | `SCHEMA_COLUMNS_CF`
    `static java.lang.String` | `SCHEMA_KEYSPACES_CF`
    `static java.lang.String` | `SCHEMA_TRIGGERS_CF`
    `static java.lang.String` | `SCHEMA_USER_TYPES_CF`
    `static java.lang.String` | `SSTABLE_ACTIVITY_CF`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SystemKeyspace()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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` | `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` | `discardCompactionsInProgress()`
    `static void` | `finishCompaction(java.util.UUID taskId)` Deletes the entry for this compaction from the set of compactions in progress.
    `static void` | `finishStartup()`
    `static void` | `forceBlockingFlush(java.lang.String cfname)`
    `static SystemKeyspace.BootstrapState` | `getBootstrapState()`
    `static javax.management.openmbean.TabularData` | `getCompactionHistory()`
    `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.util.Collection<Token>` | `getSavedTokens()`
    `static java.util.Map<DecoratedKey,ColumnFamily>` | `getSchema(java.lang.String schemaCfName, java.util.Set<java.lang.String> keyspaces)`
    `static java.nio.ByteBuffer` | `getSchemaKSKey(java.lang.String ksName)`
    `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 long` | `getTruncatedAt(java.util.UUID cfId)`
    `static ReplayPosition` | `getTruncatedPosition(java.util.UUID cfId)`
    `static java.util.Map<Pair<java.lang.String,java.lang.String>,java.util.Map<java.lang.Integer,java.util.UUID>>` | `getUnfinishedCompactions()` Returns a Map whose keys are KS.CF pairs and whose values are maps from sstable generation numbers to the task ID of the compaction they were participating in.
    `static int` | `incrementAndGetGeneration()`
    `static boolean` | `isIndexBuilt(java.lang.String keyspaceName, java.lang.String indexName)`
    `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(java.nio.ByteBuffer key, CFMetaData metadata)`
    `static com.google.common.collect.SetMultimap<java.net.InetAddress,Token>` | `loadTokens()` Return a map of stored tokens to IP addresses
    `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 Row` | `readSchemaRow(java.lang.String schemaCfName, java.lang.String ksName)` Fetches a subset of schema (table data, columns metadata or triggers) for the keyspace.
    `static Row` | `readSchemaRow(java.lang.String schemaCfName, java.lang.String ksName, java.lang.String cfName)` Fetches a subset of schema (table data, columns metadata or triggers) for the keyspace+table pair.
    `static void` | `removeEndpoint(java.net.InetAddress ep)` Remove stored tokens being used by another node
    `static void` | `removeTruncationRecord(java.util.UUID cfId)` This method is used to remove information about truncation time for specified column family
    `static void` | `savePaxosCommit(Commit commit)`
    `static void` | `savePaxosPromise(Commit promise)`
    `static void` | `savePaxosProposal(Commit proposal)`
    `static void` | `saveTruncationRecord(ColumnFamilyStore cfs, long truncatedAt, ReplayPosition position)`
    `static ColumnFamilyStore` | `schemaCFS(java.lang.String cfName)`
    `static java.util.List<Row>` | `serializedSchema()`
    `static java.util.List<Row>` | `serializedSchema(java.lang.String schemaCfName)`
    `static java.util.Collection<Mutation>` | `serializeSchema()`
    `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 java.util.UUID` | `startCompaction(ColumnFamilyStore cfs, java.lang.Iterable<SSTableReader> toCompact)` Write compaction log, except columfamilies under system keyspace.
    `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.Collection<Token>` | `updateLocalTokens(java.util.Collection<Token> addTokens, java.util.Collection<Token> rmTokens)` Convenience method to update the list of tokens in the local system keyspace.
    `static void` | `updatePeerInfo(java.net.InetAddress ep, java.lang.String columnName, java.lang.Object value)`
    `static void` | `updatePreferredIP(java.net.InetAddress ep, java.net.InetAddress preferred_ip)`
    `static void` | `updateSchemaVersion(java.util.UUID version)`
    `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 void` | `updateTokens(java.net.InetAddress ep, java.util.Collection<Token> tokens)` Record tokens being used by another node

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

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

- - ### Field Detail

    - #### PEERS_CF

          public static final java.lang.String PEERS_CF

      See Also:
        Constant Field Values

    - #### PEER_EVENTS_CF

          public static final java.lang.String PEER_EVENTS_CF

      See Also:
        Constant Field Values

    - #### LOCAL_CF

          public static final java.lang.String LOCAL_CF

      See Also:
        Constant Field Values

    - #### INDEX_CF

          public static final java.lang.String INDEX_CF

      See Also:
        Constant Field Values

    - #### HINTS_CF

          public static final java.lang.String HINTS_CF

      See Also:
        Constant Field Values

    - #### RANGE_XFERS_CF

          public static final java.lang.String RANGE_XFERS_CF

      See Also:
        Constant Field Values

    - #### BATCHLOG_CF

          public static final java.lang.String BATCHLOG_CF

      See Also:
        Constant Field Values

    - #### SCHEMA_KEYSPACES_CF

          public static final java.lang.String SCHEMA_KEYSPACES_CF

      See Also:
        Constant Field Values

    - #### SCHEMA_COLUMNFAMILIES_CF

          public static final java.lang.String SCHEMA_COLUMNFAMILIES_CF

      See Also:
        Constant Field Values

    - #### SCHEMA_COLUMNS_CF

          public static final java.lang.String SCHEMA_COLUMNS_CF

      See Also:
        Constant Field Values

    - #### SCHEMA_TRIGGERS_CF

          public static final java.lang.String SCHEMA_TRIGGERS_CF

      See Also:
        Constant Field Values

    - #### SCHEMA_USER_TYPES_CF

          public static final java.lang.String SCHEMA_USER_TYPES_CF

      See Also:
        Constant Field Values

    - #### COMPACTION_LOG

          public static final java.lang.String COMPACTION_LOG

      See Also:
        Constant Field Values

    - #### PAXOS_CF

          public static final java.lang.String PAXOS_CF

      See Also:
        Constant Field Values

    - #### SSTABLE_ACTIVITY_CF

          public static final java.lang.String SSTABLE_ACTIVITY_CF

      See Also:
        Constant Field Values

    - #### COMPACTION_HISTORY_CF

          public static final java.lang.String COMPACTION_HISTORY_CF

      See Also:
        Constant Field Values

    - #### allSchemaCfs

          public static final java.util.List<java.lang.String> allSchemaCfs

  - ### Constructor Detail

    - #### SystemKeyspace

          public SystemKeyspace()

  - ### Method Detail

    - #### finishStartup

          public static void finishStartup()

    - #### startCompaction

          public static java.util.UUID startCompaction(ColumnFamilyStore cfs,
                                       java.lang.Iterable<SSTableReader> toCompact)

      Write compaction log, except columfamilies under system keyspace.
      Parameters:
        `cfs` -
        `toCompact` - sstables to compact
      Returns:
        compaction task id or null if cfs is under system keyspace

    - #### finishCompaction

          public static void finishCompaction(java.util.UUID taskId)

      Deletes the entry for this compaction from the set of compactions in progress. The compaction does not need to complete successfully for this to be called.
      Parameters:
        `taskId` - what was returned from `startCompaction`

    - #### getUnfinishedCompactions

          public static java.util.Map<Pair<java.lang.String,java.lang.String>,java.util.Map<java.lang.Integer,java.util.UUID>> getUnfinishedCompactions()

      Returns a Map whose keys are KS.CF pairs and whose values are maps from sstable generation numbers to the task ID of the compaction they were participating in.

    - #### discardCompactionsInProgress

          public static void discardCompactionsInProgress()

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

    - #### saveTruncationRecord

          public static void saveTruncationRecord(ColumnFamilyStore cfs,
                                  long truncatedAt,
                                  ReplayPosition 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 ReplayPosition getTruncatedPosition(java.util.UUID cfId)

    - #### getTruncatedAt

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

    - #### updateTokens

          public static void updateTokens(java.net.InetAddress ep,
                          java.util.Collection<Token> tokens)

      Record tokens being used by another node

    - #### updatePreferredIP

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

    - #### updatePeerInfo

          public static void updatePeerInfo(java.net.InetAddress ep,
                            java.lang.String columnName,
                            java.lang.Object value)

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

    - #### updateLocalTokens

          public static java.util.Collection<Token> updateLocalTokens(java.util.Collection<Token> addTokens,
                                                      java.util.Collection<Token> rmTokens)

      Convenience method to update the list of tokens in the local system keyspace.
      Parameters:
        `addTokens` - tokens to add
        `rmTokens` - tokens to remove
      Returns:
        the collection of persisted tokens

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

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

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

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

    - #### schemaCFS

          public static ColumnFamilyStore schemaCFS(java.lang.String cfName)

      Parameters:
        `cfName` - The name of the ColumnFamily responsible for part of the schema (keyspace, ColumnFamily, columns)
      Returns:
        CFS responsible to hold low-level serialized schema

    - #### serializedSchema

          public static java.util.List<Row> serializedSchema()

    - #### serializedSchema

          public static java.util.List<Row> serializedSchema(java.lang.String schemaCfName)

      Parameters:
        `schemaCfName` - The name of the ColumnFamily responsible for part of the schema (keyspace, ColumnFamily, columns)
      Returns:
        low-level schema representation (each row represents individual Keyspace or ColumnFamily)

    - #### serializeSchema

          public static java.util.Collection<Mutation> serializeSchema()

    - #### getSchema

          public static java.util.Map<DecoratedKey,ColumnFamily> getSchema(java.lang.String schemaCfName,
                                                           java.util.Set<java.lang.String> keyspaces)

    - #### getSchemaKSKey

          public static java.nio.ByteBuffer getSchemaKSKey(java.lang.String ksName)

    - #### readSchemaRow

          public static Row readSchemaRow(java.lang.String schemaCfName,
                          java.lang.String ksName)

      Fetches a subset of schema (table data, columns metadata or triggers) for the keyspace.
      Parameters:
        `schemaCfName` - the schema table to get the data from (schema_keyspaces, schema_columnfamilies, schema_columns or schema_triggers)
        `ksName` - the keyspace of the tables we are interested in
      Returns:
        a Row containing the schema data of a particular type for the keyspace

    - #### readSchemaRow

          public static Row readSchemaRow(java.lang.String schemaCfName,
                          java.lang.String ksName,
                          java.lang.String cfName)

      Fetches a subset of schema (table data, columns metadata or triggers) for the keyspace+table pair.
      Parameters:
        `schemaCfName` - the schema table to get the data from (schema_columnfamilies, schema_columns or schema_triggers)
        `ksName` - the keyspace of the table we are interested in
        `cfName` - the table we are interested in
      Returns:
        a Row containing the schema data of a particular type for the table

    - #### loadPaxosState

          public static PaxosState loadPaxosState(java.nio.ByteBuffer key,
                                  CFMetaData metadata)

    - #### savePaxosPromise

          public static void savePaxosPromise(Commit promise)

    - #### savePaxosProposal

          public static void savePaxosProposal(Commit proposal)

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

Copyright © 2014 The Apache Software Foundation