-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE #124] add snapshot to raft state machine #127
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #127 +/- ##
===========================================
- Coverage 43.13% 41.95% -1.18%
===========================================
Files 114 118 +4
Lines 4766 4900 +134
Branches 697 713 +16
===========================================
Hits 2056 2056
- Misses 2356 2490 +134
Partials 354 354
|
@@ -52,10 +57,13 @@ public class MqttStateMachine extends StateMachineAdapter { | |||
|
|||
private volatile String leaderIp = "unknown"; | |||
|
|||
private SnapshotOperation snapshotOperation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snapshotOperation is not used in this file, maybe it should be delete
public MqttStateMachine(MqttRaftServer server, StateProcessor processor, String groupId) { | ||
this.server = server; | ||
this.processor = processor; | ||
this.groupId = groupId; | ||
this.snapshotOperation = this.processor.loadSnapshotOperate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parameter is not used in this file
|
||
public abstract class StateProcessor { | ||
|
||
public abstract Response onReadRequest(ReadRequest request); | ||
|
||
public abstract Response onWriteRequest(WriteRequest log); | ||
|
||
public SnapshotOperation loadSnapshotOperate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onSnapshotSave/onSnapshotLoad is used to do Snapshot Operate.
SnapshotOperation maybe can be a implementation of onSnapshotSave/onSnapshotLoad, it can be delete
@@ -62,6 +72,24 @@ public Response onWriteRequest(WriteRequest writeRequest) { | |||
} | |||
} | |||
|
|||
@Override | |||
public SnapshotOperation loadSnapshotOperate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snapshotOperation can be init in constructor, or init function with @PostConstruct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, you should consider that the user must use this framework for snapshot operations. This may be achieved through design such as inheritance
#124