Package org.apache.cassandra.db
Class ColumnFamilyStore
java.lang.Object
org.apache.cassandra.db.ColumnFamilyStore
- All Implemented Interfaces:
ColumnFamilyStoreMBean,Memtable.Owner,SSTable.Owner
public class ColumnFamilyStore
extends Object
implements ColumnFamilyStoreMBean, Memtable.Owner, SSTable.Owner
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumReason for initiating a memtable flush.static classstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionlongfinal SecondaryIndexManagerfinal Keyspacefinal TableMetadataReffinal TableMetricsfinal Stringfinal OpOrderstatic final intSpecial values used when the local ranges are not changed with ring changes (e.g.longstatic final Stringstatic final Stringfinal TopPartitionTrackerfinal TableViews -
Constructor Summary
ConstructorsConstructorDescriptionColumnFamilyStore(Keyspace keyspace, String columnFamilyName, Supplier<? extends SSTableId> sstableIdGenerator, TableMetadataRef metadata, Directories directories, boolean loadSSTables, boolean registerBookeeping, boolean offline) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSSTable(SSTableReader sstable) voidaddSSTables(Collection<SSTableReader> sstables) static Iterable<ColumnFamilyStore>all()voidapply(PartitionUpdate update, CassandraWriteContext context, boolean updateIndexes) Insert/Update the column family for this key.voidbeginLocalSampling(String sampler, int capacity, int durationMillis) begin sampling for a specific sampler with a given capacity.voidprotected static voidclearEphemeralSnapshots(Directories directories) voidclearSnapshot(String snapshotName) Clear all the snapshots for a given column family.voidFor testing.voidcompactionDiskSpaceCheck(boolean enable) booleanstatic ColumnFamilyStorecreateColumnFamilyStore(Keyspace keyspace, String columnFamily, TableMetadataRef metadata, boolean loadSSTables) static ColumnFamilyStorecreateColumnFamilyStore(Keyspace keyspace, String columnFamily, TableMetadataRef metadata, Directories directories, boolean loadSSTables, boolean registerBookkeeping, boolean offline) This is only directly used by offline toolsstatic ColumnFamilyStorecreateColumnFamilyStore(Keyspace keyspace, TableMetadataRef metadata, boolean loadSSTables) createCompactionStrategyInstance(CompactionParams compactionParams) createMemtable(AtomicReference<CommitLogPosition> commitLogUpperBound) protected TableSnapshotcreateSnapshot(String tag, boolean ephemeral, DurationSpec.IntSecondsBound ttl, Set<SSTableReader> sstables, Instant creationTime) createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, TimeUUID pendingRepair, boolean isTransient, IntervalSet<CommitLogPosition> commitLogPositions, int sstableLevel, SerializationHeader header, LifecycleNewTracker lifecycleNewTracker) createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, TimeUUID pendingRepair, boolean isTransient, IntervalSet<CommitLogPosition> commitLogPositions, SerializationHeader header, LifecycleNewTracker lifecycleNewTracker) createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, TimeUUID pendingRepair, boolean isTransient, SerializationHeader header, LifecycleNewTracker lifecycleNewTracker) decorateKey(ByteBuffer key) voidvoiddiscardSSTables(long truncatedAt) Discard all SSTables that were created before given timestamp.Drops current memtable without flushing to disk.voidvoidenableAutoCompaction(boolean waitForFutures) used for tests - to be able to check things after a minor compactionlongestimatedKeysForRange(Range<Token> range) longfinishLocalSampling(String sampler, int count) forceCleanup(int jobs) voidvoidforceCompactionForTokenRange(Collection<Range<Token>> tokenRanges) Forces a major compaction of specified token ranges in this column family.voidforceCompactionForTokenRanges(String... strings) Forces a major compaction of specified token ranges in this column family.voidforceCompactionKeysIgnoringGcGrace(String... partitionKeysIgnoreGcGrace) Flush if there is unflushed data in the memtablesFuture<?>forceFlush(CommitLogPosition flushIfDirtyBefore) Flush if there is unflushed data that was written to the CommitLog before @param flushIfDirtyBefore (inclusive).voidvoidforceMajorCompaction(boolean splitOutput) force a major compaction of this column familyfullWeightedRange(long ringVersion, IPartitioner partitioner) garbageCollect(CompactionParams.TombstoneOption tombstoneOption, int jobs) longgcBefore(long nowInSec) like getOverlappingSSTables, but acquires references before returningstatic RunnableReturns a list of the names of the built column indexes for current storegetCachedCounter(ByteBuffer partitionKey, Clustering<?> clustering, ColumnMetadata column, CellPath path) static StringgetColumnFamilieMBeanName(String ks, String name, boolean isIndex) Deprecated.See CASSANDRA-9448Get the compression parametersGet the current memtable for this owner.getDirectoriesForFiles(Set<SSTableReader> sstables) Grabs the global first/last tokens among sstables and returns the range of data directories that start/end with those tokens.doubleGet the ratio of droppable tombstones to real columns (and non-droppable tombstones)longgetExpectedCompactedFileSize(Iterable<SSTableReader> sstables, OperationType operation) Calculate expected file size of SSTable after compaction.static ColumnFamilyStoregetIfExists(String ksName, String cfName) Returns a ColumnFamilyStore by ksname and cfname if it exists, null otherwise Differently from others, this method does not throw exception if the keyspace or table does not exist.static ColumnFamilyStoregetIfExists(TableId id) Returns a ColumnFamilyStore by id if it exists, null otherwise Differently from others, this method does not throw exception if the table does not exist.static ColumnFamilyStoregetIfExists(TableMetadata table) Returns a ColumnFamilyStore by metadata if it exists, null otherwise Differently from others, this method does not throw exception if the table does not exist.Collect the index memtables flushed together with this.intintGets the maximum number of sstables in queue before compaction kicks offgetMaxSizeFile(Iterable<SSTableReader> sstables) longReturns the longest duration of an SSTable, in milliseconds, of this table, computed asmaxTimestamp - minTimestamp.longReturns the size of the biggest SSTable of this table.intdoubleintintGets the minimum number of sstables in queue before compaction kicks offbooleangetOverlappingLiveSSTables(Iterable<SSTableReader> sstables) getPaxosRepairHistoryForRanges(Collection<Range<Token>> ranges) long[]int[]int[]getSSTables(SSTableSet sstableSet) getSSTablesForKey(String key) Returns a list of filenames that contain the given key on this nodegetSSTablesForKey(String key, boolean hexFormat) Returns a list of filenames that contain the given key on this nodegetSSTablesForKeyWithLevel(String key, boolean hexFormat) Returns a list of filenames that contain the given key and which level they belong to.static StringgetTableMBeanName(String ks, String name, boolean isIndex) Package protected for access from the CompactionManager.intbooleanCheck SSTables whether or not they are misplaced.importNewSSTables(Set<String> srcPaths, boolean resetLevel, boolean clearRepaired, boolean verifySSTables, boolean verifyTokens, boolean invalidateCaches, boolean extendedVerify) importNewSSTables(Set<String> srcPaths, boolean resetLevel, boolean clearRepaired, boolean verifySSTables, boolean verifyTokens, boolean invalidateCaches, boolean extendedVerify, boolean copyData) importNewSSTables(Set<String> srcPaths, boolean resetLevel, boolean clearRepaired, boolean verifySSTables, boolean verifyTokens, boolean invalidateCaches, boolean extendedVerify, boolean copyData, boolean failOnMissingIndex, boolean validateIndexChecksum) Load new sstables from the given directoryvoidcall when dropping or renaming a CF.voidinvalidate(boolean expectMBean) voidinvalidate(boolean expectMBean, boolean dropData) voidvoidintinvalidateCounterCache(Collection<Bounds<Token>> boundsToInvalidate) voidintinvalidateRowCache(Collection<Bounds<Token>> boundsToInvalidate) booleanbooleanbooleanbooleanbooleanisEmpty()booleanisFilterFullyCoveredBy(ClusteringIndexFilter filter, DataLimits limits, CachedPartition cached, long nowInSec, boolean enforceStrictLiveness) booleanisIndex()true if this CFS contains secondary index databooleanbooleanbooleanbooleanbooleanisValid()keySamples(Range<Token> range) voidDeprecated.See CASSANDRA-6719static voidloadNewSSTables(String ksName, String cfName) See #StorageService.importNewSSTablesfor more infolocalRangeSplits(int shardCount) Construct a list of boundaries that split the locally-owned ranges into the given number of shards, splitting the owned space evenly.voidmarkObsolete(Collection<SSTableReader> sstables, OperationType compactionType) booleanmetadata()static TableMetricsmetricsFor(TableId tableId) newSSTableDescriptor(File directory) newSSTableDescriptor(File directory, SSTableFormat<?, ?> format) newSSTableDescriptor(File directory, Version version) voidonPaxosRepairComplete(Collection<Range<Token>> ranges, Ballot highBallot) voidputCachedCounter(ByteBuffer partitionKey, Clustering<?> clustering, ColumnMetadata column, CellPath path, ClockAndCount clockAndCount) booleanrebuildOnFailedScrub(Throwable failure) CASSANDRA-5174 : For an index cfs we may be able to discard everything and just rebuild the index when a scrub fails.voidrebuildSecondaryIndex(String idxName) static voidrebuildSecondaryIndex(String ksName, String cfName, String... idxNames) releaseRepairData(Collection<TimeUUID> sessions, boolean force) promotes (or demotes) data attached to an incremental repair session that has either completed successfully, or failedvoidreload()relocateSSTables(int jobs) <V> VrunWithCompactionsDisabled(Callable<V> callable, com.google.common.base.Predicate<SSTableReader> sstablesPredicate, OperationType operationType, boolean interruptValidation, boolean interruptViews, boolean interruptIndexes) Runs callable with compactions paused and compactions including sstables matching sstablePredicate stopped<V> VrunWithCompactionsDisabled(Callable<V> callable, OperationType operationType, boolean interruptValidation, boolean interruptViews) scrub(boolean disableSnapshot, boolean alwaysFail, IScrubber.Options options, int jobs) scrub(boolean disableSnapshot, IScrubber.Options options, int jobs) static voidscrubDataDirectories(TableMetadata metadata) Removes unnecessary files from the cf directory at startup: these include temp files, orphans, zero-length files and compacted sstables.select(com.google.common.base.Function<View, Iterable<SSTableReader>> filter) selectAndReference(com.google.common.base.Function<View, Iterable<SSTableReader>> filter) voidsetCompactionParameters(Map<String, String> options) Sets the compaction parameters locally for this node Note that this will be set until an ALTER with compaction = {..} is executed or the node is restartedvoidsetCompactionParametersJson(String options) Sets the compaction parameters locally for this node Note that this will be set until an ALTER with compaction = {..} is executed or the node is restartedvoidsetCompactionThresholds(int minThreshold, int maxThreshold) Sets the maximum and maximum number of SSTables in queue before compaction kicks offvoidsetCompressionParameters(Map<String, String> opts) Set the compression parameters locally for this nodevoidsetCompressionParametersJson(String options) voidsetCrcCheckChance(double crcCheckChance) Set new crc check chancevoidsetMaximumCompactionThreshold(int maxCompactionThreshold) Sets the maximum number of sstables in queue before compaction kicks offvoidsetMinimumCompactionThreshold(int minCompactionThreshold) Sets the minimum number of sstables in queue before compaction kicks offvoidsetNeverPurgeTombstones(boolean value) booleanstatic voidshutdownExecutorsAndWait(long timeout, TimeUnit unit) static voidsignalFlushRequired(Memtable memtable, ColumnFamilyStore.FlushReason reason) Signal to the owner that a flush is required (e.g.Take a snap shot of this columnfamily store.snapshot(String snapshotName, boolean skipMemtable, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, Instant creationTime) Take a snap shot of this columnfamily store.snapshot(String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral, boolean skipMemtable) snapshot(String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral, boolean skipMemtable, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, Instant creationTime) snapshot(String snapshotName, DurationSpec.IntSecondsBound ttl) booleansnapshotExists(String snapshotName) snapshotWithoutMemtable(String snapshotName) snapshotWithoutMemtable(String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, Instant creationTime) snapshotWithoutMemtable(String snapshotName, Instant creationTime) sstablesRewrite(boolean skipIfCurrentVersion, long skipIfNewerThanTimestamp, boolean skipIfCompressionMatches, int jobs) Rewrites all SSTables according to specified parametersbooleanbooleanbooleanswitchMemtableIfCurrent(Memtable memtable, ColumnFamilyStore.FlushReason reason) Switches the memtable iff the live memtable is the one providedvoidsyncPaxosRepairHistory(PaxosRepairHistory sync, boolean flush) toString()longvoidvoidvoidunloadCf()voidverify(IVerifier.Options options) <T> TwithAllSSTables(OperationType operationType, com.google.common.base.Function<LifecycleTransaction, T> op) <T> List<T>withSSTablesForKey(String key, boolean hexFormat, com.google.common.base.Function<SSTableReader, T> mapper) voidwriteAndAddMemtableRanges(TimeUUID repairSessionID, Supplier<Collection<Range<PartitionPosition>>> rangesSupplier, Refs<SSTableReader> placeIntoRefs) boolean
-
Field Details
-
SNAPSHOT_TRUNCATE_PREFIX
- See Also:
-
SNAPSHOT_DROP_PREFIX
- See Also:
-
RING_VERSION_IRRELEVANT
public static final int RING_VERSION_IRRELEVANTSpecial values used when the local ranges are not changed with ring changes (e.g. local tables).- See Also:
-
keyspace
-
name
-
metadata
-
readOrdering
-
indexManager
-
viewManager
-
metric
-
sampleReadLatencyMicros
public volatile long sampleReadLatencyMicros -
additionalWriteLatencyMicros
public volatile long additionalWriteLatencyMicros -
topPartitions
-
-
Constructor Details
-
ColumnFamilyStore
public ColumnFamilyStore(Keyspace keyspace, String columnFamilyName, Supplier<? extends SSTableId> sstableIdGenerator, TableMetadataRef metadata, Directories directories, boolean loadSSTables, boolean registerBookeeping, boolean offline)
-
-
Method Details
-
shutdownPostFlushExecutor
- Throws:
InterruptedException
-
shutdownExecutorsAndWait
public static void shutdownExecutorsAndWait(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException - Throws:
InterruptedExceptionTimeoutException
-
reload
public void reload() -
getBackgroundCompactionTaskSubmitter
-
getCompactionParameters
- Specified by:
getCompactionParametersin interfaceColumnFamilyStoreMBean
-
getCompactionParametersJson
- Specified by:
getCompactionParametersJsonin interfaceColumnFamilyStoreMBean
-
setCompactionParameters
Description copied from interface:ColumnFamilyStoreMBeanSets the compaction parameters locally for this node Note that this will be set until an ALTER with compaction = {..} is executed or the node is restarted- Specified by:
setCompactionParametersin interfaceColumnFamilyStoreMBean- Parameters:
options- compaction options map
-
setCompactionParametersJson
Description copied from interface:ColumnFamilyStoreMBeanSets the compaction parameters locally for this node Note that this will be set until an ALTER with compaction = {..} is executed or the node is restarted- Specified by:
setCompactionParametersJsonin interfaceColumnFamilyStoreMBean- Parameters:
options- compaction options with the same syntax as when doing ALTER ... WITH compaction = {..}
-
getCompressionParameters
Description copied from interface:ColumnFamilyStoreMBeanGet the compression parameters- Specified by:
getCompressionParametersin interfaceColumnFamilyStoreMBean
-
getCompressionParametersJson
- Specified by:
getCompressionParametersJsonin interfaceColumnFamilyStoreMBean
-
setCompressionParameters
Description copied from interface:ColumnFamilyStoreMBeanSet the compression parameters locally for this node- Specified by:
setCompressionParametersin interfaceColumnFamilyStoreMBean- Parameters:
opts- map of string names to values
-
setCompressionParametersJson
- Specified by:
setCompressionParametersJsonin interfaceColumnFamilyStoreMBean
-
getTableMBeanName
-
getColumnFamilieMBeanName
-
updateSpeculationThreshold
public void updateSpeculationThreshold() -
getWriteHandler
-
getStreamManager
-
getRepairManager
-
metadata
-
getDirectories
-
getDataPaths
- Specified by:
getDataPathsin interfaceColumnFamilyStoreMBean- Throws:
IOException
-
writesShouldSkipCommitLog
public boolean writesShouldSkipCommitLog() -
memtableWritesAreDurable
public boolean memtableWritesAreDurable() -
streamToMemtable
public boolean streamToMemtable() -
streamFromMemtable
public boolean streamFromMemtable() -
createSSTableMultiWriter
public SSTableMultiWriter createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, TimeUUID pendingRepair, boolean isTransient, SerializationHeader header, LifecycleNewTracker lifecycleNewTracker) -
createSSTableMultiWriter
public SSTableMultiWriter createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, TimeUUID pendingRepair, boolean isTransient, IntervalSet<CommitLogPosition> commitLogPositions, SerializationHeader header, LifecycleNewTracker lifecycleNewTracker) -
createSSTableMultiWriter
public SSTableMultiWriter createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, TimeUUID pendingRepair, boolean isTransient, IntervalSet<CommitLogPosition> commitLogPositions, int sstableLevel, SerializationHeader header, LifecycleNewTracker lifecycleNewTracker) -
supportsEarlyOpen
public boolean supportsEarlyOpen() -
invalidate
public void invalidate()call when dropping or renaming a CF. Performs mbean housekeeping and invalidates CFS to other operations -
invalidate
public void invalidate(boolean expectMBean) -
invalidate
public void invalidate(boolean expectMBean, boolean dropData) -
createColumnFamilyStore
public static ColumnFamilyStore createColumnFamilyStore(Keyspace keyspace, TableMetadataRef metadata, boolean loadSSTables) -
createColumnFamilyStore
public static ColumnFamilyStore createColumnFamilyStore(Keyspace keyspace, String columnFamily, TableMetadataRef metadata, boolean loadSSTables) -
createColumnFamilyStore
public static ColumnFamilyStore createColumnFamilyStore(Keyspace keyspace, String columnFamily, TableMetadataRef metadata, Directories directories, boolean loadSSTables, boolean registerBookkeeping, boolean offline) This is only directly used by offline tools -
scrubDataDirectories
Removes unnecessary files from the cf directory at startup: these include temp files, orphans, zero-length files and compacted sstables. Files that cannot be recognized will be ignored.- Throws:
StartupException
-
loadNewSSTables
See #StorageService.importNewSSTablesfor more info- Parameters:
ksName- The keyspace namecfName- The columnFamily name
-
loadNewSSTables
Deprecated.See CASSANDRA-6719- Specified by:
loadNewSSTablesin interfaceColumnFamilyStoreMBean
-
importNewSSTables
public List<String> importNewSSTables(Set<String> srcPaths, boolean resetLevel, boolean clearRepaired, boolean verifySSTables, boolean verifyTokens, boolean invalidateCaches, boolean extendedVerify, boolean copyData) - Specified by:
importNewSSTablesin interfaceColumnFamilyStoreMBean
-
importNewSSTables
public List<String> importNewSSTables(Set<String> srcPaths, boolean resetLevel, boolean clearRepaired, boolean verifySSTables, boolean verifyTokens, boolean invalidateCaches, boolean extendedVerify) - Specified by:
importNewSSTablesin interfaceColumnFamilyStoreMBean
-
importNewSSTables
public List<String> importNewSSTables(Set<String> srcPaths, boolean resetLevel, boolean clearRepaired, boolean verifySSTables, boolean verifyTokens, boolean invalidateCaches, boolean extendedVerify, boolean copyData, boolean failOnMissingIndex, boolean validateIndexChecksum) Description copied from interface:ColumnFamilyStoreMBeanLoad new sstables from the given directory- Specified by:
importNewSSTablesin interfaceColumnFamilyStoreMBean- Parameters:
srcPaths- the path to the new sstables - if it is an empty set, the data directories will be scannedresetLevel- if the level should be reset to 0 on the new sstablesclearRepaired- if repaired info should be wiped from the new sstablesverifySSTables- if the new sstables should be verified that they are not corruptverifyTokens- if the tokens in the new sstables should be verified that they are owned by the current nodeinvalidateCaches- if row cache should be invalidated for the keys in the new sstablesextendedVerify- if we should run an extended verify checking all values in the new sstablescopyData- if we should copy data from source paths instead of moving themfailOnMissingIndex- if loading should fail when SSTables do not contain built SAI indexes toovalidateIndexChecksum- if we should also validate checksum for SAI indexes- Returns:
- list of failed import directories
-
rebuildSecondaryIndex
-
rebuildSecondaryIndex
-
createCompactionStrategyInstance
public AbstractCompactionStrategy createCompactionStrategyInstance(CompactionParams compactionParams) -
getColumnFamilyName
Deprecated.See CASSANDRA-9448- Specified by:
getColumnFamilyNamein interfaceColumnFamilyStoreMBean
-
getTableName
- Specified by:
getTableNamein interfaceColumnFamilyStoreMBean
-
getKeyspaceName
-
newSSTableDescriptor
-
newSSTableDescriptor
-
newSSTableDescriptor
-
switchMemtableIfCurrent
public Future<CommitLogPosition> switchMemtableIfCurrent(Memtable memtable, ColumnFamilyStore.FlushReason reason) Switches the memtable iff the live memtable is the one provided- Parameters:
memtable-
-
switchMemtable
-
forceFlush
Flush if there is unflushed data in the memtables- Returns:
- a Future yielding the commit log position that can be guaranteed to have been successfully written to sstables for this table once the future completes
-
forceFlush
Flush if there is unflushed data that was written to the CommitLog before @param flushIfDirtyBefore (inclusive).- Returns:
- a Future yielding the commit log position that can be guaranteed to have been successfully written to sstables for this table once the future completes
-
forceBlockingFlush
-
createMemtable
-
signalFlushRequired
public Future<CommitLogPosition> signalFlushRequired(Memtable memtable, ColumnFamilyStore.FlushReason reason) Description copied from interface:Memtable.OwnerSignal to the owner that a flush is required (e.g. in response to hitting space limits)- Specified by:
signalFlushRequiredin interfaceMemtable.Owner
-
getCurrentMemtable
Description copied from interface:Memtable.OwnerGet the current memtable for this owner. Used to avoid capturing memtable in scheduled flush tasks.- Specified by:
getCurrentMemtablein interfaceMemtable.Owner
-
activeMemtables
-
getIndexMemtables
Description copied from interface:Memtable.OwnerCollect the index memtables flushed together with this. Used to accurately calculate memory that would be freed by a flush.- Specified by:
getIndexMemtablesin interfaceMemtable.Owner
-
apply
Insert/Update the column family for this key. Caller is responsible for acquiring Keyspace.switchLock- Parameters:
update- to be appliedcontext- write context for current updateupdateIndexes- whether secondary indexes should be updated
-
localRangesWeighted
-
localRangeSplits
Description copied from interface:Memtable.OwnerConstruct a list of boundaries that split the locally-owned ranges into the given number of shards, splitting the owned space evenly. It is up to the memtable to use this information. Any changes in the ring structure (e.g. added or removed nodes) will invalidate the splits; in such a case the memtable will be sent aMemtable.shouldSwitch(org.apache.cassandra.db.ColumnFamilyStore.FlushReason)(OWNED_RANGES_CHANGE) and, should that return false, aMemtable.localRangesUpdated()call.- Specified by:
localRangeSplitsin interfaceMemtable.Owner
-
fullWeightedRange
public static ColumnFamilyStore.VersionedLocalRanges fullWeightedRange(long ringVersion, IPartitioner partitioner) -
getOverlappingLiveSSTables
- Parameters:
sstables-- Returns:
- sstables whose key range overlaps with that of the given sstables, not including itself. (The given sstables may or may not overlap with each other.)
-
getAndReferenceOverlappingLiveSSTables
like getOverlappingSSTables, but acquires references before returning -
addSSTable
-
addSSTables
-
getExpectedCompactedFileSize
Calculate expected file size of SSTable after compaction. If operation type isCLEANUPand we're not dealing with an index sstable, then we calculate expected file size with checking token range to be eliminated. Otherwise, we just add up all the files' size, which is the worst case file size for compaction of all the list of files given.- Parameters:
sstables- SSTables to calculate expected compacted file sizeoperation- Operation type- Returns:
- Expected file size of SSTable after compaction
-
getMaxSizeFile
-
forceCleanup
public CompactionManager.AllSSTableOpStatus forceCleanup(int jobs) throws ExecutionException, InterruptedException -
scrub
public CompactionManager.AllSSTableOpStatus scrub(boolean disableSnapshot, IScrubber.Options options, int jobs) throws ExecutionException, InterruptedException -
scrub
public CompactionManager.AllSSTableOpStatus scrub(boolean disableSnapshot, boolean alwaysFail, IScrubber.Options options, int jobs) throws ExecutionException, InterruptedException -
rebuildOnFailedScrub
CASSANDRA-5174 : For an index cfs we may be able to discard everything and just rebuild the index when a scrub fails.- Returns:
- true if we are an index cfs and we successfully rebuilt the index
-
verify
public CompactionManager.AllSSTableOpStatus verify(IVerifier.Options options) throws ExecutionException, InterruptedException -
sstablesRewrite
public CompactionManager.AllSSTableOpStatus sstablesRewrite(boolean skipIfCurrentVersion, long skipIfNewerThanTimestamp, boolean skipIfCompressionMatches, int jobs) throws ExecutionException, InterruptedException Rewrites all SSTables according to specified parameters- Parameters:
skipIfCurrentVersion- - if {@link true}, will rewrite only SSTables that have version older than the current one (SSTableFormat.getLatestVersion())skipIfNewerThanTimestamp- - max timestamp (local creation time) for SSTable; SSTables created _after_ this timestamp will be excluded from compactionskipIfCompressionMatches- - if {@link true}, will rewrite only SSTables whose compression parameters are different fromTableMetadata#params#getCompressionParameters()jobs- number of jobs for parallel execution- Throws:
ExecutionExceptionInterruptedException
-
relocateSSTables
public CompactionManager.AllSSTableOpStatus relocateSSTables(int jobs) throws ExecutionException, InterruptedException -
garbageCollect
public CompactionManager.AllSSTableOpStatus garbageCollect(CompactionParams.TombstoneOption tombstoneOption, int jobs) throws ExecutionException, InterruptedException -
markObsolete
-
isValid
public boolean isValid() -
getTracker
Package protected for access from the CompactionManager. -
getLiveSSTables
-
getSSTables
-
getUncompactingSSTables
-
getPendingRepairStats
-
releaseRepairData
promotes (or demotes) data attached to an incremental repair session that has either completed successfully, or failed- Returns:
- session ids whose data could not be released
-
isFilterFullyCoveredBy
public boolean isFilterFullyCoveredBy(ClusteringIndexFilter filter, DataLimits limits, CachedPartition cached, long nowInSec, boolean enforceStrictLiveness) -
getPaxosRepairHistory
-
getPaxosRepairHistoryForRanges
-
syncPaxosRepairHistory
-
onPaxosRepairComplete
-
getPaxosRepairLowBound
-
gcBefore
public long gcBefore(long nowInSec) -
selectAndReference
public ColumnFamilyStore.RefViewFragment selectAndReference(com.google.common.base.Function<View, Iterable<SSTableReader>> filter) -
select
public ColumnFamilyStore.ViewFragment select(com.google.common.base.Function<View, Iterable<SSTableReader>> filter) -
getSSTablesForKey
Description copied from interface:ColumnFamilyStoreMBeanReturns a list of filenames that contain the given key on this node- Specified by:
getSSTablesForKeyin interfaceColumnFamilyStoreMBean- Returns:
- list of filenames containing the key
-
getSSTablesForKey
Description copied from interface:ColumnFamilyStoreMBeanReturns a list of filenames that contain the given key on this node- Specified by:
getSSTablesForKeyin interfaceColumnFamilyStoreMBeanhexFormat- if key is in hex string format- Returns:
- list of filenames containing the key
-
getSSTablesForKeyWithLevel
Description copied from interface:ColumnFamilyStoreMBeanReturns a list of filenames that contain the given key and which level they belong to. Requires table to be compacted withLeveledCompactionStrategy- Specified by:
getSSTablesForKeyWithLevelin interfaceColumnFamilyStoreMBean- Returns:
- list of filenames and levels containing the key
-
withSSTablesForKey
public <T> List<T> withSSTablesForKey(String key, boolean hexFormat, com.google.common.base.Function<SSTableReader, T> mapper) -
beginLocalSampling
Description copied from interface:ColumnFamilyStoreMBeanbegin sampling for a specific sampler with a given capacity. The cardinality may be larger than the capacity, but depending on the use case it may affect its accuracy- Specified by:
beginLocalSamplingin interfaceColumnFamilyStoreMBean
-
finishLocalSampling
- Specified by:
finishLocalSamplingin interfaceColumnFamilyStoreMBean- Returns:
- top count items for the sampler since beginLocalSampling was called
- Throws:
OpenDataException
-
isCompactionDiskSpaceCheckEnabled
public boolean isCompactionDiskSpaceCheckEnabled()- Specified by:
isCompactionDiskSpaceCheckEnabledin interfaceColumnFamilyStoreMBean
-
compactionDiskSpaceCheck
public void compactionDiskSpaceCheck(boolean enable) - Specified by:
compactionDiskSpaceCheckin interfaceColumnFamilyStoreMBean
-
cleanupCache
public void cleanupCache() -
getComparator
-
snapshotWithoutMemtable
-
snapshotWithoutMemtable
-
snapshotWithoutMemtable
public TableSnapshot snapshotWithoutMemtable(String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, Instant creationTime) - Parameters:
ephemeral- If this flag is set to true, the snapshot will be cleaned during next startup
-
createSnapshot
protected TableSnapshot createSnapshot(String tag, boolean ephemeral, DurationSpec.IntSecondsBound ttl, Set<SSTableReader> sstables, Instant creationTime) -
clearEphemeralSnapshots
-
getSnapshotSSTableReaders
- Throws:
IOException
-
snapshot
Take a snap shot of this columnfamily store.- Parameters:
snapshotName- the name of the associated with the snapshot
-
snapshot
-
snapshot
public TableSnapshot snapshot(String snapshotName, boolean skipMemtable, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, Instant creationTime) Take a snap shot of this columnfamily store.- Parameters:
snapshotName- the name of the associated with the snapshotskipMemtable- Skip flushing the memtablettl- duration after which the taken snapshot is removed automatically, if supplied with null, it will never be automatically removedrateLimiter- Rate limiter for hardlinks-per-secondcreationTime- time when this snapshot was taken
-
snapshot
public TableSnapshot snapshot(String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral, boolean skipMemtable) - Parameters:
ephemeral- If this flag is set to true, the snapshot will be cleaned up during next startupskipMemtable- Skip flushing the memtable
-
snapshot
public TableSnapshot snapshot(String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral, boolean skipMemtable, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, Instant creationTime) - Parameters:
ephemeral- If this flag is set to true, the snapshot will be cleaned up during next startupskipMemtable- Skip flushing the memtablettl- duration after which the taken snapshot is removed automatically, if supplied with null, it will never be automatically removedrateLimiter- Rate limiter for hardlinks-per-secondcreationTime- time when this snapshot was taken
-
snapshotExists
-
clearSnapshot
Clear all the snapshots for a given column family.- Parameters:
snapshotName- the user supplied snapshot name. If left empty, all the snapshots will be cleaned.
-
listSnapshots
- Returns:
- Return a map of all snapshots to space being used The pair for a snapshot has true size and size on disk.
-
getRawCachedPartition
- Returns:
- the cached partition for @param key if it is already present in the cache. Not that this will not readAndCache the parition if it is not present, nor are these calls counted in cache statistics. Note that this WILL cause deserialization of a SerializingCache partition, so if all you need to know is whether a partition is present or not, use containsCachedParition instead.
-
invalidateRowCache
-
invalidateCounterCache
-
containsCachedParition
- Returns:
- true if @param key is contained in the row cache
-
invalidateCachedPartition
-
invalidateCachedPartition
-
getCachedCounter
public ClockAndCount getCachedCounter(ByteBuffer partitionKey, Clustering<?> clustering, ColumnMetadata column, CellPath path) -
putCachedCounter
public void putCachedCounter(ByteBuffer partitionKey, Clustering<?> clustering, ColumnMetadata column, CellPath path, ClockAndCount clockAndCount) -
forceMajorCompaction
public void forceMajorCompaction() -
forceMajorCompaction
public void forceMajorCompaction(boolean splitOutput) Description copied from interface:ColumnFamilyStoreMBeanforce a major compaction of this column family- Specified by:
forceMajorCompactionin interfaceColumnFamilyStoreMBean- Parameters:
splitOutput- true if the output of the major compaction should be split in several sstables
-
forceCompactionForTokenRange
public void forceCompactionForTokenRange(Collection<Range<Token>> tokenRanges) throws ExecutionException, InterruptedException Description copied from interface:ColumnFamilyStoreMBeanForces a major compaction of specified token ranges in this column family.The token ranges will be interpreted as closed intervals to match the closed interval defined by the first and last keys of a sstable, even though the
Rangeclass is suppossed to be half-open by definition.- Specified by:
forceCompactionForTokenRangein interfaceColumnFamilyStoreMBean- Parameters:
tokenRanges- The token ranges to be compacted, interpreted as closed intervals.- Throws:
ExecutionExceptionInterruptedException
-
forceCompactionForTokenRanges
Description copied from interface:ColumnFamilyStoreMBeanForces a major compaction of specified token ranges in this column family.The token ranges will be interpreted as closed intervals to match the closed interval defined by the first and last keys of a sstable, even though the
Rangeclass is suppossed to be half-open by definition.- Specified by:
forceCompactionForTokenRangesin interfaceColumnFamilyStoreMBean
-
forceCompactionForKey
-
forceCompactionKeysIgnoringGcGrace
-
shouldIgnoreGcGraceForKey
-
all
-
keySamples
-
estimatedKeysForRange
-
writeAndAddMemtableRanges
public void writeAndAddMemtableRanges(TimeUUID repairSessionID, Supplier<Collection<Range<PartitionPosition>>> rangesSupplier, Refs<SSTableReader> placeIntoRefs) -
clearUnsafe
public void clearUnsafe()For testing. No effort is made to clear historical or even the current memtables, nor for thread safety. All we do is wipe the sstable containers clean, while leaving the actual data files present on disk. (This allows tests to easily call loadNewSSTables on them.) -
truncateBlocking
public void truncateBlocking() -
truncateBlockingWithoutSnapshot
public void truncateBlockingWithoutSnapshot() -
dumpMemtable
Drops current memtable without flushing to disk. This should only be called when truncating a column family that cannot have dirty intervals in the commit log (i.e. one which is not durable, or where the memtable itself performs durable writes). -
unloadCf
public void unloadCf() -
runWithCompactionsDisabled
public <V> V runWithCompactionsDisabled(Callable<V> callable, OperationType operationType, boolean interruptValidation, boolean interruptViews) -
runWithCompactionsDisabled
public <V> V runWithCompactionsDisabled(Callable<V> callable, com.google.common.base.Predicate<SSTableReader> sstablesPredicate, OperationType operationType, boolean interruptValidation, boolean interruptViews, boolean interruptIndexes) Runs callable with compactions paused and compactions including sstables matching sstablePredicate stopped- Parameters:
callable- what to do when compactions are pausedsstablesPredicate- which sstables should we cancel compactions forinterruptValidation- if we should interrupt validation compactionsinterruptViews- if we should interrupt view compactionsinterruptIndexes- if we should interrupt compactions on indexes. NOTE: if you set this to true your sstablePredicate must be able to handle LocalPartitioner sstables!
-
withAllSSTables
public <T> T withAllSSTables(OperationType operationType, com.google.common.base.Function<LifecycleTransaction, T> op) -
toString
-
disableAutoCompaction
public void disableAutoCompaction() -
enableAutoCompaction
public void enableAutoCompaction() -
enableAutoCompaction
public void enableAutoCompaction(boolean waitForFutures) used for tests - to be able to check things after a minor compaction- Parameters:
waitForFutures- if we should block until autocompaction is done
-
isAutoCompactionDisabled
public boolean isAutoCompactionDisabled()- Specified by:
isAutoCompactionDisabledin interfaceColumnFamilyStoreMBean
-
getCompactionStrategyManager
-
setCrcCheckChance
public void setCrcCheckChance(double crcCheckChance) Description copied from interface:ColumnFamilyStoreMBeanSet new crc check chance- Specified by:
setCrcCheckChancein interfaceColumnFamilyStoreMBean
-
getCrcCheckChance
- Specified by:
getCrcCheckChancein interfaceSSTable.Owner
-
setCompactionThresholds
public void setCompactionThresholds(int minThreshold, int maxThreshold) Description copied from interface:ColumnFamilyStoreMBeanSets the maximum and maximum number of SSTables in queue before compaction kicks off- Specified by:
setCompactionThresholdsin interfaceColumnFamilyStoreMBean
-
getMinimumCompactionThreshold
public int getMinimumCompactionThreshold()Description copied from interface:ColumnFamilyStoreMBeanGets the minimum number of sstables in queue before compaction kicks off- Specified by:
getMinimumCompactionThresholdin interfaceColumnFamilyStoreMBean
-
setMinimumCompactionThreshold
public void setMinimumCompactionThreshold(int minCompactionThreshold) Description copied from interface:ColumnFamilyStoreMBeanSets the minimum number of sstables in queue before compaction kicks off- Specified by:
setMinimumCompactionThresholdin interfaceColumnFamilyStoreMBean
-
getMaximumCompactionThreshold
public int getMaximumCompactionThreshold()Description copied from interface:ColumnFamilyStoreMBeanGets the maximum number of sstables in queue before compaction kicks off- Specified by:
getMaximumCompactionThresholdin interfaceColumnFamilyStoreMBean
-
setMaximumCompactionThreshold
public void setMaximumCompactionThreshold(int maxCompactionThreshold) Description copied from interface:ColumnFamilyStoreMBeanSets the maximum number of sstables in queue before compaction kicks off- Specified by:
setMaximumCompactionThresholdin interfaceColumnFamilyStoreMBean
-
getMeanEstimatedCellPerPartitionCount
public int getMeanEstimatedCellPerPartitionCount() -
getMeanPartitionSize
public double getMeanPartitionSize() -
getMeanRowCount
public int getMeanRowCount() -
estimateKeys
public long estimateKeys()- Specified by:
estimateKeysin interfaceColumnFamilyStoreMBean
-
getPartitioner
-
decorateKey
-
isIndex
public boolean isIndex()true if this CFS contains secondary index data -
concatWithIndexes
-
getBuiltIndexes
Description copied from interface:ColumnFamilyStoreMBeanReturns a list of the names of the built column indexes for current store- Specified by:
getBuiltIndexesin interfaceColumnFamilyStoreMBean- Returns:
- list of the index names
-
getUnleveledSSTables
public int getUnleveledSSTables()- Specified by:
getUnleveledSSTablesin interfaceColumnFamilyStoreMBean- Returns:
- the number of SSTables in L0. Always return 0 if Leveled compaction is not enabled.
-
getSSTableCountPerLevel
public int[] getSSTableCountPerLevel()- Specified by:
getSSTableCountPerLevelin interfaceColumnFamilyStoreMBean- Returns:
- sstable count for each level. null unless leveled compaction is used. array index corresponds to level(int[0] is for level 0, ...).
-
getPerLevelSizeBytes
public long[] getPerLevelSizeBytes()- Specified by:
getPerLevelSizeBytesin interfaceColumnFamilyStoreMBean- Returns:
- total size on disk for each level. null unless leveled compaction is used. array index corresponds to level(int[0] is for level 0, ...).
-
isLeveledCompaction
public boolean isLeveledCompaction()- Specified by:
isLeveledCompactionin interfaceColumnFamilyStoreMBean- Returns:
- true if the table is using LeveledCompactionStrategy. false otherwise.
-
getSSTableCountPerTWCSBucket
public int[] getSSTableCountPerTWCSBucket()- Specified by:
getSSTableCountPerTWCSBucketin interfaceColumnFamilyStoreMBean- Returns:
- sstable count for each bucket in TWCS. null unless time window compaction is used. array index corresponds to bucket(int[0] is for most recent, ...).
-
getLevelFanoutSize
public int getLevelFanoutSize()- Specified by:
getLevelFanoutSizein interfaceColumnFamilyStoreMBean- Returns:
- sstable fanout size for level compaction strategy.
-
isEmpty
public boolean isEmpty() -
isRowCacheEnabled
public boolean isRowCacheEnabled() -
isCounterCacheEnabled
public boolean isCounterCacheEnabled() -
isKeyCacheEnabled
public boolean isKeyCacheEnabled() -
isAutoSnapshotEnabled
public boolean isAutoSnapshotEnabled() -
isTableIncrementalBackupsEnabled
public boolean isTableIncrementalBackupsEnabled() -
discardSSTables
public void discardSSTables(long truncatedAt) Discard all SSTables that were created before given timestamp. Caller should first ensure that comapctions have quiesced.- Parameters:
truncatedAt- The timestamp of the truncation (all SSTables before that timestamp are going be marked as compacted)
-
getDroppableTombstoneRatio
public double getDroppableTombstoneRatio()Description copied from interface:ColumnFamilyStoreMBeanGet the ratio of droppable tombstones to real columns (and non-droppable tombstones)- Specified by:
getDroppableTombstoneRatioin interfaceColumnFamilyStoreMBean- Returns:
- ratio
-
trueSnapshotsSize
public long trueSnapshotsSize()- Specified by:
trueSnapshotsSizein interfaceColumnFamilyStoreMBean- Returns:
- the size of SSTables in "snapshots" subdirectory which aren't live anymore
-
getIfExists
Returns a ColumnFamilyStore by id if it exists, null otherwise Differently from others, this method does not throw exception if the table does not exist. -
getIfExists
Returns a ColumnFamilyStore by metadata if it exists, null otherwise Differently from others, this method does not throw exception if the table does not exist. -
getIfExists
Returns a ColumnFamilyStore by ksname and cfname if it exists, null otherwise Differently from others, this method does not throw exception if the keyspace or table does not exist. -
metricsFor
-
getDirectoriesForFiles
Grabs the global first/last tokens among sstables and returns the range of data directories that start/end with those tokens. This is done to avoid grabbing the disk boundaries for every sstable in case of huge compactions. -
getDiskBoundaries
-
invalidateLocalRanges
public void invalidateLocalRanges() -
setNeverPurgeTombstones
public void setNeverPurgeTombstones(boolean value) - Specified by:
setNeverPurgeTombstonesin interfaceColumnFamilyStoreMBean
-
getNeverPurgeTombstones
public boolean getNeverPurgeTombstones()- Specified by:
getNeverPurgeTombstonesin interfaceColumnFamilyStoreMBean
-
hasMisplacedSSTables
public boolean hasMisplacedSSTables()Description copied from interface:ColumnFamilyStoreMBeanCheck SSTables whether or not they are misplaced.- Specified by:
hasMisplacedSSTablesin interfaceColumnFamilyStoreMBean- Returns:
- true if any of the SSTables is misplaced. If all SSTables are correctly placed or the partitioner does not support splitting, it returns false.
-
getMaxSSTableSize
public long getMaxSSTableSize()Description copied from interface:ColumnFamilyStoreMBeanReturns the size of the biggest SSTable of this table.- Specified by:
getMaxSSTableSizein interfaceColumnFamilyStoreMBean- Returns:
- (physical) size of the biggest SSTable of this table on disk or 0 if no SSTable is present
-
getMaxSSTableDuration
public long getMaxSSTableDuration()Description copied from interface:ColumnFamilyStoreMBeanReturns the longest duration of an SSTable, in milliseconds, of this table, computed asmaxTimestamp - minTimestamp. It returns 0 if there are no SSTables or ifmaxTimestamporminTimestampis equal toLong.MAX_VALUE. Effectively non-zero for tables onTimeWindowCompactionStrategy.- Specified by:
getMaxSSTableDurationin interfaceColumnFamilyStoreMBean- Returns:
- the biggest
maxTimestamp - minTimestampamong all SSTables of this table or 0 if no SSTable is present
-
getTopSizePartitions
- Specified by:
getTopSizePartitionsin interfaceColumnFamilyStoreMBean
-
getTopSizePartitionsLastUpdate
- Specified by:
getTopSizePartitionsLastUpdatein interfaceColumnFamilyStoreMBean
-
getTopTombstonePartitions
- Specified by:
getTopTombstonePartitionsin interfaceColumnFamilyStoreMBean
-
getTopTombstonePartitionsLastUpdate
- Specified by:
getTopTombstonePartitionsLastUpdatein interfaceColumnFamilyStoreMBean
-
newReadOrderingBarrier
- Specified by:
newReadOrderingBarrierin interfaceSSTable.Owner
-
getMetrics
- Specified by:
getMetricsin interfaceSSTable.Owner
-