Class SystemKeyspace

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

public final class SystemKeyspace extends Object
  • Field Details

  • Method Details

    • metadata

      public static KeyspaceMetadata metadata()
    • persistLocalMetadata

      public static void persistLocalMetadata()
    • persistLocalMetadata

      public static void persistLocalMetadata(Supplier<UUID> nodeIdSupplier)
    • updateCompactionHistory

      public static void updateCompactionHistory(TimeUUID taskId, String ksname, String cfname, long compactedAt, long bytesIn, long bytesOut, Map<Integer,Long> rowsMerged, Map<String,String> compactionProperties)
    • getCompactionHistory

      public static TabularData getCompactionHistory() throws OpenDataException
      Throws:
      OpenDataException
    • isViewBuilt

      public static boolean isViewBuilt(String keyspaceName, String viewName)
    • isViewStatusReplicated

      public static boolean isViewStatusReplicated(String keyspaceName, String viewName)
    • setViewBuilt

      public static void setViewBuilt(String keyspaceName, String viewName, boolean replicated)
    • setViewRemoved

      public static void setViewRemoved(String keyspaceName, String viewName)
    • finishViewBuildStatus

      public static void finishViewBuildStatus(String ksname, String viewName)
    • setViewBuiltReplicated

      public static void setViewBuiltReplicated(String ksname, String viewName)
    • updateViewBuildStatus

      public static void updateViewBuildStatus(String ksname, String viewName, Range<Token> range, Token lastToken, long keysBuilt)
    • getViewBuildStatus

      public static Map<Range<Token>,Pair<Token,Long>> getViewBuildStatus(String ksname, String viewName)
    • saveTruncationRecord

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

      public static void removeTruncationRecord(TableId id)
      This method is used to remove information about truncation time for specified column family
    • getTruncatedPosition

      public static CommitLogPosition getTruncatedPosition(TableId id)
    • getTruncatedAt

      public static long getTruncatedAt(TableId id)
    • updateTokens

      public static void updateTokens(InetAddressAndPort ep, Collection<Token> tokens)
      Record tokens being used by another node
    • updatePreferredIP

      public static boolean updatePreferredIP(InetAddressAndPort ep, InetAddressAndPort preferred_ip)
    • updatePeerInfo

      public static void updatePeerInfo(InetAddressAndPort ep, String columnName, Object value)
    • updatePeerNativeAddress

      public static void updatePeerNativeAddress(InetAddressAndPort ep, InetAddressAndPort address)
    • updateHintsDropped

      public static void updateHintsDropped(InetAddressAndPort ep, TimeUUID timePeriod, int value)
    • updateSchemaVersion

      public static void updateSchemaVersion(UUID version)
    • removeEndpoint

      public static void removeEndpoint(InetSocketAddress ep)
      Remove stored tokens being used by another node
    • updateTokens

      public static void updateTokens(Collection<Token> tokens)
      This method is used to update the System Keyspace with the new tokens for this node
    • forceBlockingFlush

      public static void forceBlockingFlush(String... cfnames)
    • loadTokens

      public static com.google.common.collect.SetMultimap<InetAddressAndPort,Token> loadTokens()
      Return a map of stored tokens to IP addresses
    • loadHostIds

      public static Map<InetAddressAndPort,UUID> loadHostIds()
      Return a map of store host_ids to IP addresses
    • getPreferredIP

      public static InetAddressAndPort getPreferredIP(InetAddressAndPort 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 Map<InetAddressAndPort,Map<String,String>> loadDcRackInfo()
      Return a map of IP addresses containing a map of dc and rack info
    • getReleaseVersion

      public static CassandraVersion getReleaseVersion(InetAddressAndPort 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 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(String keyspaceName, String indexName)
    • setIndexBuilt

      public static void setIndexBuilt(String keyspaceName, String indexName)
    • setIndexRemoved

      public static void setIndexRemoved(String keyspaceName, String indexName)
    • getBuiltIndexes

      public static List<String> getBuiltIndexes(String keyspaceName, Set<String> indexNames)
    • getLocalHostId

      public static UUID getLocalHostId()
      Read the host ID from the system keyspace.
    • getOrInitializeLocalHostId

      public static UUID getOrInitializeLocalHostId()
      Read the host ID from the system keyspace, creating (and storing) one if none exists.
    • setLocalHostId

      public static UUID setLocalHostId(UUID hostId)
      Sets the local host ID explicitly. Should only be called outside of SystemTable when replacing a node.
    • getSchemaVersion

      public static UUID getSchemaVersion()
      Gets the schema version or null if missing
    • getRack

      public static String getRack()
      Gets the stored rack for the local node, or null if none have been set yet.
    • getDatacenter

      public static String 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

      public static int legacyPaxosTtlSec(TableMetadata metadata)
    • savePaxosWritePromise

      public static void savePaxosWritePromise(DecoratedKey key, TableMetadata metadata, Ballot ballot)
    • savePaxosReadPromise

      public static void savePaxosReadPromise(DecoratedKey key, TableMetadata metadata, Ballot ballot)
    • savePaxosProposal

      public static void savePaxosProposal(Commit proposal)
    • savePaxosCommit

      public static void savePaxosCommit(Commit commit)
    • savePaxosRepairHistory

      public static void savePaxosRepairHistory(String keyspace, String table, PaxosRepairHistory history, boolean flush)
    • flushPaxosRepairHistory

      public static void flushPaxosRepairHistory()
    • loadPaxosRepairHistory

      public static PaxosRepairHistory loadPaxosRepairHistory(String keyspace, String table)
    • getSSTableReadMeter

      public static RestorableMeter getSSTableReadMeter(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.
      Parameters:
      keyspace - the keyspace the sstable belongs to
      table - the table the sstable belongs to
      id - the generation id for the sstable
    • readSSTableActivity

      public static UntypedResultSet readSSTableActivity(String keyspace, String table, SSTableId id)
    • 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

      public static void clearSSTableReadMeter(String keyspace, String table, SSTableId id)
      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

      public static void clearEstimates(String keyspace, String table)
      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

      public static void resetAvailableStreamedRangesForKeyspace(String keyspace)
    • 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

      public static void snapshotOnVersionChange() throws 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 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

      public static ByteBuffer rangeToBytes(Range<Token> range)
    • writePreparedStatement

      public static void writePreparedStatement(String loggedKeyspace, MD5Digest key, String cql, long timestamp)
    • removePreparedStatement

      public static void removePreparedStatement(MD5Digest key)
    • 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

      public static int loadPreparedStatement(MD5Digest digest, SystemKeyspace.TriFunction<MD5Digest,String,String,Boolean> onLoaded)
    • 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)