in cassandra-four-zero-bridge/src/main/java/org/apache/cassandra/db/commitlog/BufferingCommitLogReader.java [264:324]
private void readCommitLogSegment() throws IOException
{
long startTimeNanos = System.nanoTime();
SeekableCommitLogSegmentReader segmentReader;
try
{
segmentReader = new SeekableCommitLogSegmentReader(segmentId, this, desc, reader, logger, false);
}
catch (Exception e)
{
this.handleUnrecoverableError(new CommitLogReadException(
String.format("Unable to create segment reader for commit log file: %s", e),
CommitLogReadErrorReason.UNRECOVERABLE_UNKNOWN_ERROR,
false));
return;
}
try
{
if (reader.getFilePointer() < startMarker.position())
{
stats.commitLogBytesSkippedOnRead(startMarker.position() - reader.getFilePointer());
segmentReader.seek(startMarker.position());
}
for (CommitLogSegmentReader.SyncSegment syncSegment : segmentReader)
{
// Only tolerate truncationSerializationHeader if we allow in both global and segment
// statusTracker.tolerateErrorsInSection = tolerateTruncation && syncSegment.toleratesErrorsInSection;
statusTracker.errorContext = String.format("Next section at %d in %s", syncSegment.fileStartPosition, log.name());
readSection(syncSegment.input, syncSegment.endPosition);
// track the position at end of previous section after successfully reading mutations
// so we can update highwater mark after reading
this.position = (int) reader.getFilePointer();
if (listener != null)
{
listener.accept(log.markerAt(segmentId, position));
}
if (!statusTracker.shouldContinue())
{
break;
}
}
}
// Unfortunately CommitLogSegmentReader.SegmentIterator (for-loop) cannot throw a checked exception,
// so we check to see if a RuntimeException is wrapping an IOException.
catch (RuntimeException re)
{
if (re.getCause() instanceof IOException)
{
throw (IOException) re.getCause();
}
throw re;
}
logger.debug("Finished reading commit log", "updates", updates.size(), "timeNanos", (System.nanoTime() - startTimeNanos));
}