Repository navigation
refactor(ha-raft): split ArcadeStateMachine and RaftHAServer by responsibility - #12300
Conversation
…nsibility ArcadeStateMachine goes from 11,045 to 4,631 lines and RaftHAServer from 8,693 to 4,409, with the moved code in 33 package-private classes, each with one responsibility. Method bodies are moved as they are; the new classes keep a back-reference to their owner for shared state, and log through the owner so logger names do not change. Members overridden by test subclasses, read by reflection in tests, or keyed by census tests stay in place. Methods called from outside keep a one-line delegator on the owner; references to moved static members point at the new class.
|
This pull request is merged. |
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| BestPractice | 7 medium |
| ErrorProne | 2 high |
| Complexity | 1 medium |
🟢 Metrics 1795 complexity
Metric Results Complexity 1795
🟢 Coverage ∅ diff coverage · -4.31% coverage variation
Metric Results Coverage variation ✅ -4.31% coverage variation Diff coverage ∅ diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (7fffe29) 286055 252489 88.27% Head commit (52fe705) 320068 (+34013) 268724 (+16235) 83.96% (-4.31%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#12300) 0 0 ∅ (not applicable) Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Triage: Triage reviewI could not review this PR in full. The diff is about 1.9 MB and was truncated ( What I can say from the description and file list
Requested before merge
I saw no sign of a security issue in the metadata or the file list. I could not check the diff content, so a maintainer who can read the full diff should do the final pass. 1 value(s) redacted. |
Ports the fix onto the ArcadeData#12300 split: the replay check lives in SchemaEntryApplier, the previous-session positions in AppliedIndexFile, and the forget calls in BootstrapInstaller and DropDatabaseApplier.
Conflict in RaftHAServer: ArcadeData#12300 moved restartRatis into RatisInPlaceRestart. The publication gate stays in RaftHAServer; the restart now replaces the state machine through replaceStateMachineBetweenPublications from RatisInPlaceRestart, with the same ratisCloseTimeoutMs bound.
What
Splits the two largest HA classes into smaller classes with one responsibility each. This is a behaviour-preserving refactor: method bodies are moved as they are, with no logic change.
ArcadeStateMachineRaftHAServerFrom
ArcadeStateMachine:SchemaEntryApplier,ConfigurationEntryApplier,DropDatabaseApplier,SecurityEntryApplier,CommittedEntryDecodingBootstrapInstaller,BootstrapBaselines,BootstrapPasses,BootstrapDivergenceCheck,UnverifiedCopyReverifierSnapshotResync,DatabaseQuarantine,DatabaseReplacement,LeaderSnapshotInstallAppliedIndexFile,EntryApplyRetry,SchemaChangeHistory,ExclusiveDatabaseWindows,CriticalHaltHandler,MaterializedViewRecoveryFrom
RaftHAServer:PeerEndpoints,PeerCapabilityMonitor,PeerChannelRecovery,MisdirectedRaftRequests,RatisInPlaceRestart,RaftStorageFiles,AppliedIndexWaits,TrafficReadiness,PeerAdmission,ReplicationStatistics,RaftTransportSetup,VoterQuarantineCheck,StepDownTargets.All new classes are package-private, in
com.arcadedb.server.ha.raft.How
FakeArcadeStateMachine,FakeRaftHAServer), read by reflection in tests, or keyed by census tests stay in place.Edits that are not pure moves
ArcadeStateMachine.updateLastAppliedTermIndexAfterInstall(...)bridges to the protected Ratis 2-argupdateLastAppliedTermIndex, which the moved snapshot-install code can no longer reach.CriticalHaltHandleris set in the constructor, since a field initializer cannot read the back-reference.Issue7475RepairExcludedByPauseTestandHaRemovedNodeITname the new owning class; static and method references in tests were repointed the same way.Verification
mvn -o -pl ha-raft -am verify -DskipITs -Dtest='com/arcadedb/server/ha/raft/*Test,com/arcadedb/server/ha/raft/**/*Test' -Dsurefire.failIfNoSpecifiedTests=false -DexcludedGroups=benchmark,slow,vector: 3,490 tests, 1 failure (Issue7549CapabilityMonitorInEveryRoleTest.concurrentStartsCreateExactlyOneMonitor, which fails the same way onmain).mvn -o -pl census -am verify -DskipITs -Dtest='com/arcadedb/census/*Test' -Dsurefire.failIfNoSpecifiedTests=false -DexcludedGroups=benchmark,slow,vector: 53 tests, 0 failures.ha-integration-testsand the ha-raft*ITclasses were not run locally.