You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by lj...@apache.org on 2020/05/18 05:50:29 UTC
[incubator-ratis] branch master updated: RATIS-883. Fix Failed UT:
testStateMachineMetrics.checkFollowerCommitLagsLeader
This is an automated email from the ASF dual-hosted git repository.
ljain pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 82f3fe4 RATIS-883. Fix Failed UT: testStateMachineMetrics.checkFollowerCommitLagsLeader
82f3fe4 is described below
commit 82f3fe42b0afcf7342f7800b0ec789515f0ba133
Author: runzhiwang <51...@users.noreply.github.com>
AuthorDate: Mon May 18 11:18:53 2020 +0530
RATIS-883. Fix Failed UT: testStateMachineMetrics.checkFollowerCommitLagsLeader
---
.../src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
index 14620d8..083094a 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
@@ -356,7 +356,7 @@ public class RaftServerImpl implements RaftServerProtocol, RaftServerAsynchronou
Collection<CommitInfoProto> getCommitInfos() {
final List<CommitInfoProto> infos = new ArrayList<>();
// add the commit info of this server
- infos.add(commitInfoCache.update(getPeer(), state.getLog().getLastCommittedIndex()));
+ infos.add(updateCommitInfoCache());
// add the commit infos of other servers
if (isLeader()) {
@@ -948,6 +948,10 @@ public class RaftServerImpl implements RaftServerProtocol, RaftServerAsynchronou
}
}
+ private CommitInfoProto updateCommitInfoCache() {
+ return commitInfoCache.update(getPeer(), state.getLog().getLastCommittedIndex());
+ }
+
@SuppressWarnings("checkstyle:parameternumber")
private CompletableFuture<AppendEntriesReplyProto> appendEntriesAsync(
RaftPeerId leaderId, long leaderTerm, TermIndex previous, long leaderCommit, long callId, boolean initializing,
@@ -1019,6 +1023,7 @@ public class RaftServerImpl implements RaftServerProtocol, RaftServerAsynchronou
final AppendEntriesReplyProto reply;
synchronized(this) {
state.updateStatemachine(leaderCommit, currentTerm);
+ updateCommitInfoCache();
final long n = isHeartbeat? state.getLog().getNextIndex(): entries[entries.length - 1].getIndex() + 1;
final long matchIndex = entries.length != 0 ? entries[entries.length - 1].getIndex() :
RaftLog.INVALID_LOG_INDEX;