Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhance] Add host info to heartbeat error msg #9499

Merged
merged 1 commit into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class BackendHbResponse extends HeartbeatResponse implements Writable {
private int httpPort;
private int brpcPort;
private long beStartTime;
private String host;
private String version = "";

public BackendHbResponse() {
Expand All @@ -57,6 +58,14 @@ public BackendHbResponse(long beId, String errMsg) {
this.msg = errMsg;
}

public BackendHbResponse(long beId, String host, String errMsg) {
super(HeartbeatResponse.Type.BACKEND);
this.status = HbStatus.BAD;
this.beId = beId;
this.host = host;
this.msg = errMsg;
}

public long getBeId() {
return beId;
}
Expand Down Expand Up @@ -110,6 +119,7 @@ public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(super.toString());
sb.append(", beId: ").append(beId);
sb.append(", beHost: ").append(host);
sb.append(", bePort: ").append(bePort);
sb.append(", httpPort: ").append(httpPort);
sb.append(", brpcPort: ").append(brpcPort);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ public HeartbeatResponse call() {
// backend.updateOnce(bePort, httpPort, beRpcPort, brpcPort);
return new BackendHbResponse(backendId, bePort, httpPort, brpcPort, System.currentTimeMillis(), beStartTime, version);
} else {
return new BackendHbResponse(backendId, result.getStatus().getErrorMsgs().isEmpty() ? "Unknown error"
return new BackendHbResponse(backendId, backend.getHost(), result.getStatus().getErrorMsgs().isEmpty() ? "Unknown error"
: result.getStatus().getErrorMsgs().get(0));
}
} catch (Exception e) {
LOG.warn("backend heartbeat got exception", e);
return new BackendHbResponse(backendId,
return new BackendHbResponse(backendId, backend.getHost(),
Strings.isNullOrEmpty(e.getMessage()) ? "got exception" : e.getMessage());
} finally {
if (client != null) {
Expand Down