/** Update the cursors that were pointing to head after a rotation of the head log file. */ private void updateOpenedCursorsOnHeadAfterRotation( List<Pair<AbortableLogCursor<K, V>, CursorState<K, V>>> cursors) throws ChangelogException { for (Pair<AbortableLogCursor<K, V>, CursorState<K, V>> pair : cursors) { final CursorState<K, V> cursorState = pair.getSecond(); // Need to update the cursor only if it is pointing to the head log file if (cursorState.isValid() && isHeadLogFile(cursorState.logFile)) { final K previousKey = logFiles.lowerKey(recordParser.getMaxKey()); final LogFile<K, V> logFile = findLogFileFor(previousKey); final AbortableLogCursor<K, V> cursor = pair.getFirst(); cursor.reinitializeTo( new CursorState<K, V>(logFile, cursorState.filePosition, cursorState.record)); } } }