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 d446d7c26 [CELEBORN-1033][FOLLOWUP] MasterNotLeaderException should
provide the cause of exception
d446d7c26 is described below
commit d446d7c262dad0cf1f79792d47b320077a482469
Author: SteNicholas <[email protected]>
AuthorDate: Thu Oct 12 20:57:07 2023 +0800
[CELEBORN-1033][FOLLOWUP] MasterNotLeaderException should provide the cause
of exception
### What changes were proposed in this pull request?
`HAHelper#sendFailure` only sends `MasterNotLeaderException` without cause,
which causes that the actual exception of `MasterNotLeaderException` could not
catch for troubleshooting.
### Why are the changes needed?
`MasterNotLeaderException` provides the cause of exception.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
`MasterClientSuiteJ`
Closes #1984 from SteNicholas/CELEBORN-1033-0.3.
Authored-by: SteNicholas <[email protected]>
Signed-off-by: Shuang <[email protected]>
---
.../common/haclient/MasterNotLeaderException.java | 25 ++++++++++++++--------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git
a/common/src/main/java/org/apache/celeborn/common/haclient/MasterNotLeaderException.java
b/common/src/main/java/org/apache/celeborn/common/haclient/MasterNotLeaderException.java
index 59f63deac..34aaccbb4 100644
---
a/common/src/main/java/org/apache/celeborn/common/haclient/MasterNotLeaderException.java
+++
b/common/src/main/java/org/apache/celeborn/common/haclient/MasterNotLeaderException.java
@@ -19,23 +19,30 @@ package org.apache.celeborn.common.haclient;
import java.io.IOException;
+import javax.annotation.Nullable;
+
+import org.apache.commons.lang3.StringUtils;
+
// This class is reserved for compatible with 0.2 client
public class MasterNotLeaderException extends IOException {
- private final String currentPeer;
+ private static final long serialVersionUID = -6230015203034327259L;
+
private final String leaderPeer;
public static final String LEADER_NOT_PRESENTED = "leader is not present";
- public MasterNotLeaderException(String currentPeer, String
suggestedLeaderPeer) {
+ public MasterNotLeaderException(
+ String currentPeer, String suggestedLeaderPeer, @Nullable Throwable
cause) {
super(
- "Master:"
- + currentPeer
- + " is not the leader. Suggested leader is"
- + " Master:"
- + suggestedLeaderPeer
- + ".");
- this.currentPeer = currentPeer;
+ String.format(
+ "Master:%s is not the leader. Suggested leader is Master:%s.%s",
+ currentPeer,
+ suggestedLeaderPeer,
+ cause == null
+ ? StringUtils.EMPTY
+ : String.format(" Exception:%s.", cause.getMessage())),
+ cause);
this.leaderPeer = suggestedLeaderPeer;
}