Class CommitLog
java.lang.Object
org.apache.cassandra.db.commitlog.CommitLog
- All Implemented Interfaces:
CommitLogMBean
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal CommitLogArchiverstatic final CommitLogfinal CommitLogMetrics -
Method Summary
Modifier and TypeMethodDescriptionAdd a Mutation to the commit log.voiddiscardCompletedSegments(TableId id, CommitLogPosition lowerBound, CommitLogPosition upperBound) Modifies the per-CF dirty cursors of any commit log segments for the column family according to the position given.voidFlushes all dirty CFs, waiting for them to free and recycle any segments they were retainingvoidforceRecycleAllSegments(Collection<TableId> droppedTables) Flushes all dirty CFs, waiting for them to free and recycle any segments they were retainingstatic longlonglongCommand to execute to archive a commitlog segment.booleanCommand to execute to make an archived commitlog live againDirectory to scan the recovery files inlongRestore mutations created up to and including this timestamp in GMT There are only three different formats to express three time precisions: Seconds, Milliseconds, and Microseconds.get precision of the timestamp used in the restore (MILLISECONDS, MICROSECONDS, ...) to determine if passed the restore point in time.File[]static booleanhandleCommitError(String message, Throwable t) booleanbooleanReturns true if internodes streaming of CDC data should go through write pathbooleanvoidPerform recovery on a single commit log.intrecoverFiles(File... clogs) Perform recovery on a list of commit log files.voidrecoverPath(String path) intPerform recovery on commit logs located in the directory specified by the config file.voidPreempts the CLExecutor, telling to to sync immediatelyvoidFOR TESTING PURPOSES.intresetUnsafe(boolean deleteSegments) FOR TESTING PURPOSESintFOR TESTING PURPOSESvoidsetCDCBlockWrites(boolean val) voidsetCDCOnRepairEnabled(boolean value) Set whether enable write path for CDC data during internodes streaming, e.g.voidShuts down the threads used by the commit log, blocking until completion.start()Tries to start the CommitLog if not already started.voidstopUnsafe(boolean deleteSegments) FOR TESTING PURPOSESvoidsync(boolean flush) Forces a disk flush on the commit log files that need it.
-
Field Details
-
instance
-
segmentManager
-
archiver
-
metrics
-
-
Method Details
-
start
Tries to start the CommitLog if not already started. -
isStarted
public boolean isStarted() -
hasFilesToReplay
public boolean hasFilesToReplay() -
getUnmanagedFiles
-
recoverSegmentsOnDisk
Perform recovery on commit logs located in the directory specified by the config file.- Returns:
- the number of mutations replayed
- Throws:
IOException
-
recoverFiles
Perform recovery on a list of commit log files.- Parameters:
clogs- the list of commit log files to replay- Returns:
- the number of mutations replayed
- Throws:
IOException
-
recoverPath
- Throws:
IOException
-
recover
Perform recovery on a single commit log. Kept w/sub-optimal name due to coupling w/MBean / JMX- Specified by:
recoverin interfaceCommitLogMBean- Throws:
IOException
-
getCurrentPosition
- Returns:
- a CommitLogPosition which, if
>= onereturned from add(), implies add() was started (but not necessarily finished) prior to this call
-
forceRecycleAllSegments
Flushes all dirty CFs, waiting for them to free and recycle any segments they were retaining -
forceRecycleAllSegments
public void forceRecycleAllSegments()Flushes all dirty CFs, waiting for them to free and recycle any segments they were retaining -
sync
Forces a disk flush on the commit log files that need it. Blocking.- Throws:
IOException
-
requestExtraSync
public void requestExtraSync()Preempts the CLExecutor, telling to to sync immediately -
add
Add a Mutation to the commit log. If CDC is enabled, this can fail.- Parameters:
mutation- the Mutation to add to the log- Throws:
CDCWriteException
-
discardCompletedSegments
public void discardCompletedSegments(TableId id, CommitLogPosition lowerBound, CommitLogPosition upperBound) Modifies the per-CF dirty cursors of any commit log segments for the column family according to the position given. Discards any commit log segments that are no longer used.- Parameters:
id- the table that was flushedlowerBound- the lowest covered replay position of the flushlowerBound- the highest covered replay position of the flush
-
getArchiveCommand
Description copied from interface:CommitLogMBeanCommand to execute to archive a commitlog segment. Blank to disabled.- Specified by:
getArchiveCommandin interfaceCommitLogMBean
-
getRestoreCommand
Description copied from interface:CommitLogMBeanCommand to execute to make an archived commitlog live again- Specified by:
getRestoreCommandin interfaceCommitLogMBean
-
getRestoreDirectories
Description copied from interface:CommitLogMBeanDirectory to scan the recovery files in- Specified by:
getRestoreDirectoriesin interfaceCommitLogMBean
-
getRestorePointInTime
public long getRestorePointInTime()Description copied from interface:CommitLogMBeanRestore mutations created up to and including this timestamp in GMT There are only three different formats to express three time precisions: Seconds, Milliseconds, and Microseconds. Seconds format: yyyy:MM:dd HH:mm:ss (2012:04:31 20:43:12) Milliseconds format: yyyy:MM:dd HH:mm:ss.SSS (2012:04:31 20:43:12.633) Microseconds format: yyyy:MM:dd HH:mm:ss.SSSSSS (2012:04:31 20:43:12.633222) Recovery will continue through the segment when the first client-supplied timestamp greater than this time is encountered, but only mutations less than or equal to this timestamp will be applied.- Specified by:
getRestorePointInTimein interfaceCommitLogMBean
-
getRestorePrecision
Description copied from interface:CommitLogMBeanget precision of the timestamp used in the restore (MILLISECONDS, MICROSECONDS, ...) to determine if passed the restore point in time.- Specified by:
getRestorePrecisionin interfaceCommitLogMBean
-
getActiveSegmentNames
- Specified by:
getActiveSegmentNamesin interfaceCommitLogMBean- Returns:
- file names (not full paths) of active commit log segments (segments containing unflushed data)
-
getArchivingSegmentNames
- Specified by:
getArchivingSegmentNamesin interfaceCommitLogMBean- Returns:
- Files which are pending for archival attempt. Does NOT include failed archive attempts.
-
getActiveContentSize
public long getActiveContentSize()- Specified by:
getActiveContentSizein interfaceCommitLogMBean- Returns:
- The size of the mutations in all active commit log segments (uncompressed).
-
getActiveOnDiskSize
public long getActiveOnDiskSize()- Specified by:
getActiveOnDiskSizein interfaceCommitLogMBean- Returns:
- The space taken on disk by the commit log (compressed).
-
getActiveSegmentCompressionRatios
- Specified by:
getActiveSegmentCompressionRatiosin interfaceCommitLogMBean- Returns:
- A map between active log segments and the compression ratio achieved for each.
-
getCDCBlockWrites
public boolean getCDCBlockWrites()- Specified by:
getCDCBlockWritesin interfaceCommitLogMBean
-
setCDCBlockWrites
public void setCDCBlockWrites(boolean val) - Specified by:
setCDCBlockWritesin interfaceCommitLogMBean
-
isCDCOnRepairEnabled
public boolean isCDCOnRepairEnabled()Description copied from interface:CommitLogMBeanReturns true if internodes streaming of CDC data should go through write path- Specified by:
isCDCOnRepairEnabledin interfaceCommitLogMBean
-
setCDCOnRepairEnabled
public void setCDCOnRepairEnabled(boolean value) Description copied from interface:CommitLogMBeanSet whether enable write path for CDC data during internodes streaming, e.g. repair- Specified by:
setCDCOnRepairEnabledin interfaceCommitLogMBean
-
shutdownBlocking
Shuts down the threads used by the commit log, blocking until completion. TODO this should accept a timeout, and throw TimeoutException- Throws:
InterruptedException
-
resetUnsafe
FOR TESTING PURPOSES- Returns:
- the number of files recovered
- Throws:
IOException
-
resetConfiguration
public void resetConfiguration()FOR TESTING PURPOSES. -
stopUnsafe
public void stopUnsafe(boolean deleteSegments) FOR TESTING PURPOSES -
restartUnsafe
FOR TESTING PURPOSES- Throws:
IOException
-
freeDiskSpace
public static long freeDiskSpace() -
handleCommitError
-