You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by ji...@apache.org on 2018/01/18 22:20:38 UTC
incubator-ratis git commit: RATIS-160. Retry cache should handle
leader change after log commit. Contributed by Lokesh Jain.
Repository: incubator-ratis
Updated Branches:
refs/heads/master bc435ad49 -> 5b4bc0e7d
RATIS-160. Retry cache should handle leader change after log commit. Contributed by Lokesh Jain.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ratis/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ratis/commit/5b4bc0e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ratis/tree/5b4bc0e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ratis/diff/5b4bc0e7
Branch: refs/heads/master
Commit: 5b4bc0e7d12e1b2a465774c133e04150b91fcbd9
Parents: bc435ad
Author: Jing Zhao <ji...@apache.org>
Authored: Thu Jan 18 14:16:28 2018 -0800
Committer: Jing Zhao <ji...@apache.org>
Committed: Thu Jan 18 14:16:28 2018 -0800
----------------------------------------------------------------------
.../main/java/org/apache/ratis/server/impl/RaftServerImpl.java | 4 ++++
.../src/main/java/org/apache/ratis/server/impl/RetryCache.java | 6 +++++-
2 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/5b4bc0e7/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
----------------------------------------------------------------------
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 082fe3c..b58ffdb 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
@@ -935,6 +935,10 @@ public class RaftServerImpl implements RaftServerProtocol, RaftServerAsynchronou
final RaftPeerId serverId = getId();
final RetryCache.CacheEntry cacheEntry = retryCache.getOrCreateEntry(
clientId, logEntry.getCallId());
+ if (cacheEntry.isFailed()) {
+ retryCache.refreshEntry(new RetryCache.CacheEntry(cacheEntry.getKey()));
+ }
+
stateMachineFuture.whenComplete((reply, exception) -> {
final RaftClientReply r;
if (exception == null) {
http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/5b4bc0e7/ratis-server/src/main/java/org/apache/ratis/server/impl/RetryCache.java
----------------------------------------------------------------------
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/RetryCache.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/RetryCache.java
index 5abfc1a..81ce9ae 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/RetryCache.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/RetryCache.java
@@ -126,6 +126,10 @@ public class RetryCache implements Closeable {
CompletableFuture<RaftClientReply> getReplyFuture() {
return replyFuture;
}
+
+ CacheKey getKey() {
+ return key;
+ }
}
static class CacheQueryResult {
@@ -172,7 +176,7 @@ public class RetryCache implements Closeable {
return entry;
}
- private CacheEntry refreshEntry(CacheEntry newEntry) {
+ CacheEntry refreshEntry(CacheEntry newEntry) {
cache.put(newEntry.key, newEntry);
return newEntry;
}