Class CommitLogReplayer

java.lang.Object
org.apache.cassandra.db.commitlog.CommitLogReplayer
All Implemented Interfaces:
CommitLogReadHandler

public class CommitLogReplayer extends Object implements CommitLogReadHandler
  • Field Details

    • 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 Details

    • construct

      public static CommitLogReplayer construct(CommitLog commitLog, UUID localHostId)
    • replayPath

      public void replayPath(File file, boolean tolerateTruncation) throws IOException
      Throws:
      IOException
    • replayFiles

      public void replayFiles(File[] clogs) throws IOException
      Throws:
      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(Iterable<SSTableReader> onDisk, CommitLogPosition truncatedAt, 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(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 end of the record
      desc - CommitLogDescriptor for mutation being processed
    • shouldSkipSegmentOnError

      public boolean shouldSkipSegmentOnError(CommitLogReadHandler.CommitLogReadException exception) throws 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:
      IOException - In the event the handler wants forceful termination of all processing, throw IOException.
    • handleUnrecoverableError

      public void handleUnrecoverableError(CommitLogReadHandler.CommitLogReadException exception) throws 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:
      IOException