Package org.apache.cassandra.db
Class SystemKeyspace
java.lang.Object
org.apache.cassandra.db.SystemKeyspace
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final TableMetadatastatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final CassandraVersionstatic final StringDeprecated.See CASSANDRA-14404static final StringDeprecated.See CASSANDRA-7544static final StringDeprecated.See CASSANDRA-7544static final StringDeprecated.See CASSANDRA-15637static final StringDeprecated.See CASSANDRA-17048static final StringDeprecated.See CASSANDRA-7544static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringBy default the system keyspace tables should be stored in a single data directory to allow the server to handle more gracefully disk failures.static final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic booleanstatic voidOne of three things will happen if you try to read the system keyspace: 1.static voidtruncates size_estimates and table_estimates tablesstatic voidclearEstimates(String keyspace, String table) Clears size estimates for a table (on table drop)static voidclearSSTableReadMeter(String keyspace, String table, SSTableId id) Clears persisted read rates from system.sstable_activity for SSTables that have been deleted.static voidfinishViewBuildStatus(String ksname, String viewName) static voidstatic voidforceBlockingFlush(String... cfnames) getAvailableRanges(String keyspace, IPartitioner partitioner) List of the streamed ranges, where transientness is encoded based on the source, where range was streamed from.getBuiltIndexes(String keyspaceName, Set<String> indexNames) static TabularDatastatic StringGets the stored data center for the local node, or null if none have been set yet.static UUIDRead the host ID from the system keyspace.static UUIDRead the host ID from the system keyspace, creating (and storing) one if none exists.static InetAddressAndPortGet preferred IP for given endpoint if it is known.static StringgetRack()Gets the stored rack for the local node, or null if none have been set yet.static CassandraVersionGet release version for given endpoint.static Collection<Token>static UUIDGets the schema version or null if missingstatic RestorableMetergetSSTableReadMeter(String keyspace, String table, SSTableId id) 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.getTopPartitions(TableMetadata metadata, String topType) static Map<InetAddressAndPort,Set<Range<Token>>> getTransferredRanges(String description, String keyspace, IPartitioner partitioner) static longstatic CommitLogPositiongetViewBuildStatus(String ksname, String viewName) static intstatic booleanisIndexBuilt(String keyspaceName, String indexName) static booleanisViewBuilt(String keyspaceName, String viewName) static booleanisViewStatusReplicated(String keyspaceName, String viewName) static intlegacyPaxosTtlSec(TableMetadata metadata) static Map<InetAddressAndPort,Map<String, String>> Return a map of IP addresses containing a map of dc and rack infostatic Map<InetAddressAndPort,UUID> Return a map of store host_ids to IP addressesstatic PaxosRepairHistoryloadPaxosRepairHistory(String keyspace, String table) static PaxosState.SnapshotloadPaxosState(DecoratedKey partitionKey, TableMetadata metadata, long nowInSec) Load the current paxos state for the table and key NOTE: nowInSec is typically provided as zero, and should not be assumed to be definitive, as the cache may apply different nowInSec filtersstatic intloadPreparedStatement(MD5Digest digest, SystemKeyspace.TriFunction<MD5Digest, String, String, Boolean> onLoaded) static intloadPreparedStatements(SystemKeyspace.TriFunction<MD5Digest, String, String, QueryHandler.Prepared> onLoaded) static intloadPreparedStatements(SystemKeyspace.TriFunction<MD5Digest, String, String, QueryHandler.Prepared> onLoaded, int pageSize) static com.google.common.collect.SetMultimap<InetAddressAndPort,Token> Return a map of stored tokens to IP addressesstatic KeyspaceMetadatametadata()static voidstatic voidpersistLocalMetadata(Supplier<UUID> nodeIdSupplier) static voidpersistSSTableReadMeter(String keyspace, String table, SSTableId id, RestorableMeter meter) Writes the current read rates for a given SSTable to system.sstable_activitystatic ByteBufferrangeToBytes(Range<Token> range) rawRangesToRangeSet(Set<ByteBuffer> rawRanges, IPartitioner partitioner) static UntypedResultSetreadSSTableActivity(String keyspace, String table, SSTableId id) static voidRemove stored tokens being used by another nodestatic voidstatic voidThis method is used to remove information about truncation time for specified column familystatic voidstatic voidstatic voidstatic voidsavePaxosCommit(Commit commit) static voidsavePaxosProposal(Commit proposal) static voidsavePaxosReadPromise(DecoratedKey key, TableMetadata metadata, Ballot ballot) static voidsavePaxosRepairHistory(String keyspace, String table, PaxosRepairHistory history, boolean flush) static voidsavePaxosWritePromise(DecoratedKey key, TableMetadata metadata, Ballot ballot) static voidsaveTopPartitions(TableMetadata metadata, String topType, Collection<TopPartitionTracker.TopPartition> topPartitions, long lastUpdate) static voidsaveTruncationRecord(ColumnFamilyStore cfs, long truncatedAt, CommitLogPosition position) static voidstatic voidsetIndexBuilt(String keyspaceName, String indexName) static voidsetIndexRemoved(String keyspaceName, String indexName) static UUIDsetLocalHostId(UUID hostId) Sets the local host ID explicitly.static voidsetViewBuilt(String keyspaceName, String viewName, boolean replicated) static voidsetViewBuiltReplicated(String ksname, String viewName) static voidsetViewRemoved(String keyspaceName, String viewName) static voidCompare the release version in the system.local table with the one included in the distro.static voidupdateAvailableRanges(String keyspace, Collection<Range<Token>> completedFullRanges, Collection<Range<Token>> completedTransientRanges) static voidupdateCompactionHistory(TimeUUID taskId, String ksname, String cfname, long compactedAt, long bytesIn, long bytesOut, Map<Integer, Long> rowsMerged, Map<String, String> compactionProperties) static voidupdateHintsDropped(InetAddressAndPort ep, TimeUUID timePeriod, int value) static voidupdatePeerInfo(InetAddressAndPort ep, String columnName, Object value) static voidupdatePeerNativeAddress(InetAddressAndPort ep, InetAddressAndPort address) static booleanupdatePreferredIP(InetAddressAndPort ep, InetAddressAndPort preferred_ip) static voidupdateSchemaVersion(UUID version) static voidWrites the current partition count and size estimates into SIZE_ESTIMATES_CFstatic voidupdateTableEstimates(String keyspace, String table, String type, Map<Range<Token>, Pair<Long, Long>> estimates) Writes the current partition count and size estimates into table_estimatesstatic voidupdateTokens(Collection<Token> tokens) This method is used to update the System Keyspace with the new tokens for this nodestatic voidupdateTokens(InetAddressAndPort ep, Collection<Token> tokens) Record tokens being used by another nodestatic voidupdateTransferredRanges(StreamOperation streamOperation, InetAddressAndPort peer, String keyspace, Collection<Range<Token>> streamedRanges) static voidupdateViewBuildStatus(String ksname, String viewName, Range<Token> range, Token lastToken, long keysBuilt) static booleanstatic voidwritePreparedStatement(String loggedKeyspace, MD5Digest key, String cql, long timestamp)
-
Field Details
-
CURRENT_VERSION
-
BATCHES
- See Also:
-
PAXOS
- See Also:
-
PAXOS_REPAIR_HISTORY
- See Also:
-
PAXOS_REPAIR_STATE
- See Also:
-
BUILT_INDEXES
- See Also:
-
LOCAL
- See Also:
-
PEERS_V2
- See Also:
-
PEER_EVENTS_V2
- See Also:
-
COMPACTION_HISTORY
- See Also:
-
SSTABLE_ACTIVITY_V2
- See Also:
-
TABLE_ESTIMATES
- See Also:
-
TABLE_ESTIMATES_TYPE_PRIMARY
- See Also:
-
TABLE_ESTIMATES_TYPE_LOCAL_PRIMARY
- See Also:
-
AVAILABLE_RANGES_V2
- See Also:
-
TRANSFERRED_RANGES_V2
- See Also:
-
VIEW_BUILDS_IN_PROGRESS
- See Also:
-
BUILT_VIEWS
- See Also:
-
PREPARED_STATEMENTS
- See Also:
-
REPAIRS
- See Also:
-
TOP_PARTITIONS
- See Also:
-
TABLES_SPLIT_ACROSS_MULTIPLE_DISKS
By default the system keyspace tables should be stored in a single data directory to allow the server to handle more gracefully disk failures. Some tables through can be split accross multiple directories as the server can continue operating even if those tables lost some data. -
LEGACY_PEERS
Deprecated.See CASSANDRA-7544- See Also:
-
LEGACY_PEER_EVENTS
Deprecated.See CASSANDRA-7544- See Also:
-
LEGACY_TRANSFERRED_RANGES
Deprecated.See CASSANDRA-7544- See Also:
-
LEGACY_AVAILABLE_RANGES
Deprecated.See CASSANDRA-14404- See Also:
-
LEGACY_SIZE_ESTIMATES
Deprecated.See CASSANDRA-15637- See Also:
-
LEGACY_SSTABLE_ACTIVITY
Deprecated.See CASSANDRA-17048- See Also:
-
ALL_TABLE_NAMES
-
TABLE_NAMES
-
Batches
-
-
Method Details
-
metadata
-
persistLocalMetadata
public static void persistLocalMetadata() -
persistLocalMetadata
-
updateCompactionHistory
-
getCompactionHistory
- Throws:
OpenDataException
-
isViewBuilt
-
isViewStatusReplicated
-
setViewBuilt
-
setViewRemoved
-
finishViewBuildStatus
-
setViewBuiltReplicated
-
updateViewBuildStatus
-
getViewBuildStatus
-
saveTruncationRecord
public static void saveTruncationRecord(ColumnFamilyStore cfs, long truncatedAt, CommitLogPosition position) -
removeTruncationRecord
This method is used to remove information about truncation time for specified column family -
getTruncatedPosition
-
getTruncatedAt
-
updateTokens
Record tokens being used by another node -
updatePreferredIP
-
updatePeerInfo
-
updatePeerNativeAddress
-
updateHintsDropped
-
updateSchemaVersion
-
removeEndpoint
Remove stored tokens being used by another node -
updateTokens
This method is used to update the System Keyspace with the new tokens for this node -
forceBlockingFlush
-
loadTokens
Return a map of stored tokens to IP addresses -
loadHostIds
Return a map of store host_ids to IP addresses -
getPreferredIP
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
Return a map of IP addresses containing a map of dc and rack info -
getReleaseVersion
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
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
-
incrementAndGetGeneration
public static int incrementAndGetGeneration() -
getBootstrapState
-
bootstrapComplete
public static boolean bootstrapComplete() -
bootstrapInProgress
public static boolean bootstrapInProgress() -
wasDecommissioned
public static boolean wasDecommissioned() -
setBootstrapState
-
isIndexBuilt
-
setIndexBuilt
-
setIndexRemoved
-
getBuiltIndexes
-
getLocalHostId
Read the host ID from the system keyspace. -
getOrInitializeLocalHostId
Read the host ID from the system keyspace, creating (and storing) one if none exists. -
setLocalHostId
Sets the local host ID explicitly. Should only be called outside of SystemTable when replacing a node. -
getSchemaVersion
Gets the schema version or null if missing -
getRack
Gets the stored rack for the local node, or null if none have been set yet. -
getDatacenter
Gets the stored data center for the local node, or null if none have been set yet. -
loadPaxosState
public static PaxosState.Snapshot loadPaxosState(DecoratedKey partitionKey, TableMetadata metadata, long nowInSec) Load the current paxos state for the table and key NOTE: nowInSec is typically provided as zero, and should not be assumed to be definitive, as the cache may apply different nowInSec filters -
legacyPaxosTtlSec
-
savePaxosWritePromise
-
savePaxosReadPromise
-
savePaxosProposal
-
savePaxosCommit
-
savePaxosRepairHistory
public static void savePaxosRepairHistory(String keyspace, String table, PaxosRepairHistory history, boolean flush) -
flushPaxosRepairHistory
public static void flushPaxosRepairHistory() -
loadPaxosRepairHistory
-
getSSTableReadMeter
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 totable- the table the sstable belongs toid- the generation id for the sstable
-
readSSTableActivity
-
persistSSTableReadMeter
public static void persistSSTableReadMeter(String keyspace, String table, SSTableId id, RestorableMeter meter) Writes the current read rates for a given SSTable to system.sstable_activity -
clearSSTableReadMeter
Clears persisted read rates from system.sstable_activity for SSTables that have been deleted. -
updateSizeEstimates
public static void updateSizeEstimates(String keyspace, String table, Map<Range<Token>, Pair<Long, Long>> estimates) Writes the current partition count and size estimates into SIZE_ESTIMATES_CF -
updateTableEstimates
public static void updateTableEstimates(String keyspace, String table, String type, Map<Range<Token>, Pair<Long, Long>> estimates) Writes the current partition count and size estimates into table_estimates -
clearEstimates
Clears size estimates for a table (on table drop) -
clearAllEstimates
public static void clearAllEstimates()truncates size_estimates and table_estimates tables -
updateAvailableRanges
public static void updateAvailableRanges(String keyspace, Collection<Range<Token>> completedFullRanges, Collection<Range<Token>> completedTransientRanges) -
getAvailableRanges
public static SystemKeyspace.AvailableRanges getAvailableRanges(String keyspace, IPartitioner partitioner) List of the streamed ranges, where transientness is encoded based on the source, where range was streamed from. -
resetAvailableStreamedRanges
public static void resetAvailableStreamedRanges() -
resetAvailableStreamedRangesForKeyspace
-
updateTransferredRanges
public static void updateTransferredRanges(StreamOperation streamOperation, InetAddressAndPort peer, String keyspace, Collection<Range<Token>> streamedRanges) -
getTransferredRanges
public static Map<InetAddressAndPort,Set<Range<Token>>> getTransferredRanges(String description, String keyspace, IPartitioner partitioner) -
snapshotOnVersionChange
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 and schema keyspaces. This is intended to be called at startup to create a backup of the system tables during an upgrade- Throws:
IOException
-
rawRangesToRangeSet
public static Set<Range<Token>> rawRangesToRangeSet(Set<ByteBuffer> rawRanges, IPartitioner partitioner) -
rangeToBytes
-
writePreparedStatement
-
removePreparedStatement
-
resetPreparedStatements
public static void resetPreparedStatements() -
loadPreparedStatements
public static int loadPreparedStatements(SystemKeyspace.TriFunction<MD5Digest, String, String, QueryHandler.Prepared> onLoaded) -
loadPreparedStatements
public static int loadPreparedStatements(SystemKeyspace.TriFunction<MD5Digest, String, String, QueryHandler.Prepared> onLoaded, int pageSize) -
loadPreparedStatement
-
saveTopPartitions
public static void saveTopPartitions(TableMetadata metadata, String topType, Collection<TopPartitionTracker.TopPartition> topPartitions, long lastUpdate) -
getTopPartitions
public static TopPartitionTracker.StoredTopPartitions getTopPartitions(TableMetadata metadata, String topType)
-