Skip to content

Commit

Permalink
RATIS-2089. Add CommitInfoProto in NotReplicatedException (apache#1105)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivandika3 authored and szetszwo committed Jun 16, 2024
1 parent 42cfa93 commit d425686
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ static RaftClientReply toRaftClientReply(RaftClientReplyProto replyProto) {
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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,6 +37,12 @@ public NotReplicatedException(long callId, ReplicationLevel requiredReplication,
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;
}
Expand All @@ -43,4 +54,8 @@ public ReplicationLevel getRequiredReplication() {
public long getLogIndex() {
return logIndex;
}

public Collection<CommitInfoProto> getCommitInfos() {
return commitInfos;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -559,5 +559,6 @@ static void assertNotReplicatedException(long logIndex, ReplicationLevel replica
Assert.assertNotNull(nre);
Assert.assertEquals(logIndex, nre.getLogIndex());
Assert.assertEquals(replication, nre.getRequiredReplication());
Assert.assertNotNull(nre.getCommitInfos());
}
}

0 comments on commit d425686

Please sign in to comment.