org.apache.cassandra.db.commitlog

## 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
`static class` `CommitLogReplayer.CommitLogReplayException`
`static class` `CommitLogReplayer.MutationInitiator`

### Nested classes/interfaces inherited from interface org.apache.cassandra.db.commitlog.CommitLogReadHandler

`CommitLogReadHandler.CommitLogReadErrorReason, CommitLogReadHandler.CommitLogReadException`

### Field Summary

Fields
`protected CommitLogReader` `commitLogReader`
`static long` `MAX_OUTSTANDING_REPLAY_BYTES`
`static CommitLogReplayer.MutationInitiator` `mutationInitiator`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`int` `blockForWrites()` Flushes all keyspaces associated with this replayer in parallel, blocking until their flushes are complete.
`static CommitLogReplayer` `construct(CommitLog commitLog)`
`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.
`void` `handleMutation(Mutation m, int size, int entryLocation, CommitLogDescriptor desc)` Process a deserialized mutation
`void` `handleUnrecoverableError(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)` 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
`protected boolean` `pointInTimeExceeded(Mutation fm)`
`void` `replayFiles(java.io.File[] clogs)`
`void` `replayPath(java.io.File file, boolean tolerateTruncation)`
`boolean` `shouldSkipSegmentOnError(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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### MAX_OUTSTANDING_REPLAY_BYTES

    public static long MAX_OUTSTANDING_REPLAY_BYTES

#### mutationInitiator

    public static CommitLogReplayer.MutationInitiator mutationInitiator

#### commitLogReader

    protected CommitLogReader commitLogReader

### Method Detail

#### construct

    public static CommitLogReplayer construct(CommitLog commitLog)

#### replayPath

    public void replayPath(java.io.File file,
                           boolean tolerateTruncation)
                    throws java.io.IOException

Throws:
  `java.io.IOException`

#### replayFiles

    public void replayFiles(java.io.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)

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: `CommitLogReadHandler`
Process a deserialized mutation

Specified by:
  `handleMutation` in interface `CommitLogReadHandler`
Parameters:
  `m` - deserialized mutation
  `size` - serialized size of the mutation
  `entryLocation` - filePointer offset inside the CommitLogSegment for the record
  `desc` - CommitLogDescriptor for mutation being processed

#### shouldSkipSegmentOnError

    public boolean shouldSkipSegmentOnError(CommitLogReadHandler.CommitLogReadException exception)
                                     throws java.io.IOException

Description copied from interface: `CommitLogReadHandler`
Handle 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:
  `shouldSkipSegmentOnError` in interface `CommitLogReadHandler`
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:
  `handleUnrecoverableError` in interface `CommitLogReadHandler`
Parameters:
  `exception` - CommitLogReadException w/details on exception state
Throws:
  `java.io.IOException`