kaijchen commented on code in PR #844:
URL: https://github.com/apache/ratis/pull/844#discussion_r1130329308
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderElection.java:
##########
@@ -186,16 +186,23 @@ public String toString() {
private final RaftServerImpl server;
private final boolean skipPreVote;
+ private final ConfAndTerm round0;
- LeaderElection(RaftServerImpl server, boolean skipPreVote) {
+ LeaderElection(RaftServerImpl server, boolean force) {
this.name = server.getMemberId() + "-" +
JavaUtils.getClassSimpleName(getClass()) + COUNT.incrementAndGet();
this.lifeCycle = new LifeCycle(this);
this.daemon = Daemon.newBuilder().setName(name).setRunnable(this)
.setThreadGroup(server.getThreadGroup()).build();
this.server = server;
- this.skipPreVote = skipPreVote ||
+ this.skipPreVote = force ||
!RaftServerConfigKeys.LeaderElection.preVote(
server.getRaftServer().getProperties());
+ try {
+ // increase term of the candidate early if it's forced to election
+ this.round0 = force ? server.getState().initElection(Phase.ELECTION) :
null;
Review Comment:
Check `force` instead of `this.skipPreVote` here, so it's not affected by
configKeys.
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderElection.java:
##########
@@ -186,16 +186,23 @@ public String toString() {
private final RaftServerImpl server;
private final boolean skipPreVote;
+ private final ConfAndTerm round0;
- LeaderElection(RaftServerImpl server, boolean skipPreVote) {
+ LeaderElection(RaftServerImpl server, boolean force) {
Review Comment:
Argument changed to differentiate with `this.skipPreVote`.
Also to match with the caller
https://github.com/apache/ratis/blob/69263c884573b87eada10bdd269c9e9d31fb2e94/ratis-server/src/main/java/org/apache/ratis/server/impl/RoleInfo.java#L116-L121
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]