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 dd75ffbfb RATIS-2089. Add CommitInfoProto in NotReplicatedException
(#1105)
dd75ffbfb is described below
commit dd75ffbfb94dcd624be0e75171e5c54a12b029b2
Author: Ivan Andika <[email protected]>
AuthorDate: Wed May 29 02:43:23 2024 +0800
RATIS-2089. Add CommitInfoProto in NotReplicatedException (#1105)
---
.../org/apache/ratis/client/impl/ClientProtoUtils.java | 3 ++-
.../ratis/protocol/exceptions/NotReplicatedException.java | 15 +++++++++++++++
.../src/test/java/org/apache/ratis/WatchRequestTests.java | 1 +
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git
a/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientProtoUtils.java
b/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientProtoUtils.java
index cab9606a0..5e217e7da 100644
---
a/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientProtoUtils.java
+++
b/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientProtoUtils.java
@@ -398,7 +398,8 @@ public interface ClientProtoUtils {
e = new NotLeaderException(serverMemberId, suggestedLeader, peers);
} else if (replyProto.getExceptionDetailsCase() == NOTREPLICATEDEXCEPTION)
{
final NotReplicatedExceptionProto nre =
replyProto.getNotReplicatedException();
- e = new NotReplicatedException(nre.getCallId(), nre.getReplication(),
nre.getLogIndex());
+ e = new NotReplicatedException(nre.getCallId(), nre.getReplication(),
nre.getLogIndex(),
+ replyProto.getCommitInfosList());
} else if
(replyProto.getExceptionDetailsCase().equals(STATEMACHINEEXCEPTION)) {
e = toStateMachineException(serverMemberId,
replyProto.getStateMachineException());
} else if
(replyProto.getExceptionDetailsCase().equals(DATASTREAMEXCEPTION)) {
diff --git
a/ratis-common/src/main/java/org/apache/ratis/protocol/exceptions/NotReplicatedException.java
b/ratis-common/src/main/java/org/apache/ratis/protocol/exceptions/NotReplicatedException.java
index 5f48654ee..37ff81624 100644
---
a/ratis-common/src/main/java/org/apache/ratis/protocol/exceptions/NotReplicatedException.java
+++
b/ratis-common/src/main/java/org/apache/ratis/protocol/exceptions/NotReplicatedException.java
@@ -17,12 +17,17 @@
*/
package org.apache.ratis.protocol.exceptions;
+import org.apache.ratis.proto.RaftProtos.CommitInfoProto;
import org.apache.ratis.proto.RaftProtos.ReplicationLevel;
+import java.util.Collection;
+
public class NotReplicatedException extends RaftException {
private final long callId;
private final ReplicationLevel requiredReplication;
private final long logIndex;
+ /** This is only populated on client-side since RaftClientReply already has
commitInfos */
+ private Collection<CommitInfoProto> commitInfos;
public NotReplicatedException(long callId, ReplicationLevel
requiredReplication, long logIndex) {
super("Request with call Id " + callId + " and log index " + logIndex
@@ -32,6 +37,12 @@ public class NotReplicatedException extends RaftException {
this.logIndex = logIndex;
}
+ public NotReplicatedException(long callId, ReplicationLevel
requiredReplication, long logIndex,
+ Collection<CommitInfoProto> commitInfos) {
+ this(callId, requiredReplication, logIndex);
+ this.commitInfos = commitInfos;
+ }
+
public long getCallId() {
return callId;
}
@@ -43,4 +54,8 @@ public class NotReplicatedException extends RaftException {
public long getLogIndex() {
return logIndex;
}
+
+ public Collection<CommitInfoProto> getCommitInfos() {
+ return commitInfos;
+ }
}
diff --git a/ratis-server/src/test/java/org/apache/ratis/WatchRequestTests.java
b/ratis-server/src/test/java/org/apache/ratis/WatchRequestTests.java
index 32e452758..b842ee9db 100644
--- a/ratis-server/src/test/java/org/apache/ratis/WatchRequestTests.java
+++ b/ratis-server/src/test/java/org/apache/ratis/WatchRequestTests.java
@@ -559,5 +559,6 @@ public abstract class WatchRequestTests<CLUSTER extends
MiniRaftCluster>
Assert.assertNotNull(nre);
Assert.assertEquals(logIndex, nre.getLogIndex());
Assert.assertEquals(replication, nre.getRequiredReplication());
+ Assert.assertNotNull(nre.getCommitInfos());
}
}