This is an automated email from the ASF dual-hosted git repository.

szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git


The following commit(s) were added to refs/heads/master by this push:
     new 461b9744 RATIS-1604. server reply should return success for 
SNAPSHOT_INSTALLED in InstallSnapshotReplyProto (#662)
461b9744 is described below

commit 461b97441e40f1f2e4f071ce706a2d4704036bc4
Author: Nibiru <[email protected]>
AuthorDate: Thu Jun 30 13:34:34 2022 +0800

    RATIS-1604. server reply should return success for SNAPSHOT_INSTALLED in 
InstallSnapshotReplyProto (#662)
---
 .../org/apache/ratis/server/impl/ServerProtoUtils.java  | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git 
a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerProtoUtils.java 
b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerProtoUtils.java
index 0c44561d..deae754c 100644
--- 
a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerProtoUtils.java
+++ 
b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerProtoUtils.java
@@ -79,7 +79,7 @@ final class ServerProtoUtils {
       RaftPeerId requestorId, RaftGroupMemberId replyId,
       long currentTerm, int requestIndex, InstallSnapshotResult result) {
     final RaftRpcReplyProto.Builder rb = 
toRaftRpcReplyProtoBuilder(requestorId,
-        replyId, result == InstallSnapshotResult.SUCCESS);
+        replyId, isSuccess(result));
     final InstallSnapshotReplyProto.Builder builder = InstallSnapshotReplyProto
         .newBuilder().setServerReply(rb).setTerm(currentTerm).setResult(result)
         .setRequestIndex(requestIndex);
@@ -90,7 +90,7 @@ final class ServerProtoUtils {
       RaftPeerId requestorId, RaftGroupMemberId replyId,
       long currentTerm, InstallSnapshotResult result, long 
installedSnapshotIndex) {
     final RaftRpcReplyProto.Builder rb = 
toRaftRpcReplyProtoBuilder(requestorId,
-        replyId, result == InstallSnapshotResult.SUCCESS);
+        replyId, isSuccess(result));
     final InstallSnapshotReplyProto.Builder builder = InstallSnapshotReplyProto
         
.newBuilder().setServerReply(rb).setTerm(currentTerm).setResult(result);
     if (installedSnapshotIndex > 0) {
@@ -103,7 +103,7 @@ final class ServerProtoUtils {
       RaftPeerId requestorId, RaftGroupMemberId replyId,
       InstallSnapshotResult result) {
     final RaftRpcReplyProto.Builder rb = 
toRaftRpcReplyProtoBuilder(requestorId,
-        replyId, result == InstallSnapshotResult.SUCCESS);
+        replyId, isSuccess(result));
     final InstallSnapshotReplyProto.Builder builder = InstallSnapshotReplyProto
         .newBuilder().setServerReply(rb).setResult(result);
     return builder.build();
@@ -160,4 +160,15 @@ final class ServerProtoUtils {
         .setLastRpcElapsedTimeMs(delay)
         .build();
   }
+
+  static boolean isSuccess(InstallSnapshotResult result) {
+    switch (result) {
+      case SUCCESS:
+      case SNAPSHOT_INSTALLED:
+      case ALREADY_INSTALLED:
+        return true;
+      default:
+        return false;
+    }
+  }
 }

Reply via email to