This is an automated email from the ASF dual-hosted git repository.
rexxiong pushed a commit to branch branch-0.3
in repository https://gitbox.apache.org/repos/asf/incubator-celeborn.git
The following commit(s) were added to refs/heads/branch-0.3 by this push:
new 0747ee8e8 [CELEBORN-646] Throw exception when raft client request not
success
0747ee8e8 is described below
commit 0747ee8e8ee9fd43cd763d7f9493f55c046947d8
Author: Shuang <[email protected]>
AuthorDate: Tue Jun 13 10:20:49 2023 +0800
[CELEBORN-646] Throw exception when raft client request not success
### What changes were proposed in this pull request?
Throw exception when raft client request not success.
### Why are the changes needed?
Ratis client may not throw exception when submit request not success.
Current only LeaderNotReadyException,NotLeaderException throw out exception
this may cause some inconsistent.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
UT
Closes #1556 from RexXiong/CELEBORN-646.
Authored-by: Shuang <[email protected]>
Signed-off-by: Shuang <[email protected]>
(cherry picked from commit 70cadef599571835f21ca671b17441199de805a9)
Signed-off-by: Shuang <[email protected]>
---
.../deploy/master/clustermeta/ha/HARaftServer.java | 38 +++-------------------
1 file changed, 4 insertions(+), 34 deletions(-)
diff --git
a/master/src/main/java/org/apache/celeborn/service/deploy/master/clustermeta/ha/HARaftServer.java
b/master/src/main/java/org/apache/celeborn/service/deploy/master/clustermeta/ha/HARaftServer.java
index 612a09a43..cd89fca19 100644
---
a/master/src/main/java/org/apache/celeborn/service/deploy/master/clustermeta/ha/HARaftServer.java
+++
b/master/src/main/java/org/apache/celeborn/service/deploy/master/clustermeta/ha/HARaftServer.java
@@ -37,9 +37,7 @@ import org.apache.ratis.grpc.GrpcConfigKeys;
import org.apache.ratis.netty.NettyConfigKeys;
import org.apache.ratis.proto.RaftProtos;
import org.apache.ratis.protocol.*;
-import org.apache.ratis.protocol.exceptions.LeaderNotReadyException;
-import org.apache.ratis.protocol.exceptions.NotLeaderException;
-import org.apache.ratis.protocol.exceptions.StateMachineException;
+import org.apache.ratis.protocol.exceptions.RaftException;
import org.apache.ratis.rpc.CallId;
import org.apache.ratis.rpc.RpcType;
import org.apache.ratis.rpc.SupportedRpcType;
@@ -48,7 +46,6 @@ import org.apache.ratis.server.RaftServerConfigKeys;
import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
import org.apache.ratis.util.LifeCycle;
import org.apache.ratis.util.SizeInBytes;
-import org.apache.ratis.util.StringUtils;
import org.apache.ratis.util.TimeDuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -226,36 +223,9 @@ public class HARaftServer {
}
if (!raftClientReply.isSuccess()) {
- NotLeaderException notLeaderException =
raftClientReply.getNotLeaderException();
- if (notLeaderException != null) {
- throw new CelebornRuntimeException("Not leader!");
- }
-
- LeaderNotReadyException leaderNotReadyException =
- raftClientReply.getLeaderNotReadyException();
- if (leaderNotReadyException != null) {
- throw new CelebornRuntimeException("Not leader!");
- }
-
- StateMachineException stateMachineException =
raftClientReply.getStateMachineException();
- if (stateMachineException != null) {
- ResourceResponse.Builder response =
-
ResourceResponse.newBuilder().setCmdType(request.getCmdType()).setSuccess(false);
- if (stateMachineException.getCause() != null) {
- response.setMessage(stateMachineException.getCause().getMessage());
- response.setStatus(ResourceProtos.Status.INTERNAL_ERROR);
- } else {
- // Current Ratis is setting cause, this is an safer side check.
- LOG.error("StateMachine exception cause is not set");
- response.setStatus(ResourceProtos.Status.INTERNAL_ERROR);
-
response.setMessage(StringUtils.stringifyException(stateMachineException));
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Error while executing ratis request.",
stateMachineException);
- }
- return response.build();
- }
+ RaftException exception = raftClientReply.getException();
+ throw new CelebornRuntimeException(
+ exception == null ? "Encounter raft exception." :
exception.getMessage());
}
try {