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 java.lang.Object implements ColumnFamilyStoreMBean, Memtable.Owner, SSTable.Owner
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ColumnFamilyStore.FlushReason
Reason for initiating a memtable flush.static class
ColumnFamilyStore.RefViewFragment
static class
ColumnFamilyStore.VersionedLocalRanges
static class
ColumnFamilyStore.ViewFragment
-
Field Summary
Fields Modifier and Type Field Description long
additionalWriteLatencyMicros
SecondaryIndexManager
indexManager
Keyspace
keyspace
TableMetadataRef
metadata
TableMetrics
metric
java.lang.String
name
OpOrder
readOrdering
static int
RING_VERSION_IRRELEVANT
Special values used when the local ranges are not changed with ring changes (e.g.long
sampleReadLatencyMicros
static java.lang.String
SNAPSHOT_DROP_PREFIX
static java.lang.String
SNAPSHOT_TRUNCATE_PREFIX
TopPartitionTracker
topPartitions
TableViews
viewManager
-
Constructor Summary
Constructors Constructor Description ColumnFamilyStore(Keyspace keyspace, java.lang.String columnFamilyName, java.util.function.Supplier<? extends SSTableId> sstableIdGenerator, TableMetadataRef metadata, Directories directories, boolean loadSSTables, boolean registerBookeeping, boolean offline)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.Iterable<Memtable>
activeMemtables()
void
addSSTable(SSTableReader sstable)
void
addSSTables(java.util.Collection<SSTableReader> sstables)
static java.lang.Iterable<ColumnFamilyStore>
all()
void
apply(PartitionUpdate update, CassandraWriteContext context, boolean updateIndexes)
Insert/Update the column family for this key.void
beginLocalSampling(java.lang.String sampler, int capacity, int durationMillis)
begin sampling for a specific sampler with a given capacity.void
cleanupCache()
protected static void
clearEphemeralSnapshots(Directories directories)
void
clearSnapshot(java.lang.String snapshotName)
Clear all the snapshots for a given column family.void
clearUnsafe()
For testing.void
compactionDiskSpaceCheck(boolean enable)
java.lang.Iterable<ColumnFamilyStore>
concatWithIndexes()
boolean
containsCachedParition(DecoratedKey key)
static ColumnFamilyStore
createColumnFamilyStore(Keyspace keyspace, java.lang.String columnFamily, TableMetadataRef metadata, boolean loadSSTables)
static ColumnFamilyStore
createColumnFamilyStore(Keyspace keyspace, java.lang.String columnFamily, TableMetadataRef metadata, Directories directories, boolean loadSSTables, boolean registerBookkeeping, boolean offline)
This is only directly used by offline toolsstatic ColumnFamilyStore
createColumnFamilyStore(Keyspace keyspace, TableMetadataRef metadata, boolean loadSSTables)
AbstractCompactionStrategy
createCompactionStrategyInstance(CompactionParams compactionParams)
Memtable
createMemtable(java.util.concurrent.atomic.AtomicReference<CommitLogPosition> commitLogUpperBound)
protected TableSnapshot
createSnapshot(java.lang.String tag, boolean ephemeral, DurationSpec.IntSecondsBound ttl, java.util.Set<SSTableReader> sstables, java.time.Instant creationTime)
SSTableMultiWriter
createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, TimeUUID pendingRepair, boolean isTransient, IntervalSet<CommitLogPosition> commitLogPositions, int sstableLevel, SerializationHeader header, LifecycleNewTracker lifecycleNewTracker)
SSTableMultiWriter
createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, TimeUUID pendingRepair, boolean isTransient, IntervalSet<CommitLogPosition> commitLogPositions, SerializationHeader header, LifecycleNewTracker lifecycleNewTracker)
SSTableMultiWriter
createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, TimeUUID pendingRepair, boolean isTransient, SerializationHeader header, LifecycleNewTracker lifecycleNewTracker)
DecoratedKey
decorateKey(java.nio.ByteBuffer key)
void
disableAutoCompaction()
void
discardSSTables(long truncatedAt)
Discard all SSTables that were created before given timestamp.Future<CommitLogPosition>
dumpMemtable()
Drops current memtable without flushing to disk.void
enableAutoCompaction()
void
enableAutoCompaction(boolean waitForFutures)
used for tests - to be able to check things after a minor compactionlong
estimatedKeysForRange(Range<Token> range)
long
estimateKeys()
java.util.List<javax.management.openmbean.CompositeData>
finishLocalSampling(java.lang.String sampler, int count)
CommitLogPosition
forceBlockingFlush(ColumnFamilyStore.FlushReason reason)
CompactionManager.AllSSTableOpStatus
forceCleanup(int jobs)
void
forceCompactionForKey(DecoratedKey key)
void
forceCompactionForTokenRange(java.util.Collection<Range<Token>> tokenRanges)
Forces a major compaction of specified token ranges in this column family.void
forceCompactionForTokenRanges(java.lang.String... strings)
Forces a major compaction of specified token ranges in this column family.void
forceCompactionKeysIgnoringGcGrace(java.lang.String... partitionKeysIgnoreGcGrace)
Future<CommitLogPosition>
forceFlush(ColumnFamilyStore.FlushReason reason)
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).void
forceMajorCompaction()
void
forceMajorCompaction(boolean splitOutput)
force a major compaction of this column familystatic ColumnFamilyStore.VersionedLocalRanges
fullWeightedRange(long ringVersion, IPartitioner partitioner)
CompactionManager.AllSSTableOpStatus
garbageCollect(CompactionParams.TombstoneOption tombstoneOption, int jobs)
long
gcBefore(long nowInSec)
Refs<SSTableReader>
getAndReferenceOverlappingLiveSSTables(java.lang.Iterable<SSTableReader> sstables)
like getOverlappingSSTables, but acquires references before returningstatic java.lang.Runnable
getBackgroundCompactionTaskSubmitter()
java.util.List<java.lang.String>
getBuiltIndexes()
Returns a list of the names of the built column indexes for current storeClockAndCount
getCachedCounter(java.nio.ByteBuffer partitionKey, Clustering<?> clustering, ColumnMetadata column, CellPath path)
static java.lang.String
getColumnFamilieMBeanName(java.lang.String ks, java.lang.String name, boolean isIndex)
java.lang.String
getColumnFamilyName()
Deprecated.java.util.Map<java.lang.String,java.lang.String>
getCompactionParameters()
java.lang.String
getCompactionParametersJson()
CompactionStrategyManager
getCompactionStrategyManager()
ClusteringComparator
getComparator()
java.util.Map<java.lang.String,java.lang.String>
getCompressionParameters()
Get the compression parametersjava.lang.String
getCompressionParametersJson()
java.lang.Double
getCrcCheckChance()
Memtable
getCurrentMemtable()
Get the current memtable for this owner.java.util.List<java.lang.String>
getDataPaths()
Directories
getDirectories()
java.util.List<File>
getDirectoriesForFiles(java.util.Set<SSTableReader> sstables)
Grabs the global first/last tokens among sstables and returns the range of data directories that start/end with those tokens.DiskBoundaries
getDiskBoundaries()
double
getDroppableTombstoneRatio()
Get the ratio of droppable tombstones to real columns (and non-droppable tombstones)long
getExpectedCompactedFileSize(java.lang.Iterable<SSTableReader> sstables, OperationType operation)
Calculate expected file size of SSTable after compaction.static ColumnFamilyStore
getIfExists(java.lang.String ksName, java.lang.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 ColumnFamilyStore
getIfExists(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.java.lang.Iterable<Memtable>
getIndexMemtables()
Collect the index memtables flushed together with this.java.lang.String
getKeyspaceName()
int
getLevelFanoutSize()
java.util.Set<SSTableReader>
getLiveSSTables()
int
getMaximumCompactionThreshold()
Gets the maximum number of sstables in queue before compaction kicks offSSTableReader
getMaxSizeFile(java.lang.Iterable<SSTableReader> sstables)
long
getMaxSSTableDuration()
Returns the longest duration of an SSTable, in milliseconds, of this table, computed asmaxTimestamp - minTimestamp
.long
getMaxSSTableSize()
Returns the size of the biggest SSTable of this table.int
getMeanEstimatedCellPerPartitionCount()
double
getMeanPartitionSize()
int
getMeanRowCount()
TableMetrics
getMetrics()
int
getMinimumCompactionThreshold()
Gets the minimum number of sstables in queue before compaction kicks offboolean
getNeverPurgeTombstones()
java.util.Collection<SSTableReader>
getOverlappingLiveSSTables(java.lang.Iterable<SSTableReader> sstables)
IPartitioner
getPartitioner()
PaxosRepairHistory
getPaxosRepairHistory()
PaxosRepairHistory
getPaxosRepairHistoryForRanges(java.util.Collection<Range<Token>> ranges)
Ballot
getPaxosRepairLowBound(DecoratedKey key)
java.util.Map<TimeUUID,PendingStat>
getPendingRepairStats()
long[]
getPerLevelSizeBytes()
CachedPartition
getRawCachedPartition(DecoratedKey key)
TableRepairManager
getRepairManager()
Refs<SSTableReader>
getSnapshotSSTableReaders(java.lang.String tag)
int[]
getSSTableCountPerLevel()
int[]
getSSTableCountPerTWCSBucket()
java.lang.Iterable<SSTableReader>
getSSTables(SSTableSet sstableSet)
java.util.List<java.lang.String>
getSSTablesForKey(java.lang.String key)
Returns a list of filenames that contain the given key on this nodejava.util.List<java.lang.String>
getSSTablesForKey(java.lang.String key, boolean hexFormat)
Returns a list of filenames that contain the given key on this nodejava.util.Map<java.lang.Integer,java.util.Set<java.lang.String>>
getSSTablesForKeyWithLevel(java.lang.String key, boolean hexFormat)
Returns a list of filenames that contain the given key and which level they belong to.TableStreamManager
getStreamManager()
static java.lang.String
getTableMBeanName(java.lang.String ks, java.lang.String name, boolean isIndex)
java.lang.String
getTableName()
java.util.Map<java.lang.String,java.lang.Long>
getTopSizePartitions()
java.lang.Long
getTopSizePartitionsLastUpdate()
java.util.Map<java.lang.String,java.lang.Long>
getTopTombstonePartitions()
java.lang.Long
getTopTombstonePartitionsLastUpdate()
Tracker
getTracker()
Package protected for access from the CompactionManager.java.lang.Iterable<SSTableReader>
getUncompactingSSTables()
int
getUnleveledSSTables()
TableWriteHandler
getWriteHandler()
boolean
hasMisplacedSSTables()
Check SSTables whether or not they are misplaced.java.util.List<java.lang.String>
importNewSSTables(java.util.Set<java.lang.String> srcPaths, boolean resetLevel, boolean clearRepaired, boolean verifySSTables, boolean verifyTokens, boolean invalidateCaches, boolean extendedVerify)
Load new sstables from the given directoryjava.util.List<java.lang.String>
importNewSSTables(java.util.Set<java.lang.String> srcPaths, boolean resetLevel, boolean clearRepaired, boolean verifySSTables, boolean verifyTokens, boolean invalidateCaches, boolean extendedVerify, boolean copyData)
#Load new sstables from the given directoryvoid
invalidate()
call when dropping or renaming a CF.void
invalidate(boolean expectMBean)
void
invalidate(boolean expectMBean, boolean dropData)
void
invalidateCachedPartition(RowCacheKey key)
void
invalidateCachedPartition(DecoratedKey key)
int
invalidateCounterCache(java.util.Collection<Bounds<Token>> boundsToInvalidate)
void
invalidateLocalRanges()
int
invalidateRowCache(java.util.Collection<Bounds<Token>> boundsToInvalidate)
boolean
isAutoCompactionDisabled()
boolean
isAutoSnapshotEnabled()
boolean
isCompactionDiskSpaceCheckEnabled()
boolean
isCounterCacheEnabled()
boolean
isEmpty()
boolean
isFilterFullyCoveredBy(ClusteringIndexFilter filter, DataLimits limits, CachedPartition cached, long nowInSec, boolean enforceStrictLiveness)
boolean
isIndex()
true if this CFS contains secondary index databoolean
isKeyCacheEnabled()
boolean
isLeveledCompaction()
boolean
isRowCacheEnabled()
boolean
isTableIncrementalBackupsEnabled()
boolean
isValid()
java.lang.Iterable<DecoratedKey>
keySamples(Range<Token> range)
java.util.Map<java.lang.String,TableSnapshot>
listSnapshots()
void
loadNewSSTables()
Deprecated.static void
loadNewSSTables(java.lang.String ksName, java.lang.String cfName)
See #StorageService.importNewSSTables
for more infoShardBoundaries
localRangeSplits(int shardCount)
Construct a list of boundaries that split the locally-owned ranges into the given number of shards, splitting the owned space evenly.ColumnFamilyStore.VersionedLocalRanges
localRangesWeighted()
void
markObsolete(java.util.Collection<SSTableReader> sstables, OperationType compactionType)
boolean
memtableWritesAreDurable()
TableMetadata
metadata()
static TableMetrics
metricsFor(TableId tableId)
OpOrder.Barrier
newReadOrderingBarrier()
Descriptor
newSSTableDescriptor(File directory)
Descriptor
newSSTableDescriptor(File directory, SSTableFormat<?,?> format)
Descriptor
newSSTableDescriptor(File directory, Version version)
void
onPaxosRepairComplete(java.util.Collection<Range<Token>> ranges, Ballot highBallot)
void
putCachedCounter(java.nio.ByteBuffer partitionKey, Clustering<?> clustering, ColumnMetadata column, CellPath path, ClockAndCount clockAndCount)
boolean
rebuildOnFailedScrub(java.lang.Throwable failure)
CASSANDRA-5174 : For an index cfs we may be able to discard everything and just rebuild the index when a scrub fails.void
rebuildSecondaryIndex(java.lang.String idxName)
static void
rebuildSecondaryIndex(java.lang.String ksName, java.lang.String cfName, java.lang.String... idxNames)
CleanupSummary
releaseRepairData(java.util.Collection<TimeUUID> sessions, boolean force)
promotes (or demotes) data attached to an incremental repair session that has either completed successfully, or failedvoid
reload()
CompactionManager.AllSSTableOpStatus
relocateSSTables(int jobs)
<V> V
runWithCompactionsDisabled(java.util.concurrent.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> V
runWithCompactionsDisabled(java.util.concurrent.Callable<V> callable, OperationType operationType, boolean interruptValidation, boolean interruptViews)
CompactionManager.AllSSTableOpStatus
scrub(boolean disableSnapshot, boolean alwaysFail, IScrubber.Options options, int jobs)
CompactionManager.AllSSTableOpStatus
scrub(boolean disableSnapshot, IScrubber.Options options, int jobs)
static void
scrubDataDirectories(TableMetadata metadata)
Removes unnecessary files from the cf directory at startup: these include temp files, orphans, zero-length files and compacted sstables.ColumnFamilyStore.ViewFragment
select(com.google.common.base.Function<View,java.lang.Iterable<SSTableReader>> filter)
ColumnFamilyStore.RefViewFragment
selectAndReference(com.google.common.base.Function<View,java.lang.Iterable<SSTableReader>> filter)
void
setCompactionParameters(java.util.Map<java.lang.String,java.lang.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 restartedvoid
setCompactionParametersJson(java.lang.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 restartedvoid
setCompactionThresholds(int minThreshold, int maxThreshold)
Sets the maximum and maximum number of SSTables in queue before compaction kicks offvoid
setCompressionParameters(java.util.Map<java.lang.String,java.lang.String> opts)
Set the compression parameters locally for this nodevoid
setCompressionParametersJson(java.lang.String options)
void
setCrcCheckChance(double crcCheckChance)
Set new crc check chancevoid
setMaximumCompactionThreshold(int maxCompactionThreshold)
Sets the maximum number of sstables in queue before compaction kicks offvoid
setMinimumCompactionThreshold(int minCompactionThreshold)
Sets the minimum number of sstables in queue before compaction kicks offvoid
setNeverPurgeTombstones(boolean value)
boolean
shouldIgnoreGcGraceForKey(DecoratedKey dk)
static void
shutdownExecutorsAndWait(long timeout, java.util.concurrent.TimeUnit unit)
static void
shutdownPostFlushExecutor()
Future<CommitLogPosition>
signalFlushRequired(Memtable memtable, ColumnFamilyStore.FlushReason reason)
Signal to the owner that a flush is required (e.g.TableSnapshot
snapshot(java.lang.String snapshotName)
Take a snap shot of this columnfamily store.TableSnapshot
snapshot(java.lang.String snapshotName, boolean skipMemtable, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, java.time.Instant creationTime)
Take a snap shot of this columnfamily store.TableSnapshot
snapshot(java.lang.String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral, boolean skipMemtable)
TableSnapshot
snapshot(java.lang.String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral, boolean skipMemtable, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, java.time.Instant creationTime)
TableSnapshot
snapshot(java.lang.String snapshotName, DurationSpec.IntSecondsBound ttl)
boolean
snapshotExists(java.lang.String snapshotName)
TableSnapshot
snapshotWithoutMemtable(java.lang.String snapshotName)
TableSnapshot
snapshotWithoutMemtable(java.lang.String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, java.time.Instant creationTime)
TableSnapshot
snapshotWithoutMemtable(java.lang.String snapshotName, java.time.Instant creationTime)
CompactionManager.AllSSTableOpStatus
sstablesRewrite(boolean skipIfCurrentVersion, long skipIfNewerThanTimestamp, boolean skipIfCompressionMatches, int jobs)
Rewrites all SSTables according to specified parametersboolean
streamFromMemtable()
boolean
streamToMemtable()
boolean
supportsEarlyOpen()
Future<CommitLogPosition>
switchMemtable(ColumnFamilyStore.FlushReason reason)
Future<CommitLogPosition>
switchMemtableIfCurrent(Memtable memtable, ColumnFamilyStore.FlushReason reason)
Switches the memtable iff the live memtable is the one providedvoid
syncPaxosRepairHistory(PaxosRepairHistory sync, boolean flush)
java.lang.String
toString()
long
trueSnapshotsSize()
void
truncateBlocking()
void
truncateBlockingWithoutSnapshot()
void
unloadCf()
void
updateSpeculationThreshold()
CompactionManager.AllSSTableOpStatus
verify(IVerifier.Options options)
<T> T
withAllSSTables(OperationType operationType, com.google.common.base.Function<LifecycleTransaction,T> op)
<T> java.util.List<T>
withSSTablesForKey(java.lang.String key, boolean hexFormat, com.google.common.base.Function<SSTableReader,T> mapper)
void
writeAndAddMemtableRanges(TimeUUID repairSessionID, java.util.function.Supplier<java.util.Collection<Range<PartitionPosition>>> rangesSupplier, Refs<SSTableReader> placeIntoRefs)
boolean
writesShouldSkipCommitLog()
-
-
-
Field Detail
-
SNAPSHOT_TRUNCATE_PREFIX
public static final java.lang.String SNAPSHOT_TRUNCATE_PREFIX
- See Also:
- Constant Field Values
-
SNAPSHOT_DROP_PREFIX
public static final java.lang.String SNAPSHOT_DROP_PREFIX
- See Also:
- Constant Field Values
-
RING_VERSION_IRRELEVANT
public static final int RING_VERSION_IRRELEVANT
Special values used when the local ranges are not changed with ring changes (e.g. local tables).- See Also:
- Constant Field Values
-
keyspace
public final Keyspace keyspace
-
name
public final java.lang.String name
-
metadata
public final TableMetadataRef metadata
-
readOrdering
public final OpOrder readOrdering
-
indexManager
public final SecondaryIndexManager indexManager
-
viewManager
public final TableViews viewManager
-
metric
public final TableMetrics metric
-
sampleReadLatencyMicros
public volatile long sampleReadLatencyMicros
-
additionalWriteLatencyMicros
public volatile long additionalWriteLatencyMicros
-
topPartitions
public final TopPartitionTracker topPartitions
-
-
Constructor Detail
-
ColumnFamilyStore
public ColumnFamilyStore(Keyspace keyspace, java.lang.String columnFamilyName, java.util.function.Supplier<? extends SSTableId> sstableIdGenerator, TableMetadataRef metadata, Directories directories, boolean loadSSTables, boolean registerBookeeping, boolean offline)
-
-
Method Detail
-
shutdownPostFlushExecutor
public static void shutdownPostFlushExecutor() throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
shutdownExecutorsAndWait
public static void shutdownExecutorsAndWait(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Throws:
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
reload
public void reload()
-
getBackgroundCompactionTaskSubmitter
public static java.lang.Runnable getBackgroundCompactionTaskSubmitter()
-
getCompactionParameters
public java.util.Map<java.lang.String,java.lang.String> getCompactionParameters()
- Specified by:
getCompactionParameters
in interfaceColumnFamilyStoreMBean
-
getCompactionParametersJson
public java.lang.String getCompactionParametersJson()
- Specified by:
getCompactionParametersJson
in interfaceColumnFamilyStoreMBean
-
setCompactionParameters
public void setCompactionParameters(java.util.Map<java.lang.String,java.lang.String> options)
Description copied from interface:ColumnFamilyStoreMBean
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 restarted- Specified by:
setCompactionParameters
in interfaceColumnFamilyStoreMBean
- Parameters:
options
- compaction options map
-
setCompactionParametersJson
public void setCompactionParametersJson(java.lang.String options)
Description copied from interface:ColumnFamilyStoreMBean
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 restarted- Specified by:
setCompactionParametersJson
in interfaceColumnFamilyStoreMBean
- Parameters:
options
- compaction options with the same syntax as when doing ALTER ... WITH compaction = {..}
-
getCompressionParameters
public java.util.Map<java.lang.String,java.lang.String> getCompressionParameters()
Description copied from interface:ColumnFamilyStoreMBean
Get the compression parameters- Specified by:
getCompressionParameters
in interfaceColumnFamilyStoreMBean
-
getCompressionParametersJson
public java.lang.String getCompressionParametersJson()
- Specified by:
getCompressionParametersJson
in interfaceColumnFamilyStoreMBean
-
setCompressionParameters
public void setCompressionParameters(java.util.Map<java.lang.String,java.lang.String> opts)
Description copied from interface:ColumnFamilyStoreMBean
Set the compression parameters locally for this node- Specified by:
setCompressionParameters
in interfaceColumnFamilyStoreMBean
- Parameters:
opts
- map of string names to values
-
setCompressionParametersJson
public void setCompressionParametersJson(java.lang.String options)
- Specified by:
setCompressionParametersJson
in interfaceColumnFamilyStoreMBean
-
getTableMBeanName
public static java.lang.String getTableMBeanName(java.lang.String ks, java.lang.String name, boolean isIndex)
-
getColumnFamilieMBeanName
public static java.lang.String getColumnFamilieMBeanName(java.lang.String ks, java.lang.String name, boolean isIndex)
-
updateSpeculationThreshold
public void updateSpeculationThreshold()
-
getWriteHandler
public TableWriteHandler getWriteHandler()
-
getStreamManager
public TableStreamManager getStreamManager()
-
getRepairManager
public TableRepairManager getRepairManager()
-
metadata
public TableMetadata metadata()
-
getDirectories
public Directories getDirectories()
-
getDataPaths
public java.util.List<java.lang.String> getDataPaths() throws java.io.IOException
- Specified by:
getDataPaths
in interfaceColumnFamilyStoreMBean
- Throws:
java.io.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, java.lang.String columnFamily, TableMetadataRef metadata, boolean loadSSTables)
-
createColumnFamilyStore
public static ColumnFamilyStore createColumnFamilyStore(Keyspace keyspace, java.lang.String columnFamily, TableMetadataRef metadata, Directories directories, boolean loadSSTables, boolean registerBookkeeping, boolean offline)
This is only directly used by offline tools
-
scrubDataDirectories
public static void scrubDataDirectories(TableMetadata metadata) throws StartupException
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
public static void loadNewSSTables(java.lang.String ksName, java.lang.String cfName)
See #StorageService.importNewSSTables
for more info- Parameters:
ksName
- The keyspace namecfName
- The columnFamily name
-
loadNewSSTables
@Deprecated public void loadNewSSTables()
Deprecated.- Specified by:
loadNewSSTables
in interfaceColumnFamilyStoreMBean
-
importNewSSTables
public java.util.List<java.lang.String> importNewSSTables(java.util.Set<java.lang.String> srcPaths, boolean resetLevel, boolean clearRepaired, boolean verifySSTables, boolean verifyTokens, boolean invalidateCaches, boolean extendedVerify, boolean copyData)
#Load new sstables from the given directory- Specified by:
importNewSSTables
in 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 them- Returns:
- list of failed import directories
-
importNewSSTables
public java.util.List<java.lang.String> importNewSSTables(java.util.Set<java.lang.String> srcPaths, boolean resetLevel, boolean clearRepaired, boolean verifySSTables, boolean verifyTokens, boolean invalidateCaches, boolean extendedVerify)
Description copied from interface:ColumnFamilyStoreMBean
Load new sstables from the given directory- Specified by:
importNewSSTables
in 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 sstables- Returns:
- list of failed import directories
-
rebuildSecondaryIndex
public void rebuildSecondaryIndex(java.lang.String idxName)
-
rebuildSecondaryIndex
public static void rebuildSecondaryIndex(java.lang.String ksName, java.lang.String cfName, java.lang.String... idxNames)
-
createCompactionStrategyInstance
public AbstractCompactionStrategy createCompactionStrategyInstance(CompactionParams compactionParams)
-
getColumnFamilyName
@Deprecated public java.lang.String getColumnFamilyName()
Deprecated.- Specified by:
getColumnFamilyName
in interfaceColumnFamilyStoreMBean
- Returns:
- the name of the column family
-
getTableName
public java.lang.String getTableName()
- Specified by:
getTableName
in interfaceColumnFamilyStoreMBean
-
getKeyspaceName
public java.lang.String getKeyspaceName()
-
newSSTableDescriptor
public Descriptor newSSTableDescriptor(File directory)
-
newSSTableDescriptor
public Descriptor newSSTableDescriptor(File directory, SSTableFormat<?,?> format)
-
newSSTableDescriptor
public Descriptor newSSTableDescriptor(File directory, Version version)
-
switchMemtableIfCurrent
public Future<CommitLogPosition> switchMemtableIfCurrent(Memtable memtable, ColumnFamilyStore.FlushReason reason)
Switches the memtable iff the live memtable is the one provided- Parameters:
memtable
-
-
switchMemtable
public Future<CommitLogPosition> switchMemtable(ColumnFamilyStore.FlushReason reason)
-
forceFlush
public Future<CommitLogPosition> forceFlush(ColumnFamilyStore.FlushReason reason)
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
public Future<?> forceFlush(CommitLogPosition flushIfDirtyBefore)
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
public CommitLogPosition forceBlockingFlush(ColumnFamilyStore.FlushReason reason)
-
createMemtable
public Memtable createMemtable(java.util.concurrent.atomic.AtomicReference<CommitLogPosition> commitLogUpperBound)
-
signalFlushRequired
public Future<CommitLogPosition> signalFlushRequired(Memtable memtable, ColumnFamilyStore.FlushReason reason)
Description copied from interface:Memtable.Owner
Signal to the owner that a flush is required (e.g. in response to hitting space limits)- Specified by:
signalFlushRequired
in interfaceMemtable.Owner
-
getCurrentMemtable
public Memtable getCurrentMemtable()
Description copied from interface:Memtable.Owner
Get the current memtable for this owner. Used to avoid capturing memtable in scheduled flush tasks.- Specified by:
getCurrentMemtable
in interfaceMemtable.Owner
-
activeMemtables
public static java.lang.Iterable<Memtable> activeMemtables()
-
getIndexMemtables
public java.lang.Iterable<Memtable> getIndexMemtables()
Description copied from interface:Memtable.Owner
Collect the index memtables flushed together with this. Used to accurately calculate memory that would be freed by a flush.- Specified by:
getIndexMemtables
in interfaceMemtable.Owner
-
apply
public void apply(PartitionUpdate update, CassandraWriteContext context, boolean updateIndexes)
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
public ColumnFamilyStore.VersionedLocalRanges localRangesWeighted()
-
localRangeSplits
public ShardBoundaries localRangeSplits(int shardCount)
Description copied from interface:Memtable.Owner
Construct 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:
localRangeSplits
in interfaceMemtable.Owner
-
fullWeightedRange
public static ColumnFamilyStore.VersionedLocalRanges fullWeightedRange(long ringVersion, IPartitioner partitioner)
-
getOverlappingLiveSSTables
public java.util.Collection<SSTableReader> getOverlappingLiveSSTables(java.lang.Iterable<SSTableReader> sstables)
- 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
public Refs<SSTableReader> getAndReferenceOverlappingLiveSSTables(java.lang.Iterable<SSTableReader> sstables)
like getOverlappingSSTables, but acquires references before returning
-
addSSTable
public void addSSTable(SSTableReader sstable)
-
addSSTables
public void addSSTables(java.util.Collection<SSTableReader> sstables)
-
getExpectedCompactedFileSize
public long getExpectedCompactedFileSize(java.lang.Iterable<SSTableReader> sstables, OperationType operation)
Calculate expected file size of SSTable after compaction. If operation type isCLEANUP
and 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
public SSTableReader getMaxSizeFile(java.lang.Iterable<SSTableReader> sstables)
-
forceCleanup
public CompactionManager.AllSSTableOpStatus forceCleanup(int jobs) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
-
scrub
public CompactionManager.AllSSTableOpStatus scrub(boolean disableSnapshot, IScrubber.Options options, int jobs) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
-
scrub
public CompactionManager.AllSSTableOpStatus scrub(boolean disableSnapshot, boolean alwaysFail, IScrubber.Options options, int jobs) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
-
rebuildOnFailedScrub
public boolean rebuildOnFailedScrub(java.lang.Throwable failure)
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 java.util.concurrent.ExecutionException, java.lang.InterruptedException
- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
-
sstablesRewrite
public CompactionManager.AllSSTableOpStatus sstablesRewrite(boolean skipIfCurrentVersion, long skipIfNewerThanTimestamp, boolean skipIfCompressionMatches, int jobs) throws java.util.concurrent.ExecutionException, java.lang.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 from {@link TableMetadata#params#getCompressionParameters()} ()}jobs
- number of jobs for parallel execution- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
-
relocateSSTables
public CompactionManager.AllSSTableOpStatus relocateSSTables(int jobs) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
-
garbageCollect
public CompactionManager.AllSSTableOpStatus garbageCollect(CompactionParams.TombstoneOption tombstoneOption, int jobs) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
-
markObsolete
public void markObsolete(java.util.Collection<SSTableReader> sstables, OperationType compactionType)
-
isValid
public boolean isValid()
-
getTracker
public Tracker getTracker()
Package protected for access from the CompactionManager.
-
getLiveSSTables
public java.util.Set<SSTableReader> getLiveSSTables()
-
getSSTables
public java.lang.Iterable<SSTableReader> getSSTables(SSTableSet sstableSet)
-
getUncompactingSSTables
public java.lang.Iterable<SSTableReader> getUncompactingSSTables()
-
getPendingRepairStats
public java.util.Map<TimeUUID,PendingStat> getPendingRepairStats()
-
releaseRepairData
public CleanupSummary releaseRepairData(java.util.Collection<TimeUUID> sessions, boolean force)
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
public PaxosRepairHistory getPaxosRepairHistory()
-
getPaxosRepairHistoryForRanges
public PaxosRepairHistory getPaxosRepairHistoryForRanges(java.util.Collection<Range<Token>> ranges)
-
syncPaxosRepairHistory
public void syncPaxosRepairHistory(PaxosRepairHistory sync, boolean flush)
-
onPaxosRepairComplete
public void onPaxosRepairComplete(java.util.Collection<Range<Token>> ranges, Ballot highBallot)
-
getPaxosRepairLowBound
public Ballot getPaxosRepairLowBound(DecoratedKey key)
-
gcBefore
public long gcBefore(long nowInSec)
-
selectAndReference
public ColumnFamilyStore.RefViewFragment selectAndReference(com.google.common.base.Function<View,java.lang.Iterable<SSTableReader>> filter)
-
select
public ColumnFamilyStore.ViewFragment select(com.google.common.base.Function<View,java.lang.Iterable<SSTableReader>> filter)
-
getSSTablesForKey
public java.util.List<java.lang.String> getSSTablesForKey(java.lang.String key)
Description copied from interface:ColumnFamilyStoreMBean
Returns a list of filenames that contain the given key on this node- Specified by:
getSSTablesForKey
in interfaceColumnFamilyStoreMBean
- Returns:
- list of filenames containing the key
-
getSSTablesForKey
public java.util.List<java.lang.String> getSSTablesForKey(java.lang.String key, boolean hexFormat)
Description copied from interface:ColumnFamilyStoreMBean
Returns a list of filenames that contain the given key on this node- Specified by:
getSSTablesForKey
in interfaceColumnFamilyStoreMBean
hexFormat
- if key is in hex string format- Returns:
- list of filenames containing the key
-
getSSTablesForKeyWithLevel
public java.util.Map<java.lang.Integer,java.util.Set<java.lang.String>> getSSTablesForKeyWithLevel(java.lang.String key, boolean hexFormat)
Description copied from interface:ColumnFamilyStoreMBean
Returns a list of filenames that contain the given key and which level they belong to. Requires table to be compacted withLeveledCompactionStrategy
- Specified by:
getSSTablesForKeyWithLevel
in interfaceColumnFamilyStoreMBean
- Returns:
- list of filenames and levels containing the key
-
withSSTablesForKey
public <T> java.util.List<T> withSSTablesForKey(java.lang.String key, boolean hexFormat, com.google.common.base.Function<SSTableReader,T> mapper)
-
beginLocalSampling
public void beginLocalSampling(java.lang.String sampler, int capacity, int durationMillis)
Description copied from interface:ColumnFamilyStoreMBean
begin 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:
beginLocalSampling
in interfaceColumnFamilyStoreMBean
-
finishLocalSampling
public java.util.List<javax.management.openmbean.CompositeData> finishLocalSampling(java.lang.String sampler, int count) throws javax.management.openmbean.OpenDataException
- Specified by:
finishLocalSampling
in interfaceColumnFamilyStoreMBean
- Returns:
- top count items for the sampler since beginLocalSampling was called
- Throws:
javax.management.openmbean.OpenDataException
-
isCompactionDiskSpaceCheckEnabled
public boolean isCompactionDiskSpaceCheckEnabled()
- Specified by:
isCompactionDiskSpaceCheckEnabled
in interfaceColumnFamilyStoreMBean
-
compactionDiskSpaceCheck
public void compactionDiskSpaceCheck(boolean enable)
- Specified by:
compactionDiskSpaceCheck
in interfaceColumnFamilyStoreMBean
-
cleanupCache
public void cleanupCache()
-
getComparator
public ClusteringComparator getComparator()
-
snapshotWithoutMemtable
public TableSnapshot snapshotWithoutMemtable(java.lang.String snapshotName)
-
snapshotWithoutMemtable
public TableSnapshot snapshotWithoutMemtable(java.lang.String snapshotName, java.time.Instant creationTime)
-
snapshotWithoutMemtable
public TableSnapshot snapshotWithoutMemtable(java.lang.String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, java.time.Instant creationTime)
- Parameters:
ephemeral
- If this flag is set to true, the snapshot will be cleaned during next startup
-
createSnapshot
protected TableSnapshot createSnapshot(java.lang.String tag, boolean ephemeral, DurationSpec.IntSecondsBound ttl, java.util.Set<SSTableReader> sstables, java.time.Instant creationTime)
-
clearEphemeralSnapshots
protected static void clearEphemeralSnapshots(Directories directories)
-
getSnapshotSSTableReaders
public Refs<SSTableReader> getSnapshotSSTableReaders(java.lang.String tag) throws java.io.IOException
- Throws:
java.io.IOException
-
snapshot
public TableSnapshot snapshot(java.lang.String snapshotName)
Take a snap shot of this columnfamily store.- Parameters:
snapshotName
- the name of the associated with the snapshot
-
snapshot
public TableSnapshot snapshot(java.lang.String snapshotName, DurationSpec.IntSecondsBound ttl)
-
snapshot
public TableSnapshot snapshot(java.lang.String snapshotName, boolean skipMemtable, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, java.time.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(java.lang.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(java.lang.String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral, boolean skipMemtable, DurationSpec.IntSecondsBound ttl, com.google.common.util.concurrent.RateLimiter rateLimiter, java.time.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
public boolean snapshotExists(java.lang.String snapshotName)
-
clearSnapshot
public void clearSnapshot(java.lang.String snapshotName)
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
public java.util.Map<java.lang.String,TableSnapshot> 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
public CachedPartition getRawCachedPartition(DecoratedKey key)
- 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
public int invalidateRowCache(java.util.Collection<Bounds<Token>> boundsToInvalidate)
-
invalidateCounterCache
public int invalidateCounterCache(java.util.Collection<Bounds<Token>> boundsToInvalidate)
-
containsCachedParition
public boolean containsCachedParition(DecoratedKey key)
- Returns:
- true if @param key is contained in the row cache
-
invalidateCachedPartition
public void invalidateCachedPartition(RowCacheKey key)
-
invalidateCachedPartition
public void invalidateCachedPartition(DecoratedKey key)
-
getCachedCounter
public ClockAndCount getCachedCounter(java.nio.ByteBuffer partitionKey, Clustering<?> clustering, ColumnMetadata column, CellPath path)
-
putCachedCounter
public void putCachedCounter(java.nio.ByteBuffer partitionKey, Clustering<?> clustering, ColumnMetadata column, CellPath path, ClockAndCount clockAndCount)
-
forceMajorCompaction
public void forceMajorCompaction()
-
forceMajorCompaction
public void forceMajorCompaction(boolean splitOutput)
Description copied from interface:ColumnFamilyStoreMBean
force a major compaction of this column family- Specified by:
forceMajorCompaction
in interfaceColumnFamilyStoreMBean
- Parameters:
splitOutput
- true if the output of the major compaction should be split in several sstables
-
forceCompactionForTokenRange
public void forceCompactionForTokenRange(java.util.Collection<Range<Token>> tokenRanges) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
Description copied from interface:ColumnFamilyStoreMBean
Forces 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
Range
class is suppossed to be half-open by definition.- Specified by:
forceCompactionForTokenRange
in interfaceColumnFamilyStoreMBean
- Parameters:
tokenRanges
- The token ranges to be compacted, interpreted as closed intervals.- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
-
forceCompactionForTokenRanges
public void forceCompactionForTokenRanges(java.lang.String... strings)
Description copied from interface:ColumnFamilyStoreMBean
Forces 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
Range
class is suppossed to be half-open by definition.- Specified by:
forceCompactionForTokenRanges
in interfaceColumnFamilyStoreMBean
-
forceCompactionForKey
public void forceCompactionForKey(DecoratedKey key)
-
forceCompactionKeysIgnoringGcGrace
public void forceCompactionKeysIgnoringGcGrace(java.lang.String... partitionKeysIgnoreGcGrace)
-
shouldIgnoreGcGraceForKey
public boolean shouldIgnoreGcGraceForKey(DecoratedKey dk)
-
all
public static java.lang.Iterable<ColumnFamilyStore> all()
-
keySamples
public java.lang.Iterable<DecoratedKey> keySamples(Range<Token> range)
-
writeAndAddMemtableRanges
public void writeAndAddMemtableRanges(TimeUUID repairSessionID, java.util.function.Supplier<java.util.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
public Future<CommitLogPosition> 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(java.util.concurrent.Callable<V> callable, OperationType operationType, boolean interruptValidation, boolean interruptViews)
-
runWithCompactionsDisabled
public <V> V runWithCompactionsDisabled(java.util.concurrent.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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
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:
isAutoCompactionDisabled
in interfaceColumnFamilyStoreMBean
-
getCompactionStrategyManager
public CompactionStrategyManager getCompactionStrategyManager()
-
setCrcCheckChance
public void setCrcCheckChance(double crcCheckChance)
Description copied from interface:ColumnFamilyStoreMBean
Set new crc check chance- Specified by:
setCrcCheckChance
in interfaceColumnFamilyStoreMBean
-
getCrcCheckChance
public java.lang.Double getCrcCheckChance()
- Specified by:
getCrcCheckChance
in interfaceSSTable.Owner
-
setCompactionThresholds
public void setCompactionThresholds(int minThreshold, int maxThreshold)
Description copied from interface:ColumnFamilyStoreMBean
Sets the maximum and maximum number of SSTables in queue before compaction kicks off- Specified by:
setCompactionThresholds
in interfaceColumnFamilyStoreMBean
-
getMinimumCompactionThreshold
public int getMinimumCompactionThreshold()
Description copied from interface:ColumnFamilyStoreMBean
Gets the minimum number of sstables in queue before compaction kicks off- Specified by:
getMinimumCompactionThreshold
in interfaceColumnFamilyStoreMBean
-
setMinimumCompactionThreshold
public void setMinimumCompactionThreshold(int minCompactionThreshold)
Description copied from interface:ColumnFamilyStoreMBean
Sets the minimum number of sstables in queue before compaction kicks off- Specified by:
setMinimumCompactionThreshold
in interfaceColumnFamilyStoreMBean
-
getMaximumCompactionThreshold
public int getMaximumCompactionThreshold()
Description copied from interface:ColumnFamilyStoreMBean
Gets the maximum number of sstables in queue before compaction kicks off- Specified by:
getMaximumCompactionThreshold
in interfaceColumnFamilyStoreMBean
-
setMaximumCompactionThreshold
public void setMaximumCompactionThreshold(int maxCompactionThreshold)
Description copied from interface:ColumnFamilyStoreMBean
Sets the maximum number of sstables in queue before compaction kicks off- Specified by:
setMaximumCompactionThreshold
in interfaceColumnFamilyStoreMBean
-
getMeanEstimatedCellPerPartitionCount
public int getMeanEstimatedCellPerPartitionCount()
-
getMeanPartitionSize
public double getMeanPartitionSize()
-
getMeanRowCount
public int getMeanRowCount()
-
estimateKeys
public long estimateKeys()
- Specified by:
estimateKeys
in interfaceColumnFamilyStoreMBean
-
getPartitioner
public IPartitioner getPartitioner()
-
decorateKey
public DecoratedKey decorateKey(java.nio.ByteBuffer key)
-
isIndex
public boolean isIndex()
true if this CFS contains secondary index data
-
concatWithIndexes
public java.lang.Iterable<ColumnFamilyStore> concatWithIndexes()
-
getBuiltIndexes
public java.util.List<java.lang.String> getBuiltIndexes()
Description copied from interface:ColumnFamilyStoreMBean
Returns a list of the names of the built column indexes for current store- Specified by:
getBuiltIndexes
in interfaceColumnFamilyStoreMBean
- Returns:
- list of the index names
-
getUnleveledSSTables
public int getUnleveledSSTables()
- Specified by:
getUnleveledSSTables
in interfaceColumnFamilyStoreMBean
- Returns:
- the number of SSTables in L0. Always return 0 if Leveled compaction is not enabled.
-
getSSTableCountPerLevel
public int[] getSSTableCountPerLevel()
- Specified by:
getSSTableCountPerLevel
in 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:
getPerLevelSizeBytes
in 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:
isLeveledCompaction
in interfaceColumnFamilyStoreMBean
- Returns:
- true if the table is using LeveledCompactionStrategy. false otherwise.
-
getSSTableCountPerTWCSBucket
public int[] getSSTableCountPerTWCSBucket()
- Specified by:
getSSTableCountPerTWCSBucket
in 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:
getLevelFanoutSize
in 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:ColumnFamilyStoreMBean
Get the ratio of droppable tombstones to real columns (and non-droppable tombstones)- Specified by:
getDroppableTombstoneRatio
in interfaceColumnFamilyStoreMBean
- Returns:
- ratio
-
trueSnapshotsSize
public long trueSnapshotsSize()
- Specified by:
trueSnapshotsSize
in interfaceColumnFamilyStoreMBean
- Returns:
- the size of SSTables in "snapshots" subdirectory which aren't live anymore
-
getIfExists
public static ColumnFamilyStore getIfExists(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.
-
getIfExists
public static ColumnFamilyStore getIfExists(java.lang.String ksName, java.lang.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.
-
metricsFor
public static TableMetrics metricsFor(TableId tableId)
-
getDirectoriesForFiles
public java.util.List<File> getDirectoriesForFiles(java.util.Set<SSTableReader> sstables)
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
public DiskBoundaries getDiskBoundaries()
-
invalidateLocalRanges
public void invalidateLocalRanges()
-
setNeverPurgeTombstones
public void setNeverPurgeTombstones(boolean value)
- Specified by:
setNeverPurgeTombstones
in interfaceColumnFamilyStoreMBean
-
getNeverPurgeTombstones
public boolean getNeverPurgeTombstones()
- Specified by:
getNeverPurgeTombstones
in interfaceColumnFamilyStoreMBean
-
hasMisplacedSSTables
public boolean hasMisplacedSSTables()
Description copied from interface:ColumnFamilyStoreMBean
Check SSTables whether or not they are misplaced.- Specified by:
hasMisplacedSSTables
in 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:ColumnFamilyStoreMBean
Returns the size of the biggest SSTable of this table.- Specified by:
getMaxSSTableSize
in 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:ColumnFamilyStoreMBean
Returns the longest duration of an SSTable, in milliseconds, of this table, computed asmaxTimestamp - minTimestamp
. It returns 0 if there are no SSTables or ifmaxTimestamp
orminTimestamp
is equal toLong.MAX_VALUE
. Effectively non-zero for tables onTimeWindowCompactionStrategy
.- Specified by:
getMaxSSTableDuration
in interfaceColumnFamilyStoreMBean
- Returns:
- the biggest
maxTimestamp - minTimestamp
among all SSTables of this table or 0 if no SSTable is present
-
getTopSizePartitions
public java.util.Map<java.lang.String,java.lang.Long> getTopSizePartitions()
- Specified by:
getTopSizePartitions
in interfaceColumnFamilyStoreMBean
-
getTopSizePartitionsLastUpdate
public java.lang.Long getTopSizePartitionsLastUpdate()
- Specified by:
getTopSizePartitionsLastUpdate
in interfaceColumnFamilyStoreMBean
-
getTopTombstonePartitions
public java.util.Map<java.lang.String,java.lang.Long> getTopTombstonePartitions()
- Specified by:
getTopTombstonePartitions
in interfaceColumnFamilyStoreMBean
-
getTopTombstonePartitionsLastUpdate
public java.lang.Long getTopTombstonePartitionsLastUpdate()
- Specified by:
getTopTombstonePartitionsLastUpdate
in interfaceColumnFamilyStoreMBean
-
newReadOrderingBarrier
public OpOrder.Barrier newReadOrderingBarrier()
- Specified by:
newReadOrderingBarrier
in interfaceSSTable.Owner
-
getMetrics
public TableMetrics getMetrics()
- Specified by:
getMetrics
in interfaceSSTable.Owner
-
-