controller.git
3 weeks agoMove entry serialization back to ByteBufWriter 51/111651/12
Robert Varga [Tue, 7 May 2024 20:29:31 +0000 (22:29 +0200)]
Move entry serialization back to ByteBufWriter

I8f6bac3192a0f38b627150be4c8ea128f1e233e5 moved serialization to heap,
causing unnecessary copies, while nominally simplifying the interface.

This patch undoes that move, restoring the logic, except working on top
of a ByteBuf. This requires a bit more logic to deal with the fact we
are no longer writing to the diskEntry nor are we flipping it.

JIRA: CONTROLLER-2115
Change-Id: I1d18f99cfdb5b7e6c6548a5833c824af9f31c166
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoMerge SegmentedByteBufWriter.checkedTruncate() 68/111668/2
Robert Varga [Wed, 8 May 2024 22:00:34 +0000 (00:00 +0200)]
Merge SegmentedByteBufWriter.checkedTruncate()

This method has a single caller, just merge them together.

JIRA: CONTROLLER-2100
Change-Id: Ibf9424e71c9c1dd9e862b00a75d4ed76cd29cc0d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoReformat ByteArrayOutput/BufferAwareByteArrayOutputStream 71/111671/1
Robert Varga [Wed, 8 May 2024 22:34:24 +0000 (00:34 +0200)]
Reformat ByteArrayOutput/BufferAwareByteArrayOutputStream

These are simple classes, just reformat them to keep checkstyle happy.

Change-Id: I7e0331a3bd8b4373921bafb29da6362e02e57f19
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoFix checkstyle in Kryo{IO,Input,Output}Pool 70/111670/1
Robert Varga [Wed, 8 May 2024 22:08:32 +0000 (00:08 +0200)]
Fix checkstyle in Kryo{IO,Input,Output}Pool

Reformat and make minor adjustments to keep everyone happy.

Change-Id: I32371650660080adfac970d9530abb04609de7f6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoSuppress warnings in Kryo505ByteBufferInput 69/111669/1
Robert Varga [Wed, 8 May 2024 22:04:06 +0000 (00:04 +0200)]
Suppress warnings in Kryo505ByteBufferInput

This is legacy third-party code. We will not be fixing its huge amount
of issutes.

Change-Id: I6599301b4124e96fac910a98ac634c94f5c5aa11
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoModernize tests and fixup checkstyle 65/111665/3
Robert Varga [Wed, 8 May 2024 16:45:41 +0000 (18:45 +0200)]
Modernize tests and fixup checkstyle

Reformat for checkstyle compliance and modernize with JUnit5, etc.

Change-Id: I6fab572f429578e6be924f6d8bcffcc6d083d333
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoUse eliminate magic JournalSegmentWriter constructor 63/111663/2
Robert Varga [Wed, 8 May 2024 16:11:14 +0000 (18:11 +0200)]
Use eliminate magic JournalSegmentWriter constructor

Rather than performing internal initialization, move index entries to
acquire current position. This way the writer is always properly
initialized.

JIRA: CONTROLLER-2100
Change-Id: I4c6459d31438379d58dc1c8e769dca368565eaf5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoDo not copy bytes when deserializing 55/111655/3
Robert Varga [Wed, 8 May 2024 03:01:56 +0000 (05:01 +0200)]
Do not copy bytes when deserializing

ByteBufUtil.getBytes() performs a deep copy of the contents of the
buffer. This is completely superfluous, as we can use the underlying
nioBuffer() directly.

JIRA: CONTROLLER-2115
Change-Id: I0a9f0ec7b22682cd41063db93921c159ba66b082
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoImprove TestEntry 48/111648/5
Robert Varga [Tue, 7 May 2024 16:10:22 +0000 (18:10 +0200)]
Improve TestEntry

Implement hashCode()/equals() for comparison clarity.

Change-Id: I90fd7113dfa3f900d61a99fac6989e6df9014664
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoUtilize segment index to recover writer state after truncate 65/111465/7
Ruslan Kashapov [Fri, 19 Apr 2024 08:15:58 +0000 (11:15 +0300)]
Utilize segment index to recover writer state after truncate

index.truncate() returns nearest indexed entry position which
can be used to minimize number of loops required to recover
writer state - current position and last written entry.

JIRA: CONTROLLER-2100
Change-Id: I6875c1697a2ac5f13b82b256850f293a7658f220
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
3 weeks agoRemove JournalWriter.truncate() 62/111662/1
Robert Varga [Wed, 8 May 2024 13:08:44 +0000 (15:08 +0200)]
Remove JournalWriter.truncate()

The truncate(N) operation is completely equivalent to reset(N + 1).
Remove this duplicity, preventing potential confusion.

JIRA: CONTROLLER-2100
Change-Id: If62e55edfd610c87174a6b83a15c0a1a0ab7836c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoClean up SegmentedByteBufWriter.reset(long) 61/111661/1
Robert Varga [Wed, 8 May 2024 14:05:25 +0000 (16:05 +0200)]
Clean up SegmentedByteBufWriter.reset(long)

The logic in writer reset needs to be a tad updated:

- it makes absolutely no sense to seek past last written index, unless
  we want to magically sync across multiply-open journals. We do not
  support that
- we need to realize when we are already at the correct index

JIRA: CONTROLLER-2100
Change-Id: I20b2a084c782069b893059f8d5bf535ecbbf33e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoMove JournalWriter.getLastIndex() 47/111647/4
Robert Varga [Mon, 6 May 2024 19:51:31 +0000 (21:51 +0200)]
Move JournalWriter.getLastIndex()

Last written index is a property of a particular Journal, not of a
writer -- and now that we maintain this in the index, we can make
shortcuts.

This also removes a source of confusion, as we have two methods taking
a 'long index' and performing some writer adjustments:
- reset(long) is equivalent of setNextIndex()
- truncate(long) is equivalent of setLastIndex()

Change-Id: I1bc4b5d1b3052c2b35808b8ec4ea2d88dcfca593
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoMaintain last known position in JournalIndex 35/111635/8
Robert Varga [Mon, 6 May 2024 05:16:46 +0000 (07:16 +0200)]
Maintain last known position in JournalIndex

A JournalIndex is bound to see all entries that get written into a file,
hence it can easily maintain that Position. This simplifies
JournalSegmentWriter state maintenance, as we can consult the index for
JournalSegmentWriter.get{Last,Next}Index().

Also expand test suite to make explicit assertions on returns.

JIRA: CONTROLLER-2100
Change-Id: I57731f53cacfdfd548ab59c06706d41a013e7908
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoRefactor SegmentedJournalWriter.reset() 46/111646/2
Robert Varga [Tue, 7 May 2024 13:11:23 +0000 (15:11 +0200)]
Refactor SegmentedJournalWriter.reset()

We have two methods reset() and truncate(), both of which take an index,
without a real documented distinction.

Document reset() as taking the index to read/write next and instantiate
a guard against attempts to use reset(0) -- as 0 is not a valid next
index.

JIRA: CONTROLLER-2100
Change-Id: I8a6b366fdb0827ab3cd5a494e7e9f5a741983264
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoFix segment population 54/111654/2
Robert Varga [Tue, 7 May 2024 22:49:53 +0000 (00:49 +0200)]
Fix segment population

There has been a mixup in previous patch, which ends up touching the
segments from loadSegments(). Fix that up.

JIRA: CONTROLLER-2115
Change-Id: I7932e691c9751a79ab2b407f9de4049721680c6d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoDo not call nextSegment() from {first,last}Segment() 52/111652/3
Robert Varga [Tue, 7 May 2024 21:24:33 +0000 (23:24 +0200)]
Do not call nextSegment() from {first,last}Segment()

We always have at last one segment and nextSegment() is the slow path
here (requiring synchronization). Just assume {first,last}Entry()
returns non-null.

This assumption is violated while we are removing a segment, as we could
be removing the last segment. In that case we need to re-create it.

Also improve method names and documentation a bit.

JIRA: CONTROLLER-2115
Change-Id: I74bb1578e73828666ee795522a68f14ad112ec75
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoUse getCompactableIndex() to unmask firstIndex 53/111653/2
Robert Varga [Tue, 7 May 2024 21:02:42 +0000 (23:02 +0200)]
Use getCompactableIndex() to unmask firstIndex

We have duplicated code which can easily use the result of
getCompactableIndex() and work on top of that.

JIRA: CONTROLLER-2100
Change-Id: Ib580853424d445d82c448a86d82a706f4bba50d2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoRefactor Journal interface 43/111643/2
Robert Varga [Mon, 6 May 2024 18:59:16 +0000 (20:59 +0200)]
Refactor Journal interface

There are two basic issues:
- isOpen() is completely unused
- close() is inherited from Closeable, not AutoCloseable

Address these and move implementation of openReader(long), so it
is canonical.

JIRA: CONTROLLER-2100
Change-Id: I1468ed5a3e9ee1abefe35a4bfaf653696763907f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoSeparate byte-level atomic-storage access 27/111227/20
Ruslan Kashapov [Mon, 22 Apr 2024 14:24:04 +0000 (17:24 +0300)]
Separate byte-level atomic-storage access

Byte level functionality was moved into *ByteJournal*
artifacts and now can be accessed independently.
SegmentedJournal is now acts as a type serialization
layer on top of ByteJournal.

// FIXME: refactor SegmentedJournal.Builder (in a subsequent patch?)

JIRA: CONTROLLER-2115
Change-Id: I2e4941bda3af76f0cd59e8c545131af85c668010
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoDeprecate ByteArraySerdes 50/111650/1
Robert Varga [Tue, 7 May 2024 18:46:07 +0000 (20:46 +0200)]
Deprecate ByteArraySerdes

This is another serdes, it should be deprecated.

Change-Id: I6eab2a136cb1bc3f1f4629561752d8abcb26db56
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoDeprecate more of serdes 49/111649/1
Robert Varga [Tue, 7 May 2024 17:54:02 +0000 (19:54 +0200)]
Deprecate more of serdes

The JournalSerdes is deprecated for removal, as are all the classes
directly related to it. This patch applies the second part of that
sentence.

Change-Id: I0ddb7293dfef539526ecb46598db7e194bdaf8f1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoAdd JournalSegmentFile.map() 33/111633/1
Robert Varga [Mon, 6 May 2024 00:52:44 +0000 (02:52 +0200)]
Add JournalSegmentFile.map()

We already provide a hub for I/O operations. Mapping a file is one such
operation.

JIRA: CONTROLLER-2099
Change-Id: I4fba610eac00739691849454bb99f99796c24e9c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoCentralize IO buffer allocation 32/111632/1
Robert Varga [Mon, 6 May 2024 00:09:32 +0000 (02:09 +0200)]
Centralize IO buffer allocation

JournalSegmentFile.maxSize() goes into the algorithm to choose I/O size.
Let's move the method there.

JIRA: CONTROLLER-2115
Change-Id: I9f0810cb9769217965375ee70c7e3e231adbf1d9
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoAdd SparseJournalIndex.toString() 31/111631/3
Robert Varga [Sun, 5 May 2024 23:49:50 +0000 (01:49 +0200)]
Add SparseJournalIndex.toString()

Improve developer experience by noting positions.

JIRA: CONTROLLER-2115
Change-Id: I1c8d9618ceec6775b22b3bd129ecbc9be8a412d1
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoCentralize CRC32 computation 30/111630/3
Robert Varga [Sun, 5 May 2024 23:22:47 +0000 (01:22 +0200)]
Centralize CRC32 computation

We have essentially-duplicate codepaths between
JournalSegment{Reader,Writer}. Move computation to SegmentEntry.

JIRA: CONTROLLER-2115
Change-Id: I776b693b6e88d84ddb99c274371ac694aa536d1d
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoDo not expose descriptor from JournalSegmentFile 29/111629/3
Robert Varga [Sun, 5 May 2024 22:48:01 +0000 (00:48 +0200)]
Do not expose descriptor from JournalSegmentFile

JournalSegmentFile should expose interesting mapping -- the descriptor
is really an internal thing.

JIRA: CONTROLLER-2099
Change-Id: I2276cee3c4cb15d961aaa1b7f72d618f10dd744e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoRetain RandomAccessFile in JournalSegmentFile 27/111627/4
Robert Varga [Sun, 5 May 2024 21:24:58 +0000 (23:24 +0200)]
Retain RandomAccessFile in JournalSegmentFile

Having a RandomAccessFile is nice, as it internally holds a FileChannel.
This makes our files stateful -- which is okay, as we still manage their
lifecycle via JournalSegment.

JIRA: CONTROLLER-2099
Change-Id: Id8305c74dbd881eaf52d84191c11bb4ea2bc164b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoCentralize JournalSegmentFile creation 26/111626/2
Robert Varga [Sun, 5 May 2024 21:03:03 +0000 (23:03 +0200)]
Centralize JournalSegmentFile creation

There are only two callers of the constructor: we are either creating
a new file (in which case we initialize the descriptor) or we are
opening a file (in which case we read the descriptor).

JIRA: CONTROLLER-2099
Change-Id: Id3943a637067d3b7f2ba7384e417e935df65276a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoImprove JournalSegment lifecycle 25/111625/1
Robert Varga [Sun, 5 May 2024 20:45:39 +0000 (22:45 +0200)]
Improve JournalSegment lifecycle

Disconnect JournalSegment from AutoCloseable, making its close() method
its own thing.

This makes it clear there are really two lifecycle entry points:
- close()
- delete()
Callers of delete() always invoke close(), so let's make sure delete()
does this internally.

JIRA: CONTROLLER-2099
Change-Id: I64b3c12f7a3301e513a36b8a156d8495a405313f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoExpand JournalSegmentFile semantics 24/111624/1
Robert Varga [Sun, 5 May 2024 20:04:20 +0000 (22:04 +0200)]
Expand JournalSegmentFile semantics

JournalSegmentFile also includes a descriptor, making it more useful
than just a File/Path holder.

JIRA: CONTROLLER-2099
Change-Id: Ia808512b7c3012bdb8e749429ac4b785643fa6c7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoRefactor JournalSegmentDescriptor 79/110779/15
Robert Varga [Sun, 5 May 2024 18:50:00 +0000 (20:50 +0200)]
Refactor JournalSegmentDescriptor

Converted JournalSegmentDescriptor to record, unused fields
removed. Also eliminated extra read of descriptor on initial
segment load.

JIRA: CONTROLLER-2107
Change-Id: I5ef45cd2bebfafe0a9dcc9838e056d9ed0bf7958
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoSplit out JournalSegmentDescriptor.readFrom() 22/111622/2
Robert Varga [Sun, 5 May 2024 12:45:54 +0000 (14:45 +0200)]
Split out JournalSegmentDescriptor.readFrom()

We have a user which reads a one-time representation from a file. Split
out that use case into a dedicated factory method.

JIRA: CONTROLLER-2107
Change-Id: I11c335ce03aa59c7796d9c2c8e78801c5b2754c0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoReformat JournalSegmentFile 21/111621/2
Robert Varga [Sun, 5 May 2024 13:03:34 +0000 (15:03 +0200)]
Reformat JournalSegmentFile

It is hard to navigate this file, which seems to be a rather pointless
class. Reformat it before we decide what to do with it next.

Change-Id: I33688e934e9860ae3945cb459e4026d6233bd0af
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoBump upstreams 29/111429/11
Robert Varga [Tue, 16 Apr 2024 12:05:48 +0000 (14:05 +0200)]
Bump upstreams

Adopt:
- odlparent-13.1.2
- yangtools-13.0.5
- mdsal-13.0.3

Also adjusts for the removal of DOMActionResult.

Change-Id: I6a57d7b612203bfea2291432cec4946f11abd078
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoInline isServerConfigurationPayload() 99/111599/2
Robert Varga [Fri, 3 May 2024 21:34:07 +0000 (23:34 +0200)]
Inline isServerConfigurationPayload()

We can use an instanceof pattern to improve safety. Inline the check
into its two callers.

Change-Id: Ia3758a754713818587bf3c7cd215764d05c2028b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoDo not access payload data when not needed 98/111598/2
Robert Varga [Fri, 3 May 2024 21:27:27 +0000 (23:27 +0200)]
Do not access payload data when not needed

We are just putting out a debug, make sure to make this operation
conditional.

Change-Id: I79c39aab6bb6c94efa03e5a878ceabdb552d93cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoImprove segmented journal actor metrics 03/111103/6
Ruslan Kashapov [Wed, 27 Mar 2024 08:52:41 +0000 (10:52 +0200)]
Improve segmented journal actor metrics

Update write time marked on actual flush not on flush request.

JIRA: CONTROLLER-2108
Change-Id: I92a66ae775cbae6aeea69bddf654df741f473dbd
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoRemove JournalWriter.getLastEntry() 78/111478/2
Robert Varga [Mon, 22 Apr 2024 10:49:02 +0000 (12:49 +0200)]
Remove JournalWriter.getLastEntry()

We really do not want to retain a written entry -- and there is only a
single real user. Remove this method and update its sole caller.

JIRA: CONTROLLER-2115
Change-Id: Ibea3d820fa7d1daa023be1cdcc1a513720744b6e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
5 weeks agoRemove bierman02 terminology from dev guide 91/109291/10
Oleksandr Zharov [Mon, 11 Dec 2023 16:08:51 +0000 (17:08 +0100)]
Remove bierman02 terminology from dev guide

Updated dev guide terminology after bierman02 removal.

JIRA: CONTROLLER-2088
Change-Id: I6e77b54c4c2fe1629b4a1014944c26110735a075
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
5 weeks agoUse Netty to clean mapped buffers 73/111473/2
Robert Varga [Mon, 22 Apr 2024 08:20:31 +0000 (10:20 +0200)]
Use Netty to clean mapped buffers

Netty offers PlatformDependent.freeDirectBuffer(), use that to clean our
buffers.

Change-Id: Id737c9e951bc1c77376133d7053287e2840bafc6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoRefactor JournalReader.tryNext() 72/111472/6
Robert Varga [Sun, 21 Apr 2024 13:28:18 +0000 (15:28 +0200)]
Refactor JournalReader.tryNext()

We are usually translating an entry to an internal representation,
encode that in the API signature.

Since we have an API method to carry Indexed.* fields, we reduce our
reliance on this DTO. This leads to more efficient advance during reset,
as we do not need to instantiate Indexed instance.

JIRA: CONTROLLER-2115
Change-Id: I1d399e14997fb93b100397afab785778e47f985b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove JournalReader.getCurrentEntry() 71/111471/3
Robert Varga [Sun, 21 Apr 2024 12:51:20 +0000 (14:51 +0200)]
Remove JournalReader.getCurrentEntry()

JournalReader.currentEntry is just a single-entry cache which is not
used anywhere but tests. Remove the public method and private field.

While we are at it, make SegmentedJournalReader.tryNext() state
index management more obvious.

JIRA: CONTROLLER-2115
Change-Id: If92293e8393e71a4c1f402a0370973872a9593ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoCap index to sequenceNr before tryNext() 70/111470/3
Robert Varga [Sun, 21 Apr 2024 12:04:40 +0000 (14:04 +0200)]
Cap index to sequenceNr before tryNext()

Rather than relying on Indexed.index(), which requires us to attempt to
read the next entry, use a simple getNextIndex() check.

JIRA: CONTROLLER-2115
Change-Id: Id1d7638dda0d909b8383af8f1e201fb9e7f192e0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoFactor out FileWriter interface 86/111086/11
Robert Varga [Wed, 27 Mar 2024 00:15:59 +0000 (01:15 +0100)]
Factor out FileWriter interface

We have two specializations of JournalSegmentWriter just to provide
specialized write access. Factor out the require interface into
FileWriter and specialize that instead of JournalSegmentWriter.

JIRA: CONTROLLER-2100
Change-Id: Ie6a2497f49d7e1e00f32836cccbf0680b17b15e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
6 weeks agoSegmented journal benchmark 43/111143/5
Ruslan Kashapov [Fri, 29 Mar 2024 15:47:43 +0000 (17:47 +0200)]
Segmented journal benchmark

Performance test for sal-akka-segmented-journal moved
and refactored to standalone benchmark module, making
self-contained executable jar; 'benchmark' profile
executes benchmark via maven build using current
configuration (taken from sal-clustering-config)

JIRA: CONTROLLER-2114
Change-Id: I108f7aa99b089bdc1ae12b99fcc6ff4bf53bbd38
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
6 weeks agoFixup checkstyle 31/111431/2
Robert Varga [Tue, 16 Apr 2024 12:23:15 +0000 (14:23 +0200)]
Fixup checkstyle

Updated checkstyle is picking up a few new warnings. Fix them up.

Change-Id: Ib5fa92b84c7e4570098a1bd1163f0947a86ed7a9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoatomic-storage: remove type dependency at segment level I/O 17/111217/3
Ruslan Kashapov [Wed, 3 Apr 2024 09:53:20 +0000 (12:53 +0300)]
atomic-storage: remove type dependency at segment level I/O

Due to object de- and serialization was served by segment
I/O artifacts it required these artifacts holding serializer
instance and being dependent on its type (generics).

Moving serialization to upper level (journal) allows segment
reader/writer operate on byte level only with no extra data
conversions. Serializer interface simplified for further
isolation and removal of Kryo serializer.

JIRA: CONTROLLER-2115
Change-Id: I8f6bac3192a0f38b627150be4c8ea128f1e233e5
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoFix followerDistributedDataStore tear down 57/111357/1
lubos-cicut [Wed, 10 Apr 2024 08:48:50 +0000 (10:48 +0200)]
Fix followerDistributedDataStore tear down

Fix closing of followerDistributedDataStore in
DistributedDataStoreRemotingIntegrationTest#tearDown.

Change-Id: Iba35cae665f29a9da0430baff1f792191a4d1287
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
2 months agoBump versions to 9.0.3-SNAPSHOT 07/111107/1
Robert Varga [Wed, 27 Mar 2024 12:19:56 +0000 (13:19 +0100)]
Bump versions to 9.0.3-SNAPSHOT

This starts the next development iteration.

Change-Id: I4263aa380442f375497222c0c2050e2a585c6adf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoRelease controller v9.0.2
jenkins-releng [Wed, 27 Mar 2024 10:37:57 +0000 (10:37 +0000)]
Release controller

2 months agoDefer up to maxEntrySize flushes by default 00/111100/2
Robert Varga [Wed, 27 Mar 2024 04:09:55 +0000 (05:09 +0100)]
Defer up to maxEntrySize flushes by default

Batching flushes has performance benefits in terms of throughput.
Keeping the flush size at maxEntrySize makes the flush times more
consistent, as the journal's syncs will be amortized to fit writing
maxEntrySize'd entries.

JIRA: CONTROLLER-2108
Change-Id: Ie385738f65d9503fdeeed6a9e0b5ced37fde7fd3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoDo not use BufferOverflowException for EOF signalling 84/111084/2
Robert Varga [Tue, 26 Mar 2024 23:20:26 +0000 (00:20 +0100)]
Do not use BufferOverflowException for EOF signalling

A neat benefit of well-structured code is that it makes it clear what
the contracts are.

In this patch we eliminate a source of BufferOverflowExceptions and opt
to report the fact next segment is needed via a @Nullable return.

JIRA: CONTROLLER-2100
Change-Id: I1b9535053561709dc2a4b60446cd7cabd19da659
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoCentralize JournalSegmentWriter.append() 81/111081/3
Robert Varga [Tue, 26 Mar 2024 23:04:35 +0000 (00:04 +0100)]
Centralize JournalSegmentWriter.append()

We have almost-identical implementations of append(), differing only
slightly in how the do buffer management.

Expose a ByteBuffer-based API to writing to segment file, in terms of
abstract methods and pull the implementation down into the superclass.

JIRA: CONTROLLER-2100
Change-Id: I8d5629019d1c5d2978b0861e30e80346fbfc3c31
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoRename JournalSegment.index() 80/111080/3
Robert Varga [Tue, 26 Mar 2024 21:16:59 +0000 (22:16 +0100)]
Rename JournalSegment.index()

'index' is an overloaded term. firstIndex() is much more descriptive
than 'index()', which is easily confused with public API argument names.

JIRA: CONTROLLER-2100
Change-Id: I7848a6bb0e1e7b4a1c7f63c8e6db5b02bd0dab76
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoUnify JournalSegmentWriter.truncate() 79/111079/3
Robert Varga [Tue, 26 Mar 2024 20:59:30 +0000 (21:59 +0100)]
Unify JournalSegmentWriter.truncate()

Implementations of truncate are practically identical, merge them into a
common method. Also eliminate JournalSegmentWriter.firstIndex, as we can
get it from the segment at any time.

JIRA: CONTROLLER-2100
Change-Id: I019978461b67693f109cd6e90c8fba2ed8b18a3f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoUnify JournalSegmentWriter.reset(long) 78/111078/3
Robert Varga [Tue, 26 Mar 2024 20:43:19 +0000 (21:43 +0100)]
Unify JournalSegmentWriter.reset(long)

We have two distinct implementations here. The version for
StorageLevel.DISK is generic enough to work for StorageLevel.MAPPED, and
will guarantee consistency with reader implementation (which is already
shared across StorageLevels).

JIRA: CONTROLLER-2100
Change-Id: I3e9a5c8a72be766431e5cb527cae1f4809964dd7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoRework MappedJournalSegmentWriter position tracking 77/111077/4
Robert Varga [Tue, 26 Mar 2024 20:03:48 +0000 (21:03 +0100)]
Rework MappedJournalSegmentWriter position tracking

Use an internal field to track the position. Also align entry reading
logic by slicing the appropriate buffer.

JIRA: CONTROLLER-2100
Change-Id: Iaa36fb32d9ffb7b215bef7829f8d3e7e5728e4b9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoFix SegmentEntry license 85/111085/1
Robert Varga [Wed, 27 Mar 2024 00:14:56 +0000 (01:14 +0100)]
Fix SegmentEntry license

All this code is Apache-2 licensed, fix the header.

JIRA: CONTROLLER-2109
Change-Id: If0604f566c43a844da4522c2274a3b1a9f308a03
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoFix reader/writer buffer sharing 83/111083/1
Robert Varga [Tue, 26 Mar 2024 23:46:44 +0000 (00:46 +0100)]
Fix reader/writer buffer sharing

DiskFileReaders should share the buffer with with their writers.

JIRA: CONTROLLER-2109
Change-Id: I79203b7111827cd1b9885956fc6ca98bf621a12a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoShorten currentPosition 76/111076/2
Robert Varga [Tue, 26 Mar 2024 19:17:44 +0000 (20:17 +0100)]
Shorten currentPosition

Our current file position is limited to 2^31-1, hence we can safely use
an int instead of a long. This is what StorageLevel.MAPPED needs anyway.

JIRA: CONTROLLER-2100
Change-Id: Idddea88cdc031f515675a39afb64115ded39fe0b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoAllow segmented journal to flush periodically 80/110880/5
Robert Varga [Tue, 19 Mar 2024 20:42:14 +0000 (21:42 +0100)]
Allow segmented journal to flush periodically

Flushes to disk end up dominating our use of disk resources, as we issue
a flush after each write. This is not entirely efficient, as we may have
multiple outstanding writes in the actor queue -- and we ignore the
batching opportunity.

This patch makes it possible to configure an upper bound of the number
of outstanding bytes written which can remainin unflushed.

We flush whenever we reach this watermark or when we flush all messages
that have been submitted at the time the flush batch has been started.

JIRA: CONTROLLER-2108
Change-Id: I6f18de7871c89b5feffecc71580e1f440024f2a3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoRename patched ByteBufferInput 08/111008/5
Robert Varga [Mon, 25 Mar 2024 08:47:22 +0000 (09:47 +0100)]
Rename patched ByteBufferInput

Hide the patched version and renake it to Kryo505ByteBufferInput.

JIRA: CONTROLLER-2109
Change-Id: Ie2b50dab13f1ae93e343f18acf4a05a890616576
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoDeploy fix of ByteBufferInput and use it 07/111007/12
Robert Varga [Mon, 25 Mar 2024 08:24:52 +0000 (09:24 +0100)]
Deploy fix of ByteBufferInput and use it

readAscii() just wants to fix up the last byte it passes to the String
constructor. Do that after reading.

Inherit everything alse that is not required from the regular
ByteBufferInput to minimize code duplication.

JIRA: CONTROLLER-2109
Change-Id: Ic12b8e06317a8376b34d514daaf1ba7d46d16178
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoUnify Disk segment reading 03/111003/10
Robert Varga [Sat, 23 Mar 2024 23:52:08 +0000 (00:52 +0100)]
Unify Disk segment reading

DiskJournalSegmentWriter contains code duplicating DiskFileReader. Let's
remediate the situation by having an internal DiskFileReader, through
which we access the file in a read-only manner.

JIRA: CONTROLLER-2109
Change-Id: I0a5ffd1aebbea71513f6cd70e2138562755316fa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoAdd almost-verbatim kryo.io.ByteBufferInput from kryo-4.0.3 06/111006/7
Robert Varga [Mon, 25 Mar 2024 08:15:58 +0000 (09:15 +0100)]
Add almost-verbatim kryo.io.ByteBufferInput from kryo-4.0.3

We are about to address a deeply-seated problem. Import souces almost
verbatim. Changes:
- inline MAX_SAFE_ARRAY_SIZE
- different package
- CR/LF changed
- javadoc corrected

JIRA: CONTROLLER-2109
Change-Id: I56cbaa7e541d9e78025095cb86effae8f97883c6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoLower reader buffering 02/111002/8
Robert Varga [Sat, 23 Mar 2024 22:41:35 +0000 (23:41 +0100)]
Lower reader buffering

We are choosing buffer for two entries. This is a legacy choice, when we
could not compact our buffer and is actively hostile to large
maxEntrySize.

At the end of the day we really need space for one full entry. Since we
are being smart re. buffer management, we do not need the doubled buffer
size -- so allocate just what we need.

One exemption is when the buffer would be less than 8KiB -- in that case
just do not bother and cache up to 8KiB as needed.

JIRA: CONTROLLER-2109
Change-Id: Ic03df7e271e59588608f07c097b3831db83d7bd7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoFactor out FileReader interface 01/111001/5
Robert Varga [Sat, 23 Mar 2024 21:52:25 +0000 (22:52 +0100)]
Factor out FileReader interface

As it turns out, JournalSegmentReader's specializations are providing a
very simple API they provide via abstract methods.

Extract this API into FileReader, allowing JournalSegmentReader to
become a final class, reducing mental requirements to understand what is
going on.

JIRA: CONTROLLER-2109
Change-Id: I4199f10a9483b18ac381f16e2b0d818f2d74ac16
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoRemove JournalReader.getCurrentIndex() 05/111005/3
Robert Varga [Mon, 25 Mar 2024 07:34:32 +0000 (08:34 +0100)]
Remove JournalReader.getCurrentIndex()

This method is used only in tests and has the weird 'or 0' return.
Refactor test asserts and remove this method.

Change-Id: If397f2398e75d08de867cf4c674a1dd14e8add30
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoRefactor JournalSegmentReader 00/111000/6
Robert Varga [Sat, 23 Mar 2024 21:00:34 +0000 (22:00 +0100)]
Refactor JournalSegmentReader

We have almost-duplicated code in {Disk,Mapped}JournalSegmentReader,
which looks very similar to what DiskJournalSegmentWriter revolves
around.

JournalSegmentReader revolves around tracking current position and
interpreting bytes read. Its specializations provide the means for
access.

JIRA: CONTROLLER-2109
Change-Id: I80b78cde5baf6b222d888e635dd5c854331f261a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoDo not use ByteBufferInput 04/111004/4
Robert Varga [Mon, 25 Mar 2024 07:05:59 +0000 (08:05 +0100)]
Do not use ByteBufferInput

ByteBufferInput ends up calling ByteBuffer.put() in readAscii(). Work
this around by integrating through InputStream. Not exactly nice, but
the best we can do right now.

JIRA: CONTROLLER-2109
Change-Id: I182c3cefb97ada0cd9fdc2b7440256f38341df5a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoMove entry tracking to SegmentedJournalReader 98/110998/10
Robert Varga [Sat, 23 Mar 2024 13:51:23 +0000 (14:51 +0100)]
Move entry tracking to SegmentedJournalReader

We have duplicated state tracking just because JournalSegmentReader used
to provide the same API as SegmentedJournalReader.

Rehost tracking the next index and current entry into
SegmentedJournalReader, making it more obvious as to what is going on.

This allows Indexed to enforce the entry being non-null, as we do not
have to use a fake entry anymore.

JIRA: CONTROLLER-2109
Change-Id: I9ebd50fde94d695bb62315bba1b6adb1235b37f1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoSimplify JournalSegmentReader entry access 99/110999/1
Robert Varga [Sat, 23 Mar 2024 12:27:22 +0000 (13:27 +0100)]
Simplify JournalSegmentReader entry access

The only user is SegmentedJournalReader, which is using these methods to
implement its tryNext() operation.

Mirror this with JournalSegmentReader.tryNext(), which simplifies some
of the logic.

JIRA: CONTROLLER-2109
Change-Id: Id104743b16199b4734b322d1397b85280f03346b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoJournalIndex.truncate() should return last entry 49/110949/1
Robert Varga [Thu, 21 Mar 2024 08:47:32 +0000 (09:47 +0100)]
JournalIndex.truncate() should return last entry

The only time we are calling truncate(), we are following up with a seek
to the appropriate entry.

Return the last indexed position from truncate(), so we can do better
than a linear search.

JIRA: CONTROLLER-2109
Change-Id: I701b0eefbf1f4d83f74ba95b93c41407289d95cb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoMove ENTRY_HEADER_BYTES 07/110907/1
Robert Varga [Wed, 20 Mar 2024 15:52:24 +0000 (16:52 +0100)]
Move ENTRY_HEADER_BYTES

We have SegmentEntry.HEADER_BYTES instead of ENTRY_HEADER_BYTES.

JIRA: CONTROLLER-2109
Change-Id: I4bc66155dccd3e177a61bad28be50e0bc62827ab
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoIntroduce SegmentEntry 96/110896/4
Robert Varga [Wed, 20 Mar 2024 00:52:54 +0000 (01:52 +0100)]
Introduce SegmentEntry

This is a helper DTO to communicate CRC32 and a buffer slice during
DiskJournalSegmentWriter's indexing.

This allows us improve the reset(long) loop to a manageable size, which
is mostly self-explanatory.

JIRA: CONTROLLER-2109
Change-Id: Ife1bddaf7684a304a0e7cdfd24ca9e774ac5143d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoImprove disk entry access 10/110810/5
Robert Varga [Sun, 17 Mar 2024 11:22:10 +0000 (12:22 +0100)]
Improve disk entry access

Eliminate superfluous compactions while a complete entry is available.
This is done by carefully looking at the buffer and figuring out how
many bytes we actually need progress.

JIRA: CONTROLLER-2109
Change-Id: If091b5c6f74da6a989629dae49137ed492725e2d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoSegmentJournal.log is static 97/110897/2
Robert Varga [Wed, 20 Mar 2024 01:16:42 +0000 (02:16 +0100)]
SegmentJournal.log is static

This is derived from getClass() on a final class -- hence we can
amortize the logger into a static field, from whence it will be
constant-propagated.

Change-Id: Idcc6cf2d86c5ae687694fa5c16089687ac4a949a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoDelete test directories after test 42/110842/1
Robert Varga [Mon, 18 Mar 2024 11:47:18 +0000 (12:47 +0100)]
Delete test directories after test

We have files in target being archived. Remove them after the test
finishes.

Change-Id: I68ea84a78e82bffcc3d8e0868b2f492759f64f90
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoBump versions to 9.0.2-SNAPSHOT 76/110776/1
Robert Varga [Fri, 15 Mar 2024 16:07:51 +0000 (17:07 +0100)]
Bump versions to 9.0.2-SNAPSHOT

This starts the next deveopment iteration.

Change-Id: I5940bc14b5261316778f547b0111b62b3a983bdb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoRelease controller v9.0.1
jenkins-releng [Fri, 15 Mar 2024 14:14:17 +0000 (14:14 +0000)]
Release controller

2 months agoChange FileChannel prefix to Disk 51/110751/1
Robert Varga [Fri, 15 Mar 2024 12:26:10 +0000 (13:26 +0100)]
Change FileChannel prefix to Disk

We use FileChannelJournalSegment{Reader,Writer} for StorageLevel.DISK,
and Mapped* for StorageLevel.MAPPED.

Fix this by a quick rename to DiskJournaSegment{Reader,Writer},
improving internal consistency and shortening class names.

Change-Id: Ia6d7311ed93527ff77cde3f7b57bb34689f962cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoAdd PANTHEON.tech copyright headers 50/110750/2
Robert Varga [Fri, 15 Mar 2024 12:20:47 +0000 (13:20 +0100)]
Add PANTHEON.tech copyright headers

These files have been significantly altered and hence deserve a
contributor copyright with a fresh year.

JIRA: CONTROLLER-2105
Change-Id: Ieceb00a54d204db5ba8bb92971a719f2b0815c59
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoNormalized copyright header 49/110749/2
Robert Varga [Fri, 15 Mar 2024 12:10:18 +0000 (13:10 +0100)]
Normalized copyright header

Use a closed range and our standard 'and others' moniker.

JIRA: CONTROLLER-2105
Change-Id: I868b02415666da378f395ff711d5092a334d0196
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoFuther improvements to ByteBuffer invocations 48/110748/1
Robert Varga [Fri, 15 Mar 2024 11:13:18 +0000 (12:13 +0100)]
Futher improvements to ByteBuffer invocations

MappedJournalSegmentWriter should take advantage of fluent APIs of
ByteBuffer.

JIRA: CONTROLLER-2097
Change-Id: If12fe247bd08db450e00ea9878ecfafb7f75596b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoCentralize entry header size 47/110747/1
Robert Varga [Fri, 15 Mar 2024 11:09:13 +0000 (12:09 +0100)]
Centralize entry header size

We jave 'Integer.BYTES + Integer.BYTES' strewn all across the code,
centralize this constant into a single place.

JIRA: CONTROLLER-2098
Change-Id: If15f944db20b01767ca387f652ddf11fed64e2fa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoMake JournalSegmentWriter.getNextIndex() final 46/110746/1
Robert Varga [Fri, 15 Mar 2024 10:11:11 +0000 (11:11 +0100)]
Make JournalSegmentWriter.getNextIndex() final

We have duplicated code between the two implementations. Centralize it
to the common superclass.

JIRA: CONTROLLER-2098
Change-Id: I84b1a1d716c2ccbaaf2f75e3728bcbad0aa05ec6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoMake JournalSegmentWriter.getLastIndex() final 45/110745/1
Robert Varga [Fri, 15 Mar 2024 10:05:21 +0000 (11:05 +0100)]
Make JournalSegmentWriter.getLastIndex() final

We have duplicated code between the two implementations. Centralize it
to the common superclass.

JIRA: CONTROLLER-2098
Change-Id: I805e882566d8f891c23a1f25143d453c94284cd1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoImprove ByteBuffer invocations 44/110744/1
Robert Varga [Fri, 15 Mar 2024 09:58:55 +0000 (10:58 +0100)]
Improve ByteBuffer invocations

ByteBuffer has a fluent API, returning the same buffer from methods
which do not return something else.

Take advantage of this a chain invocations, resulting in denser byte
code.

JIRA: CONTROLLER-2097
Change-Id: Ic744e5e4f4d8c3fec5026f9d7edc58b7a5387c0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoImprove FileChannelJournalSegmentWriter's buffer management 35/110735/3
Oleksandr Zharov [Thu, 14 Mar 2024 13:46:11 +0000 (14:46 +0100)]
Improve FileChannelJournalSegmentWriter's buffer management

Minor refactor of logic in FileChannelJournalSegmentWriter class.
Removed unnecessary buffer clearing after each entry. New logic
remove already proccesed entry from the buffer and if needed reads
new data from FileChannel to it's capacity.

JIRA: CONTROLLER-2097
Change-Id: I571d531437b068cd468bdc92b3ab6a4223450a45
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
2 months agoUse correct JournalSegmentWriter for initial indexing 40/110740/1
Robert Varga [Fri, 15 Mar 2024 08:11:41 +0000 (09:11 +0100)]
Use correct JournalSegmentWriter for initial indexing

JournalSegment should look at StorageLevel and pick the appropriate
writer instead of always using FileChannelJournalSegment.

JIRA: CONTROLLER-2099
Change-Id: I060618a2808a837214b5ae61f4860f329c1799f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoRemove LeaderLocationListenerRegistration 33/110733/2
Robert Varga [Thu, 14 Mar 2024 10:34:27 +0000 (11:34 +0100)]
Remove LeaderLocationListenerRegistration

This specialization is not used anywhere, remove it and adjust
LeaderLocationListener.

Change-Id: Ic6a738b2b34ecaca980fb222fb363ef391f24b1a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoMigrate users of deprecated methods 32/110732/2
Robert Varga [Thu, 14 Mar 2024 10:24:05 +0000 (11:24 +0100)]
Migrate users of deprecated methods

Updated yangtools/mdsal are providing a few more convenient methods, use
those instead of their deprecated equivalents.

Change-Id: I6a971e349dc7d5aed00697c179dfa0c37afa8209
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoBump upstreams 31/110731/1
Robert Varga [Thu, 14 Mar 2024 08:48:54 +0000 (09:48 +0100)]
Bump upstreams

Adopt:
- odlparent-13.0.11
- yangtools-13.0.1
- mdsal-13.0.0

Change-Id: I33bbfb6a9016ae13cfaba8d95bf461f8167621eb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoJournalReader is not an Iterator 94/110694/2
Robert Varga [Wed, 13 Mar 2024 12:32:07 +0000 (13:32 +0100)]
JournalReader is not an Iterator

Iterator dictating a two method API, which is not quite appropriate, as
the writer could be manipulated between hasNext() and next() methods --
and next() has to perform validation again.

Introduce JournalReader.tryNext(), which returns a @Nullable Indexed --
either the next entry (as next()), or null (indicating !hasNext() case).

JIRA: CONTROLLER-2106
Change-Id: Ie0338a9869ece8e6381ae719a29e97fd569b442f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoCatch JournalReader.next() violations in Mode.COMMITS 90/110690/1
Robert Varga [Wed, 13 Mar 2024 09:39:30 +0000 (10:39 +0100)]
Catch JournalReader.next() violations in Mode.COMMITS

JournalReader.next() is specified as an Iterator and should be throwing
NSEs. This is not the case when we ask for only commits, as the
corresponding check is done only in hasNext() and thus we would give out
uncommitted entries.

Fix this by adding an override to check for this condition.

JIRA: CONTROLLER-2106
Change-Id: I1f391cc19b9674646786c93656b83519e0f1f47b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoUse try-with-resources in testCompactAndRecover 89/110689/1
Robert Varga [Wed, 13 Mar 2024 09:24:36 +0000 (10:24 +0100)]
Use try-with-resources in testCompactAndRecover

Eclipse is flagging a warning here, make sure we silence it.

Change-Id: I7bfa9d490e8b9b71bf04511bc42d6d101345b179
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoCache reader's nextIndex during reset() 88/110688/1
Robert Varga [Wed, 13 Mar 2024 08:50:03 +0000 (09:50 +0100)]
Cache reader's nextIndex during reset()

JournalSegmentReader.getNextIndex() involves some computation, so do not
call it twice when deciding how to reset SegmentedJournalReader.

JIRA: CONTROLLER-2106
Change-Id: I7527d8f0c47d35b7a59c30558715204a85b24eae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoRemove JournalSegmentReader.getCurrentIndex() 87/110687/1
Robert Varga [Wed, 13 Mar 2024 07:45:42 +0000 (08:45 +0100)]
Remove JournalSegmentReader.getCurrentIndex()

This method is only ever called by SegmentedJournalReader, inline it
there. This removes one source of the magic 0 index.

JIRA: CONTROLLER-2106
Change-Id: I0fcb16e806d027d22f8e6370788aab21884c9e71
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoModernize Indexed 83/110683/3
Robert Varga [Tue, 12 Mar 2024 21:17:44 +0000 (22:17 +0100)]
Modernize Indexed

Indexed.getType() is not used anywhere, hence remove it. While we are
here, also turn the class into a record, as it is a pure DTO.

Also add a FIXME to require the actual entry to be non-null.

JIRA: CONTROLLER-2101
Change-Id: I8bd42a815096a3d0993eb41c59cf39655a7ed0fd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>