-
Improvement
-
Resolution: Unresolved
-
High
-
None
JournalSegmentWriter.reset() has two implementations, which are pretty much the same thing. These should be concentrated into JournalSegmentWriter itself, with proper reading callouts to the two concrete implementations – so that we have a single place maintaining the logic.
Furthermore this method serves two distinct purposes:
- reset(0) is used as a magic value to indicate to go through all entries for the purposes when the file is open for the first time (see
CONTROLLER-2043's final fix for details) - other invocations are coming from JournalSegmentWriter.truncate(long) and their purpose boils down to resetting the file position the the indicated entry
The first case should be a dedicated method, called from the constructor only. That method should be verifying CRC, but it should not be deserializing all entries – just the last one.
The second case should really be inlined into truncate() and should consult the index, which is guaranteed to may know where exactly the a previous entry lies – so it can rewind to that offset and only read that entry enough entries to correctly position.
- split from
-
CONTROLLER-2043 Circuit breaker timeout with BGP and tell-based protocol
- Resolved