Class CommitLogReplayer
- java.lang.Object
-
- org.apache.cassandra.db.commitlog.CommitLogReplayer
-
- All Implemented Interfaces:
CommitLogReadHandler
public class CommitLogReplayer extends java.lang.Object implements CommitLogReadHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCommitLogReplayer.CommitLogReplayExceptionstatic classCommitLogReplayer.MutationInitiator-
Nested classes/interfaces inherited from interface org.apache.cassandra.db.commitlog.CommitLogReadHandler
CommitLogReadHandler.CommitLogReadErrorReason, CommitLogReadHandler.CommitLogReadException
-
-
Field Summary
Fields Modifier and Type Field Description protected CommitLogReadercommitLogReaderstatic longMAX_OUTSTANDING_REPLAY_BYTESstatic CommitLogReplayer.MutationInitiatormutationInitiatorprotected booleansawCDCMutation
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intblockForWrites()Flushes all keyspaces associated with this replayer in parallel, blocking until their flushes are complete.static CommitLogReplayerconstruct(CommitLog commitLog, java.util.UUID localHostId)static CommitLogPositionfirstNotCovered(java.util.Collection<IntervalSet<CommitLogPosition>> ranges)Find the earliest commit log position that is not covered by the known flushed ranges for some table.voidhandleMutation(Mutation m, int size, int entryLocation, CommitLogDescriptor desc)Process a deserialized mutationvoidhandleUnrecoverableError(CommitLogReadHandler.CommitLogReadException exception)The logic for whether or not we throw on an error is identical for the replayer between recoverable or non.static IntervalSet<CommitLogPosition>persistedIntervals(java.lang.Iterable<SSTableReader> onDisk, CommitLogPosition truncatedAt, java.util.UUID localhostId)A set of known safe-to-discard commit log replay positions, based on the range covered by on disk sstables and those prior to the most recent truncation recordprotected booleanpointInTimeExceeded(Mutation fm)voidreplayFiles(File[] clogs)voidreplayPath(File file, boolean tolerateTruncation)booleanshouldSkipSegmentOnError(CommitLogReadHandler.CommitLogReadException exception)Handle an error during segment read, signaling whether or not you want the reader to skip the remainder of the current segment on error.
-
-
-
Field Detail
-
MAX_OUTSTANDING_REPLAY_BYTES
public static long MAX_OUTSTANDING_REPLAY_BYTES
-
mutationInitiator
public static CommitLogReplayer.MutationInitiator mutationInitiator
-
sawCDCMutation
protected boolean sawCDCMutation
-
commitLogReader
protected CommitLogReader commitLogReader
-
-
Method Detail
-
construct
public static CommitLogReplayer construct(CommitLog commitLog, java.util.UUID localHostId)
-
replayPath
public void replayPath(File file, boolean tolerateTruncation) throws java.io.IOException
- Throws:
java.io.IOException
-
replayFiles
public void replayFiles(File[] clogs) throws java.io.IOException
- Throws:
java.io.IOException
-
blockForWrites
public int blockForWrites()
Flushes all keyspaces associated with this replayer in parallel, blocking until their flushes are complete.- Returns:
- the number of mutations replayed
-
persistedIntervals
public static IntervalSet<CommitLogPosition> persistedIntervals(java.lang.Iterable<SSTableReader> onDisk, CommitLogPosition truncatedAt, java.util.UUID localhostId)
A set of known safe-to-discard commit log replay positions, based on the range covered by on disk sstables and those prior to the most recent truncation record
-
firstNotCovered
public static CommitLogPosition firstNotCovered(java.util.Collection<IntervalSet<CommitLogPosition>> ranges)
Find the earliest commit log position that is not covered by the known flushed ranges for some table. For efficiency this assumes that the first contiguously flushed interval we know of contains the moment that the given table was constructed* and hence we can start replay from the end of that interval. If such an interval is not known, we must replay from the beginning. * This is not true only until if the very first flush of a table stalled or failed, while the second or latter succeeded. The chances of this happening are at most very low, and if the assumption does prove to be incorrect during replay there is little chance that the affected deployment is in production.
-
pointInTimeExceeded
protected boolean pointInTimeExceeded(Mutation fm)
-
handleMutation
public void handleMutation(Mutation m, int size, int entryLocation, CommitLogDescriptor desc)
Description copied from interface:CommitLogReadHandlerProcess a deserialized mutation- Specified by:
handleMutationin interfaceCommitLogReadHandler- Parameters:
m- deserialized mutationsize- serialized size of the mutationentryLocation- filePointer offset inside the CommitLogSegment for the end of the recorddesc- CommitLogDescriptor for mutation being processed
-
shouldSkipSegmentOnError
public boolean shouldSkipSegmentOnError(CommitLogReadHandler.CommitLogReadException exception) throws java.io.IOException
Description copied from interface:CommitLogReadHandlerHandle an error during segment read, signaling whether or not you want the reader to skip the remainder of the current segment on error.- Specified by:
shouldSkipSegmentOnErrorin interfaceCommitLogReadHandler- Parameters:
exception- CommitLogReadException w/details on exception state- Returns:
- boolean indicating whether to stop reading
- Throws:
java.io.IOException- In the event the handler wants forceful termination of all processing, throw IOException.
-
handleUnrecoverableError
public void handleUnrecoverableError(CommitLogReadHandler.CommitLogReadException exception) throws java.io.IOException
The logic for whether or not we throw on an error is identical for the replayer between recoverable or non.- Specified by:
handleUnrecoverableErrorin interfaceCommitLogReadHandler- Parameters:
exception- CommitLogReadException w/details on exception state- Throws:
java.io.IOException
-
-