Remove unused exceptions This drops exception declarations which are never used. Change-Id: Icc8938b9c3b437a0d5961ec1b481fd06c52d47f2 Signed-off-by: Stephen Kitt <skitt@redhat.com>
Cleanup warnings - pom.xml groupId duplicate - Futures.addCallback() - Throwables.propagate*() - pontentially-static methods - remove 'throws Exception' where it is not really needed Change-Id: Ib47e6255e0f510ab7dd0dcd08f71f2dd124df7b7 Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Fix timing issue in PartitionedCandidateOnStartupElection*Test If the initial AppendEntries sent by the leader (member 1) to member 3 is delayed enough such that the behavior field in MemberActor is already set by the test code, the AppendEntries message will be forwarded to the Candidate behavior and yield incorrect results for the test. To prevent this, we really shouldn't set and access the behavior field directly but instead do so via messages to maintain actor encapsulation. Change-Id: If497583ce648e62e3279e5abff19cb8702943c17 Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
Fix warnings in sal-akka-raft test classes Fixed checkstyle warnings in the test classes. Most of the warnings/changes were for: - white space before if/for/while/catch - white space before beginning brace - line too long - illegal catching of Exception (suppressed) - variable name too short - indentation - removed use of JavaTestKit with embedded code (avoids having to indent code another 4 spaces). In most cases, JavaTestKit wasn't even used. - local vars/params hiding a field - putting overloaded methods close to one another - remove unused vars - convert functional interfaces to lambdas (eclipse save action) - empty catch block - added comment or Throwables.propagate as appropriate - missing period after first sentence in javadoc - missing first sentence in javadoc - adding final for locals declared too far from first usage Change-Id: I5c522e5b0383b2c5e9b0b036dc444c51f788b650 Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
Alleviate premature elections in followers If a follower actor is busy or some non-leader messages take longer to process, leader messages may get backed up enough to cause the election timer to expire, thereby resulting in an unwanted election and leader disruption. To alleviate this scenario, I added a Stopwatch to keep the last time a leader message was received, ie when a leader message is received it restarts the Stopwatch. When ElectionTimeout is received, it checks if the elapsed time of the Stopwatch has exceeded the election timeout interval. Therefore if leader messages were occurring during the election timeout interval but were delayed, they will be processed before the ElectionTimeout message and restart the Stopwatch such that the elapsed time will/should be less than the election timeout interval by the time ElectionTimeout is received (unless the last leader message happened to take longer than the election timeout interval). There are cases where ElectionTimeout is manually sent to force an election timeout (eg during leadership transfer). In these cases we don't want to check the Stopwatch so I added an explicit TimeoutNow message to distinguish the 2 messages. Change-Id: I6b745288040da2fdcef1d29cb5ffc482c9e66003 Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
Remove DelegatingRaftActorBehavior The delegate is leaked through various methods, implementations of which already have access to the current behavior if it were available from RaftActorContext. Simplify calling conventions Change-Id: I9e27f68e55f28a9afd446abff91fbb38dd26c011 Signed-off-by: Robert Varga <rovarga@cisco.com>
Turn ElectionTimeout into a proper singleton There is no need to instantiate this object multiple times. Turn it into a singleton. Also add a bit of javadocs. Change-Id: Ied90a43ec297409b8074875d305d7f74e1b37ce4 Signed-off-by: Robert Varga <rovarga@cisco.com>
Fix resource leaks in test cases Close AutoCloseable objects created in test cases that were not being closed. Add mock calls for close() methods that now need to be stubbed. Change-Id: Iab057a3a1850d024f02656eb1ae82c6fb1486030 Signed-off-by: Gary Wu <gary.wu1@huawei.com>
Refactor LeaderElectionScenarioTests Refactored LeaderElectionScenarioTests into separate test classes for each scenario with specific methods for each major test step to improve readability and comprehension. This also will make it easier to add new tests. Change-Id: Ie072d1837cdc6bf53b8e34aad9c6421fd7d4e22a Signed-off-by: Tom Pantelis <tpanteli@brocade.com>