controller.git
6 weeks agoMove SnapshotBytes propagation 94/115994/2
Robert Varga [Sat, 22 Mar 2025 12:57:41 +0000 (13:57 +0100)]
Move SnapshotBytes propagation

We no longer need a Snapshot, hence we can move the propagation logic to
the single method which is invoking it.

JIRA: CONTROLLER-2134
Change-Id: I87544711d1a69825fa920f23c2893d58f757c753
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRefactor SendInstallSnapshot 93/115993/1
Robert Varga [Sat, 22 Mar 2025 12:48:24 +0000 (13:48 +0100)]
Refactor SendInstallSnapshot

SendInstallSnapshot contains a Snapshot, from which we only extract last
applied index/term to instantiate SnapshotHolder.

Merge SendInstallSnapshot and SnapshotHolder into a replacement class
called SnapshotBytes and adjust callers accordingly -- making the
contract simpler and easier to test.

JIRA: CONTROLLER-2134
Change-Id: I3d23176dda2322595679b4854cb8dabfb8d480f7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoDo not use Optional for snapshotHolder 92/115992/1
Robert Varga [Sat, 22 Mar 2025 12:13:02 +0000 (13:13 +0100)]
Do not use Optional for snapshotHolder

We are in complete control of the lifecycle here, so Optional does not
provide any benefit. Ditch it and use a simple field.

JIRA: CONTROLLER-2134
Change-Id: I199a7d21fbec3adec9092024c6e5ca05376a5b9a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoClean up SnapshotHolder 91/115991/3
Robert Varga [Sat, 22 Mar 2025 11:48:15 +0000 (12:48 +0100)]
Clean up SnapshotHolder

The holder does not need a full snapshot and can be a simple record.
Also refactor test methods to hide it.

JIRA: CONTROLLER-2134
Change-Id: I84de057724003f844f0cb20aa60a32228298836c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoMove SendInstallSnapshot 90/115990/2
Robert Varga [Sat, 22 Mar 2025 11:31:33 +0000 (12:31 +0100)]
Move SendInstallSnapshot

This class is used only by AbstractLeader, move it there and modernize
it.

JIRA: CONTROLLER-2134
Change-Id: I09282c69b029b3b7f52ad6024aafbf656b4dfa84
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove ReplicatedLogImpl.create() 88/115988/1
Robert Varga [Sat, 22 Mar 2025 10:50:13 +0000 (11:50 +0100)]
Remove ReplicatedLogImpl.create()

Turn the two methods into simple constructors, updating callers.

JIRA: CONTROLLER-2134
Change-Id: I0d3a7836ae469363d7953eaffffe24d384eae3ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoAnnotate SnapshotManger.memberId() 87/115987/1
Robert Varga [Sat, 22 Mar 2025 10:44:20 +0000 (11:44 +0100)]
Annotate SnapshotManger.memberId()

Returned String cannot be null, annotate that fact.

Change-Id: Ic7148a054309df557b99267f5cff74a21f548abe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoInline memberId in CandidateTest 86/115986/2
Robert Varga [Sat, 22 Mar 2025 10:37:47 +0000 (11:37 +0100)]
Inline memberId in CandidateTest

We have a few stray callers to RaftActorContext.getId(), inline the
"candidate" memberId.

JIRA: CONTROLLER-2134
Change-Id: I33220c222e0eacb300cb5306e0a218068f57bda6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoInline FollowerTest memberId checks 85/115985/2
Robert Varga [Sat, 22 Mar 2025 10:32:05 +0000 (11:32 +0100)]
Inline FollowerTest memberId checks

We are using RaftActorContext.get() to arrive at the constant "follower"
-- inline it instead.

JIRA: CONTROLLER-2134
Change-Id: If427fe33fb5b4e5ffb8032d6647223e05d16c5ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRename RaftActorBehavior.getId() 84/115984/2
Robert Varga [Sat, 22 Mar 2025 10:27:13 +0000 (11:27 +0100)]
Rename RaftActorBehavior.getId()

We are using memberId() in other place, let's make sure to be
consistent. We also update callers of RaftActorContext.getId() to use
this method where possible.

JIRA: CONTROLLER-2134
Change-Id: If9afee1c546a60073e182f1af23a67a0c1e77fa9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoClean up CandidateTest a bit 83/115983/1
Robert Varga [Sat, 22 Mar 2025 10:26:11 +0000 (11:26 +0100)]
Clean up CandidateTest a bit

MessageCollectorActor.expectFirstMatching() calls can be a single-line
affair, do that.

Change-Id: I4fd6e68225d4e8d5a137212473c7df339241a5f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoReduce calls to RaftActorContext.getId() 82/115982/1
Robert Varga [Sat, 22 Mar 2025 10:01:21 +0000 (11:01 +0100)]
Reduce calls to RaftActorContext.getId()

RaftActorRecoverySupport has LocalAccess, hence we can get memberId from
there.

RaftActorServerConfigurationSupport has RaftActor, so let's get memberId
from there.

JIRA: CONTROLLER-2134
Change-Id: I78da1043ee8e52cac987fdbc66d5b3bdc1073a51
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove Snapshot.getElection{Term,VotedFor} 80/115980/1
Robert Varga [Sat, 22 Mar 2025 09:07:25 +0000 (10:07 +0100)]
Remove Snapshot.getElection{Term,VotedFor}

These methods are not used anywhere, remove them.

Change-Id: I5e0cf0d1979a7792651b6721453cdac6073b5b01
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoModernize CaptureSnapshot 79/115979/1
Robert Varga [Sat, 22 Mar 2025 08:57:45 +0000 (09:57 +0100)]
Modernize CaptureSnapshot

Use List.of() and make the class final.

Change-Id: I3b23bf4d0ef600ce6117e1b0bdd51e607df95c27
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove SnapshotManager.computeLastAppliedEntry() 77/115977/5
Robert Varga [Sat, 22 Mar 2025 02:41:34 +0000 (03:41 +0100)]
Remove SnapshotManager.computeLastAppliedEntry()

This method has a single caller, inline it.

JIRA: CONTROLLER-2134
Change-Id: Ife65ee3cdd3415476004d7b950801206e825f5f3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoSplit up computeLastAppliedEntry() 76/115976/2
Robert Varga [Fri, 21 Mar 2025 19:31:41 +0000 (20:31 +0100)]
Split up computeLastAppliedEntry()

There are two distinct cases here: we either have followers or we do
not. Split the two cases into separate methods.

JIRA: CONTROLLER-2134
Change-Id: Ice6247f29f30ca7382d4c6c95a3ff40b9c486585
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoSwitch AbstractReplicatedLogTest to JUnit5 75/115975/2
Robert Varga [Fri, 21 Mar 2025 18:48:28 +0000 (19:48 +0100)]
Switch AbstractReplicatedLogTest to JUnit5

This is trivial conversion.

Change-Id: I76a065c7a6de9d9478d9d6ddc47eb0c8b054d719
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoSplit out MockReplicatedLog 74/115974/2
Robert Varga [Fri, 21 Mar 2025 18:40:36 +0000 (19:40 +0100)]
Split out MockReplicatedLog

This class deserves to be outside of the test class, simplifying its
name.

JIRA: CONTROLLER-2134
Change-Id: I39052e6f4b6cf05dddbc025b2898239a1ff2d24d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoMove SnapshotManager.computeLastAppliedEntry() 73/115973/2
Robert Varga [Fri, 21 Mar 2025 18:37:53 +0000 (19:37 +0100)]
Move SnapshotManager.computeLastAppliedEntry()

This method is tightly coupled to a ReplicatedLog and independent of
SnapshotManager. Move it to AbstractReplicatedLog for further evolution.

JIRA: CONTROLLER-2134
Change-Id: Ic87e4896094c166ff53a62c0d56eb1a0fbf38b1f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoModernuze FollowerInitialSyncUpStatus 72/115972/2
Robert Varga [Fri, 21 Mar 2025 17:12:48 +0000 (18:12 +0100)]
Modernuze FollowerInitialSyncUpStatus

This message should be just a plain record. Also clean up the
SyncStatusTracker internals to improve the logic, coupled with a
long-overdue clean up of SyncStatusTrackerTest.

Change-Id: If0cc3c838e433ba87fe614327f289ae2b0aa39ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoHide SyncStatusTracker 71/115971/2
Robert Varga [Fri, 21 Mar 2025 16:45:24 +0000 (17:45 +0100)]
Hide SyncStatusTracker

This class is only used by Follower, hence it does not need to be
exposed outside of the package.

Change-Id: I9e770e2c4b9fdc78d44aef8015c5e42d43f5f0dd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoLock down Follower 70/115970/2
Robert Varga [Fri, 21 Mar 2025 16:36:06 +0000 (17:36 +0100)]
Lock down Follower

Do not allow overriding methods other than those the tests need.

Change-Id: I0ab961116d1ee3be82060a821363f1905d51ff32
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoImprove AbstractLeader class hierarchy 69/115969/2
Robert Varga [Fri, 21 Mar 2025 16:29:03 +0000 (17:29 +0100)]
Improve AbstractLeader class hierarchy

AbstractLeader.handleAppendEntriesReply() always results in 'this' being
returned and is overridden in the three subclasses.

Rename it to processAppendEntriesReply(), without the ability to change
behavior and make it final. The subclasses then use it as a common
utility, doing their own thing as needed.

Since Leader is subclassed in tests, we lock down all its methods except
the single one that is being overridden.

Change-Id: I594bebedfa612f7e946d97040ea55c053c2c9f3d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoImprove sal-akka-raft test assertions 68/115968/2
Robert Varga [Fri, 21 Mar 2025 16:08:03 +0000 (17:08 +0100)]
Improve sal-akka-raft test assertions

We have a number of assertions which just check RaftState value -- but
we really should be checking which behaviour we are servicing.

Change-Id: If2a9d898b0e237e7c1886d298c4584b94149f65e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRefactor SwitchBehavior 67/115967/2
Robert Varga [Fri, 21 Mar 2025 15:29:36 +0000 (16:29 +0100)]
Refactor SwitchBehavior

We only support switching to leader or to follower, whereas our messages
allow for any RaftState -- leading to us needing to place explicit
guards.

This patch makes SwitchBehavior a sealed interface with two possible
specializations: BecomeFollower and BecomeLeader. The result is more
expressive code without the need for RaftActorBehavior.createBehavior()
dispatch.

Change-Id: Ib9da61012f1814ef6786992aa2ddbe1d2c72040a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoReduce use of getRaftActorContext()() 66/115966/2
Robert Varga [Fri, 21 Mar 2025 14:41:42 +0000 (15:41 +0100)]
Reduce use of getRaftActorContext()()

Internal use here is just plain clutter. Fix that.

Change-Id: I826424aac10f00f1162e5909f579238044b46985
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoHide RaftActorBehaviour.switchBehavior() 65/115965/2
Robert Varga [Fri, 21 Mar 2025 14:34:31 +0000 (15:34 +0100)]
Hide RaftActorBehaviour.switchBehavior()

Eliminate indirection through RaftState, allowing us to use a single
method for switching behaviors.

Change-Id: I90ff03ed1dc6f82d8b1d917ff6c7ab97cd474ff1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoClean up Follower reinitialization 64/115964/2
Robert Varga [Fri, 21 Mar 2025 14:04:31 +0000 (15:04 +0100)]
Clean up Follower reinitialization

Use an instanceof pattern to talk directly to Follower to obtain a copy
-- making it a tad cleaner.

Change-Id: I34213d4d690a6bdce96febd6e2f51d77ee14effd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoLock down behaviors 63/115963/2
Robert Varga [Fri, 21 Mar 2025 13:49:47 +0000 (14:49 +0100)]
Lock down behaviors

A number of improvements:
- hide constructors
- enforce leader transitions
- make IsolaterLeader/PreLeader final

Change-Id: I54101d56af4a7b99051d14444c01d39bf2c35c6f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoButton down ShardSnapshotCohort 62/115962/3
Robert Varga [Fri, 21 Mar 2025 12:54:53 +0000 (13:54 +0100)]
Button down ShardSnapshotCohort

The output stream is now always non-null: button this down, simplifying
things a little bit.

JIRA: CONTROLLER-2134
Change-Id: I339c13742e4b7e02b353c2a5fd8d879deb28bb29
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove SnapshotManager.convertSnapshot() 61/115961/1
Robert Varga [Fri, 21 Mar 2025 10:39:21 +0000 (11:39 +0100)]
Remove SnapshotManager.convertSnapshot()

This is a useless indirection, just inline it into the single caller.

JIRA: CONTROLLER-2134
Change-Id: I87830a1e57623c630de037c8bfe345792c33b398
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRequire output stream 59/115959/2
Robert Varga [Thu, 20 Mar 2025 21:35:36 +0000 (22:35 +0100)]
Require output stream

Make sure we specialize createSnapshot() to be the alternative to
takeSnapshot().

Change-Id: I75caf958c6bf2969dc2fd604508b08cbc1e670a4
JIRA: CONTROLLER-2134
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoUse takeSnapshot() in normal stream captures 51/115951/9
Robert Varga [Thu, 20 Mar 2025 15:10:49 +0000 (16:10 +0100)]
Use takeSnapshot() in normal stream captures

We only need asynchronous callout during captureToInstall(), otherwise
we can use the much simpler interface, which does not need a turnaround
through CaptureSnapshotReply.

This necessitates a bit of an update to the test suites, where we switch
from capture() to captureToInstall() to catch the negative scenarios.

Integration-level tests need to be updated as well: since we now invoke
persist() directly, we need to fiddle with SaveSnapshotSuccess instead
of CaptureSnapshotReply.

JIRA: CONTROLLER-2134
Change-Id: I18ffb7c062f52474d5df3c581d997072dac04e0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoFix ShardTest capture trigger 60/115960/1
Robert Varga [Fri, 21 Mar 2025 10:07:57 +0000 (11:07 +0100)]
Fix ShardTest capture trigger

The test here operates on a live actor, but it invokes
ShardManager.capture() outside of actor confinement. This means that if
any processing in ShardManager decides to send a message to the actor,
the actor will process asynchronously.

Fix this by tickling ShardManager via executeInSelf().

Change-Id: I6a26d98b14ee2d4101f8b036a573baa41d5148ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoOverride takeSnapshot() in mocks 58/115958/1
Robert Varga [Thu, 20 Mar 2025 16:48:12 +0000 (17:48 +0100)]
Override takeSnapshot() in mocks

We have two specialized mocks, which override default forwarding
behaviour of MockRaftActor.createSnapshot(). This adds overrides of
takeSnapshot(), so that the behaviour matches.

JIRA: CONTROLLER-2134
Change-Id: Idde23e1ba42d98b7f228546b25b03063ba3998ba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoClean up whitespace 57/115957/1
Robert Varga [Thu, 20 Mar 2025 16:45:39 +0000 (17:45 +0100)]
Clean up whitespace

We have an a superfluous empty line and a space -- remove both.

Change-Id: Ib915c8ddab13eaee39ccc0252b26eb711aa41664
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoEnforce Snapshot consistency 55/115955/1
Robert Varga [Thu, 20 Mar 2025 16:06:54 +0000 (17:06 +0100)]
Enforce Snapshot consistency

Make sure we do not allow nulls where inappropriate.

Change-Id: Ibb3f664f4702b6f8e87ac67b9450f63c7d3b21de
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoClean up ternary operator use 54/115954/1
Robert Varga [Thu, 20 Mar 2025 16:05:34 +0000 (17:05 +0100)]
Clean up ternary operator use

The colon should be on a new line, fix that.

Change-Id: I4d4a51664495bc6d949429c7b4f1d60c66994d63
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove unused logger 53/115953/1
Robert Varga [Thu, 20 Mar 2025 16:05:09 +0000 (17:05 +0100)]
Remove unused logger

We are not using this logger anymore, remove it.

Change-Id: I38a6749dcc02cd7cc19c86c81f0b2c1c98a435bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove GetSnapshot.timeout() 50/115950/1
Robert Varga [Thu, 20 Mar 2025 14:27:13 +0000 (15:27 +0100)]
Remove GetSnapshot.timeout()

We are using takeSnapshot(), which means there is absolutely no point in
propagating the timeout.

What we do instead is we use the specified timeout for Patterns.ask(),
which actually leads to a more correct behaviour.

JIRA: CONTROLLER-2134
Change-Id: I2b3fdd9af695df31562a2c620735544721c0e078
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoUse takeSnapshot() to service GetSnapshot 49/115949/1
Robert Varga [Thu, 20 Mar 2025 14:07:28 +0000 (15:07 +0100)]
Use takeSnapshot() to service GetSnapshot

The code to service GetSnapshot requests does not serialize the snapshot
itself: use takeSnapshot() to service it.

This renders GetSnapshotReplyActor superfluous, hence we remove it as
well as timeout tests.

JIRA: CONTROLLER-2134
Change-Id: Iabeb1a042fa3410d31d4c1f0298b3dedb8cafc72
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoAdd RaftActorSnapshotCohort.takeSnapshot() 48/115948/1
Robert Varga [Thu, 20 Mar 2025 13:54:12 +0000 (14:54 +0100)]
Add RaftActorSnapshotCohort.takeSnapshot()

We only have a complicated way of acquiring snapshots, but there are use
cases, where we actually want to to take a snapshot without serializing
it -- which can be a convenient synchronous operation.

This patch adds that takeSnapshot(), which is much easier to use.

JIRA: CONTROLLER-2134
Change-Id: If0a0af0b21e8a90a06eff14f3a23772d3af07450
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoReduce use of context.getId() 47/115947/1
Robert Varga [Thu, 20 Mar 2025 12:34:38 +0000 (13:34 +0100)]
Reduce use of context.getId()

We have memberId() available, use that instead of getId().

Change-Id: I2416ae2a3d9feaff3a99a46ba7835c0931429c06
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoReduce use of Optional 46/115946/2
Robert Varga [Thu, 20 Mar 2025 12:18:35 +0000 (13:18 +0100)]
Reduce use of Optional

While Optional looks cool, its use in arguments is not. Ditch it in
favor of @Nullable in SnapshotManager.commit().

JIRA: CONTROLLER-2134
Change-Id: Id03af74b8a0cff87ebb96b15a7a1ac5cb3744e96
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoMake RaftActorSnapshotCohort type-safe 44/115944/5
Robert Varga [Thu, 20 Mar 2025 10:46:12 +0000 (11:46 +0100)]
Make RaftActorSnapshotCohort type-safe

We are dancing around with State, where not every case is really
possible. We are about to make State handoff more dicey, so this patch
ensures that we have the cohorts advertize their supported class.

JIRA: CONTROLLER-2134
Change-Id: Iaea1e580ea8c806ff147a428330a6a9b407e730b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoSplit out MockSnapshotState 43/115943/3
Robert Varga [Thu, 20 Mar 2025 10:31:56 +0000 (11:31 +0100)]
Split out MockSnapshotState

This is a simplistic class, use a standalone record for it.

JIRA: CONTROLLER-2134
Change-Id: Ida1f5abf59df589972eefddccc07b9f87f7ec33b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoSplit off request allocation 41/115941/2
Robert Varga [Thu, 20 Mar 2025 09:37:53 +0000 (10:37 +0100)]
Split off request allocation

Move request allocation to the three callers, improving modularity of
the methods. Also ensure that public method are clustered together.

JIRA: CONTROLLER-2134
Change-Id: I879594f328d96028294c599c1b6845bd34e91a37
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoInvert state checking 40/115940/1
Robert Varga [Thu, 20 Mar 2025 09:17:12 +0000 (10:17 +0100)]
Invert state checking

We have over-generalized capture() method, which we will need to break
down. This takes the first step to perform basic valid-or-bail first.

JIRA: CONTROLLER-2134
Change-Id: I590bea5642e8779edd3f65927821bc8ecb63fd4c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoClose executor via try-with-resources 39/115939/1
Robert Varga [Thu, 20 Mar 2025 08:06:13 +0000 (09:06 +0100)]
Close executor via try-with-resources

ExecutorService is now AutoCloseable, take advantage of that.

Change-Id: Idcc244d1945d157976b0e402f7d9e2eba733167f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoImprove RaftActor(Context) interactions 38/115938/2
Robert Varga [Thu, 20 Mar 2025 02:54:19 +0000 (03:54 +0100)]
Improve RaftActor(Context) interactions

RaftActor.getSnapshot() can be simplified by:
- using memberId()
- capturing common bits from RaftActorContext before capturing the
  snapshot
- using ActorContext.actorOf() directly

This eliminates the need for RaftActorContext.actorOf(), which is now
removed.

A futher change is to use ActorRef.noSender(), as the sender information
is completely unused by GetSnapshotReply recipients.

JIRA: CONTROLLER-2134
Change-Id: Ieb6eaac87984fdb5434d242d4b97887451a8b6c4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoClean up SnapshotManager.capture() tests 30/115930/2
Robert Varga [Wed, 19 Mar 2025 20:20:48 +0000 (21:20 +0100)]
Clean up SnapshotManager.capture() tests

Use ImmutableRaftEntryMeta instead of SimpleReplicateLogEntry, reducing
the amount of clutter.

JIRA: CONTROLLER-2134
Change-Id: Ibe67bfad07fd510f05c123bbcfc6a04341888648
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove RaftActorContextImpl.close() 28/115928/1
Robert Varga [Wed, 19 Mar 2025 15:12:22 +0000 (16:12 +0100)]
Remove RaftActorContextImpl.close()

We are indirecting to current behavior, just inline this login in
RaftActor.

Change-Id: I2ed629cd67e032058ecf922c9b51a31cea7e8d15
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoMove CommitSnapshot 26/115926/2
Robert Varga [Wed, 19 Mar 2025 14:43:39 +0000 (15:43 +0100)]
Move CommitSnapshot

CommitSnapshot needs to be visible for testing purposes, move it to
SnapshotManager, simplifying RaftActorSnapshotMessageSupport a bit more.

JIRA: CONTROLLER-2134
Change-Id: I15d0d841dc8bc0396c37e77d26e43ff7a17d232f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoSimplify RaftActorSnapshotMessageSupport 25/115925/2
Robert Varga [Wed, 19 Mar 2025 14:04:59 +0000 (15:04 +0100)]
Simplify RaftActorSnapshotMessageSupport

We really only need SnapshotManager here, let's move things around to
simplify things a bit.

JIRA: CONTROLLER-2134
Change-Id: I5d50d9f75a567c2eed5f5296308d5e0fb3758e9c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoMove GetSnapshot support 24/115924/2
Robert Varga [Wed, 19 Mar 2025 13:43:13 +0000 (14:43 +0100)]
Move GetSnapshot support

GetSnapshot has nothing to do with actual snapshotting, it just happens
to use the same mechanism. Move the implementation to RaftActor, making
RaftActorSnapshotMessageSupport independent of RaftActorSnapshotCohort
et al.

JIRA: CONTROLLER-2134
Change-Id: I574e02dc1bf268d8d78077fc4f15b939a983ee8d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoClean up ExampleActor a bit 27/115927/1
Robert Varga [Wed, 19 Mar 2025 14:53:05 +0000 (15:53 +0100)]
Clean up ExampleActor a bit

Improve mapping to/from state: make sure we know it is Serializable and
verify incoming snapshot.

Change-Id: I1813973102b98ddf6153bc0f0a97f267335b329e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRefactor GetSnapshot 23/115923/3
Robert Varga [Wed, 19 Mar 2025 13:15:15 +0000 (14:15 +0100)]
Refactor GetSnapshot

Make timeout mandatory, allowing us to simplify state management in
RaftActorSnapshotMessageSupport.

JIRA: CONTROLLER-2134
Change-Id: I6b660b17c23a4544bbf976b5e0944143e94ef887
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove GetSnapshotReplyActor.Params 22/115922/2
Robert Varga [Wed, 19 Mar 2025 13:02:40 +0000 (14:02 +0100)]
Remove GetSnapshotReplyActor.Params

This is a useless indirection, let's remove it.

JIRA: CONTROLLER-2134
Change-Id: I134e2b42bb127781d23dbeab12ce55ecc33b0da5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoShorten references to Failure 21/115921/1
Robert Varga [Wed, 19 Mar 2025 12:49:20 +0000 (13:49 +0100)]
Shorten references to Failure

Use an import instead of spelling out the reference.

Change-Id: Id32ecb53ca08e335230630a4a4bc9dadbf85628f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoCleanup ReplicatedLogImplTest 20/115920/1
Robert Varga [Wed, 19 Mar 2025 12:35:43 +0000 (13:35 +0100)]
Cleanup ReplicatedLogImplTest

Hide individual test methods.

Change-Id: I6311cd13b6da577870f05fd926e464d720676bdd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoUse RaftActorBehavior.getId() 19/115919/1
Robert Varga [Wed, 19 Mar 2025 12:18:46 +0000 (13:18 +0100)]
Use RaftActorBehavior.getId()

We have a shortcut method, let's use it.

Change-Id: I5b6d3e0f706f02d2e23221c5a050d47712cad254
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoUse memberId 18/115918/1
Robert Varga [Wed, 19 Mar 2025 12:18:16 +0000 (13:18 +0100)]
Use memberId

We do not need to context for the ID -- just pick it up from superclass
field.

Change-Id: I3a7334e7d3d6105e2e060cc2ab6b3a66e06fdef5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoClean up deserializeSnapshot() implementations 17/115917/1
Robert Varga [Wed, 19 Mar 2025 10:46:54 +0000 (11:46 +0100)]
Clean up deserializeSnapshot() implementations

Eliminate unneeded casting.

Change-Id: I16fef02797d196c5c44fef5548fff4685274feec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoEliminate SnapshotManager.createSnapshotProcedure 16/115916/2
Robert Varga [Wed, 19 Mar 2025 10:25:52 +0000 (11:25 +0100)]
Eliminate SnapshotManager.createSnapshotProcedure

The Consumer indirection here is not nice: just acknowledge we are
talking to RaftActorSnapshotCohort and eliminate the indirection.

JIRA: CONTROLLER-2134
Change-Id: Ia1c364c66d30d27ec1fe88e023171eefbdcc84ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoMake GetSnapshotReply a record 13/115913/2
Robert Varga [Tue, 18 Mar 2025 15:19:54 +0000 (16:19 +0100)]
Make GetSnapshotReply a record

This is a very simple class, use a record for its function, eliminating
an unneeded suppression in the process of doing so.

Change-Id: Ibfe412bfa5a26fac5db68b583499d2727d626c69
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoUpdate SpotBugs issue reference 14/115914/2
Robert Varga [Tue, 18 Mar 2025 15:23:26 +0000 (16:23 +0100)]
Update SpotBugs issue reference

SpotBugs has closed the reported issue, but the problem is still there.
Update the pointer to the new issue.

Change-Id: Ibed7fe90c09d98c9b29095202bb3a11ed69de175
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoClean up documentation 12/115912/1
Robert Varga [Tue, 18 Mar 2025 14:44:06 +0000 (15:44 +0100)]
Clean up documentation

We have a tad of mess with method documentation. Turn the comment into a
proper javadoc block and update references.

JIRA: CONTROLLER-2134
Change-Id: I445123e801aa1b4e295a93a7487528bdfb429dfa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoClean up AbstracMXBean 08/115908/5
Robert Varga [Tue, 18 Mar 2025 04:03:08 +0000 (05:03 +0100)]
Clean up AbstracMXBean

Make most methods final and enforce non-null invariants.

Change-Id: Ic3ca4bb76b2e70eb9fdf898ae970edc52dea2899
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoModernize OwnerSupervisor 09/115909/2
Robert Varga [Tue, 18 Mar 2025 04:20:53 +0000 (05:20 +0100)]
Modernize OwnerSupervisor

Use scala.jdk.javaapi.CollectionConverters, as recommended by
documentation. Also use local variable type inference and instanceof
patterns to simplify code.

Change-Id: I2751b688f2fed5484ff7297ccd94451bf35effce
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoModernize sal-remoterpc-connector 07/115907/1
Robert Varga [Tue, 18 Mar 2025 03:53:21 +0000 (04:53 +0100)]
Modernize sal-remoterpc-connector

Use java.time.Duration-based timers, which pushes us towards
CompletionStage -- reducing our exposure to Scala constructs.

Change-Id: I977d43bba5bdadcc8b713930482f0b2a3a58034c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoMore FiniteDuration conversions 05/115905/3
Robert Varga [Mon, 17 Mar 2025 23:46:12 +0000 (00:46 +0100)]
More FiniteDuration conversions

Use java.time.Duration instead, converting to FiniteDuration where
needed.

Change-Id: Ifb8d61dbde0d450bd30c5786a56f22e1dfa59631
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove ActorUtils.getTransactionCommitOperationTimeout() 06/115906/1
Robert Varga [Mon, 17 Mar 2025 23:56:13 +0000 (00:56 +0100)]
Remove ActorUtils.getTransactionCommitOperationTimeout()

This method is no longer used, remove it. Also clean up ActorUtilsTest a
bit.

Change-Id: I859aa142c244208f4ca7727ea26dc35906a65f51
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoReduce use of FiniteDuration in cds-access-client 04/115904/1
Robert Varga [Mon, 17 Mar 2025 23:24:42 +0000 (00:24 +0100)]
Reduce use of FiniteDuration in cds-access-client

Use java.time.Duration instead.

Change-Id: I34ad2c608c1a24e712058ed65c447ac8a5f69728
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoUse Duration instead for FiniteDuration 03/115903/1
Robert Varga [Mon, 17 Mar 2025 17:39:06 +0000 (18:39 +0100)]
Use Duration instead for FiniteDuration

Pekko provides java.time.Duration-based timers, use those instead of
Scala's FiniteDuration.

Change-Id: I0aa1c112a2b0124df2eca91781317658ed485b39
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove RemoteOpsProviderConfig.newInstance() 02/115902/1
Robert Varga [Mon, 17 Mar 2025 13:53:41 +0000 (14:53 +0100)]
Remove RemoteOpsProviderConfig.newInstance()

Just use the builder, as we are no longer tied to Blueprint.

Change-Id: I1da0f3d74a5d3f3ddd3f4b2d0b27e2c83f4a9235
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoUse an instanceof pattern 00/115900/1
Robert Varga [Mon, 17 Mar 2025 13:41:25 +0000 (14:41 +0100)]
Use an instanceof pattern

Remove explicit cast in favor of an instanceof pattern.

Change-Id: Iaedfbf3aa333692b99e30c7106ce6da0d9f1b546
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoWorkaround Follower SpotBugs suppression 99/115899/1
Robert Varga [Mon, 17 Mar 2025 13:17:08 +0000 (14:17 +0100)]
Workaround Follower SpotBugs suppression

MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR is being flagged here because
electionDuration() is non-final for Candidate override.

Ditch the suppression by invoking super.electionDuration(), which makes
it clear the call cannot be overridden.

Change-Id: Ia791129648b199dc86e662623ec8ceacf98d3fbd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoImprove possiblyUpdateCommitIndex() 98/115898/2
Robert Varga [Mon, 17 Mar 2025 12:33:50 +0000 (13:33 +0100)]
Improve possiblyUpdateCommitIndex()

The ReplicatedLog is invariant during execution of this method, hence we
can just access it once. Also clean up logic to reduce if/else blocks,
making the logic more linear.

JIRA: CONTROLLER-2137
Change-Id: I336f687a254a18c38c29060efb827df6c2888d6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoHide ReplicateLogEntry.setPersistencePending() 97/115897/1
Robert Varga [Mon, 17 Mar 2025 11:51:48 +0000 (12:51 +0100)]
Hide ReplicateLogEntry.setPersistencePending()

The control over persistence should be hidden from casual users. Update
appendAndPersist() prototype to prevent loss of implementation identity
and make the setPersistencePending() an implementation detail.

JIRA: CONTROLLER-2137
Change-Id: Idbdee4f00a7a23498f303cb0e7f7347e2318386f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoDrop use of org.apache.pekko.japi.Procedure 96/115896/2
Robert Varga [Mon, 17 Mar 2025 10:58:26 +0000 (11:58 +0100)]
Drop use of org.apache.pekko.japi.Procedure

Callbacks are not allowed to throw, so let's use
java.util.function.Consumer instead. This simplifies the code a bit
at the expense of a single object when we meet AbstractPersistentActor's
methods. That is fine, as those touch points are going away.

JIRA: CONTROLLER-2137
Change-Id: Icbc9e564b7720a5c3f381242fbf6eaa720781ded
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoModernize ExecuteInSelf{Actor,Message} 95/115895/1
Robert Varga [Mon, 17 Mar 2025 10:37:35 +0000 (11:37 +0100)]
Modernize ExecuteInSelf{Actor,Message}

Use a record for ExecuteInSelfMessage and correct ExecuteInSelfActor's
documentation.

Change-Id: Id5039b4617c5776bdef4eb0a4f790469bc95dd57
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoSplit out TestDataProvider 94/115894/1
Robert Varga [Mon, 17 Mar 2025 10:23:38 +0000 (11:23 +0100)]
Split out TestDataProvider

Make NonPersistentDataProvider abstract, making shared methods final.
Introduce TestDataProvider to concentrate the functionality needed for
testing.

JIRA: CONTROLLER-2134
Change-Id: I374c29f5dd1d73e45255a2a757be717b7d4f96cf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoSplit out TransientDataProvider 93/115893/2
Robert Varga [Mon, 17 Mar 2025 09:13:05 +0000 (10:13 +0100)]
Split out TransientDataProvider

We have a subclass of NonPersistentDataProvider, split it out and make
sure the transitions are kept inside RaftActorDataPersistenceProvider.

JIRA: CONTROLLER-2134
Change-Id: If4d1cbb6eca0e256aea5d0d34cb9f2fb1157de26
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoImprove ShardTest 92/115892/1
Robert Varga [Fri, 14 Mar 2025 13:24:41 +0000 (14:24 +0100)]
Improve ShardTest

Now that we have a guaranteed Snapshot, we do not need to have an
explicit cast.

JIRA: CONTROLLER-2134
Change-Id: Icec7676b6d159492ed94ed7bd3a6652146e07fd4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoUse RaftActor in PersistentDataProvider 89/115889/1
Robert Varga [Fri, 14 Mar 2025 10:20:17 +0000 (11:20 +0100)]
Use RaftActor in PersistentDataProvider

Disconnect from Pekko persistence.

JIRA: CONTROLLER-2134
Change-Id: Ib9d7d26f182dde933a4884d1191915f6c0fdea84
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoClean up RaftActor.persistData() 88/115888/2
Robert Varga [Fri, 14 Mar 2025 09:19:25 +0000 (10:19 +0100)]
Clean up RaftActor.persistData()

- use simpler names
- use context directly
- reuse replicated log

Change-Id: Ic45b2e6f36593e4fe10879f3edefa3b736656cb5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoRemove redundant checks for existing snapshot 87/115887/1
Robert Varga [Thu, 13 Mar 2025 13:00:37 +0000 (14:00 +0100)]
Remove redundant checks for existing snapshot

We have two callers who have checked the Optional for presence, so they
should be bypass the check, making the flow a bit clearer.

JIRA: CONTROLLER-2134
Change-Id: I31877288b1bb00d6f0ddfd35558a00e96027bb08
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoUpdate DataPersistenceProvider 84/115884/1
Robert Varga [Thu, 13 Mar 2025 09:03:39 +0000 (10:03 +0100)]
Update DataPersistenceProvider

All arguments are required to be non-null, let's annotate that.
Furthermore we know we are always saving a Snapshot, not a plain Object.

JIRA: CONTROLLER-2134
Change-Id: I9411cc6bdcea19ae4d6113485aed925f1bca3674
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoHide (Non)PersistentDataProvider 82/115882/1
Robert Varga [Wed, 12 Mar 2025 15:50:55 +0000 (16:50 +0100)]
Hide (Non)PersistentDataProvider

These two implementations are really just an internal detail, which is
not being used outside of RaftActor/testing.

Hide them and also integrate DelegatingPersistentDataProvider with
RaftActorDataPersistenceProvider, making relationships a tad clearer.

JIRA: CONTROLLER-2134
Change-Id: I27885b31f6652a2093a9e52b131786e610a0b642
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoRename RaftActorDelegatingPersistentDataProvider 80/115880/1
Robert Varga [Wed, 12 Mar 2025 15:17:14 +0000 (16:17 +0100)]
Rename RaftActorDelegatingPersistentDataProvider

DelegatingPersistentDataProvider is not really useful, let's start with
eliminating some of the tangles we have going through it.

JIRA: CONTROLLER-2134
Change-Id: I310bb6f02b2218522dd59f0ea53f3291aed67aaf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoInitialize MockRaftActor.state 79/115879/1
Robert Varga [Wed, 12 Mar 2025 15:11:56 +0000 (16:11 +0100)]
Initialize MockRaftActor.state

There is no need to initialize in constructor, just use an expression.

Change-Id: Ida71c0147e63e8084ed6d858b038146d89442900
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoMigrate sal-akka-raft messages tests to JUnit5 77/115877/4
Robert Varga [Wed, 12 Mar 2025 11:48:18 +0000 (12:48 +0100)]
Migrate sal-akka-raft messages tests to JUnit5

Move to using JUnit5 for simple tests.

Change-Id: I2c6da396ba7af50c57ef8370d451bb4db854ad02
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoHide LocalAccess 76/115876/2
Robert Varga [Wed, 12 Mar 2025 11:27:52 +0000 (12:27 +0100)]
Hide LocalAccess

Refactor CandidateTest to use the same infrastructure as the rest of the
tests, allowing us to hide LocalAccess.

JIRA: CONTROLLER-2134
Change-Id: I50fe061abb6e565e78c09bf72dcf543df5a46d00
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoHide SnapshotManager methods 68/115868/2
Robert Varga [Tue, 11 Mar 2025 12:50:03 +0000 (13:50 +0100)]
Hide SnapshotManager methods

Most of the methods, as well as the constructor, does not need to be
exposed to the outside world. Hide them and make SnapshotManager final.

JIRA: CONTROLLER-2134
Change-Id: I4e8de5dc8ace4afbf2fbe1d0834a3511c0da5f26
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoMove DataPersistenceProvider 44/115844/1
Robert Varga [Tue, 11 Mar 2025 10:37:13 +0000 (11:37 +0100)]
Move DataPersistenceProvider

DataPersistenceProvider is used only coupled with RaftActor, so this
patch moves it to cluster.raft.spi for further evolution.

JIRA: CONTROLLER-2134
Change-Id: I4cb3e35eaa5a45c2772f1fbf7ec535d96d0240f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoClean up MockRaftActorContext 43/115843/1
Robert Varga [Tue, 11 Mar 2025 10:25:52 +0000 (11:25 +0100)]
Clean up MockRaftActorContext

- remove unused logger
- improve equals() implementation
- fixup @Override annotation placement
- add java.io.Serial annotation

Change-Id: Ib4430b8096f2b356be91772e5d3bca7d286ee8e4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoRemove DatastoreContext.GLOBAL_DATASTORE_NAMES 42/115842/1
Robert Varga [Tue, 11 Mar 2025 10:12:20 +0000 (11:12 +0100)]
Remove DatastoreContext.GLOBAL_DATASTORE_NAMES

This is a global field, which is really not used -- remove it.

Change-Id: If9bfe72661154978f57b9429bd6f405116256e23
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoFix VO_VOLATILE_INCREMENT 41/115841/1
Robert Varga [Tue, 11 Mar 2025 08:40:56 +0000 (09:40 +0100)]
Fix VO_VOLATILE_INCREMENT

Make the variable non-volatile and guard it properly, eliminating a
SpotBugs violation.

Change-Id: I9284e5e623d90e6f6ff719030c15702a068f4e3c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoUse List.reversed() 40/115840/1
Robert Varga [Tue, 11 Mar 2025 08:25:15 +0000 (09:25 +0100)]
Use List.reversed()

We have more modern collections, ditch use of Lists.reversed().

Change-Id: I95a2f1bda581543ae88249ecaa8009b52b23fdd0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoModernize ClusterAdminRpcServiceTest 38/115838/1
Robert Varga [Mon, 10 Mar 2025 16:34:25 +0000 (17:34 +0100)]
Modernize ClusterAdminRpcServiceTest

Address the issues pointed out by modernizer and enable enforcement
again.

Change-Id: I837ee8656304021ec41f7175d18a89b8f3dbbc06
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>