Uploaded image for project: 'controller'
  1. controller
  2. CONTROLLER-2100

Improve JournalSegmentWriter.reset(long)

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: High High
    • 10.0.0, 8.0.6, 9.0.3
    • None
    • clustering

      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:

      1. 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)
      2. 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.

            rkashapov Ruslan Kashapov
            rovarga Robert Varga
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: