[optimization](show-frontends) Add start time in Show frontends (#21844)
--------- Co-authored-by: yuxianbing <iloveqaz123>
This commit is contained in:
@ -45,7 +45,8 @@ public class FrontendsProcNode implements ProcNodeInterface {
|
||||
public static final ImmutableList<String> TITLE_NAMES = new ImmutableList.Builder<String>()
|
||||
.add("Name").add("Host").add("EditLogPort").add("HttpPort").add("QueryPort").add("RpcPort")
|
||||
.add("Role").add("IsMaster").add("ClusterId").add("Join").add("Alive")
|
||||
.add("ReplayedJournalId").add("LastHeartbeat").add("IsHelper").add("ErrMsg").add("Version")
|
||||
.add("ReplayedJournalId").add("LastStartTime").add("LastHeartbeat")
|
||||
.add("IsHelper").add("ErrMsg").add("Version")
|
||||
.add("CurrentConnected")
|
||||
.build();
|
||||
|
||||
@ -124,6 +125,7 @@ public class FrontendsProcNode implements ProcNodeInterface {
|
||||
info.add(String.valueOf(fe.isAlive()));
|
||||
info.add(Long.toString(fe.getReplayedJournalId()));
|
||||
}
|
||||
info.add(TimeUtils.longToTimeString(fe.getLastStartupTime()));
|
||||
info.add(TimeUtils.longToTimeString(fe.getLastUpdateTime()));
|
||||
info.add(String.valueOf(isHelperNode(helperNodes, fe)));
|
||||
info.add(fe.getHeartbeatErrMsg());
|
||||
|
||||
@ -26,10 +26,12 @@ public class ExecuteEnv {
|
||||
private static volatile ExecuteEnv INSTANCE;
|
||||
private MultiLoadMgr multiLoadMgr;
|
||||
private ConnectScheduler scheduler;
|
||||
private long startupTime;
|
||||
|
||||
private ExecuteEnv() {
|
||||
multiLoadMgr = new MultiLoadMgr();
|
||||
scheduler = new ConnectScheduler(Config.qe_max_connection);
|
||||
startupTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static ExecuteEnv getInstance() {
|
||||
@ -50,4 +52,8 @@ public class ExecuteEnv {
|
||||
public MultiLoadMgr getMultiLoadMgr() {
|
||||
return multiLoadMgr;
|
||||
}
|
||||
|
||||
public long getStartupTime() {
|
||||
return startupTime;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1920,6 +1920,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
result.setQueryPort(Config.query_port);
|
||||
result.setRpcPort(Config.rpc_port);
|
||||
result.setVersion(Version.DORIS_BUILD_VERSION + "-" + Version.DORIS_BUILD_SHORT_HASH);
|
||||
result.setLastStartupTime(exeEnv.getStartupTime());
|
||||
}
|
||||
} else {
|
||||
result.setStatus(TFrontendPingFrontendStatusCode.FAILED);
|
||||
|
||||
@ -51,6 +51,7 @@ public class Frontend implements Writable {
|
||||
private int rpcPort;
|
||||
|
||||
private long replayedJournalId;
|
||||
private long lastStartupTime;
|
||||
private long lastUpdateTime;
|
||||
private String heartbeatErrMsg = "";
|
||||
|
||||
@ -114,6 +115,10 @@ public class Frontend implements Writable {
|
||||
return heartbeatErrMsg;
|
||||
}
|
||||
|
||||
public long getLastStartupTime() {
|
||||
return lastStartupTime;
|
||||
}
|
||||
|
||||
public long getLastUpdateTime() {
|
||||
return lastUpdateTime;
|
||||
}
|
||||
@ -138,6 +143,7 @@ public class Frontend implements Writable {
|
||||
replayedJournalId = hbResponse.getReplayedJournalId();
|
||||
lastUpdateTime = hbResponse.getHbTime();
|
||||
heartbeatErrMsg = "";
|
||||
lastStartupTime = hbResponse.getFeStartTime();
|
||||
isChanged = true;
|
||||
} else {
|
||||
if (isAlive) {
|
||||
|
||||
@ -39,13 +39,14 @@ public class FrontendHbResponse extends HeartbeatResponse implements Writable {
|
||||
@SerializedName(value = "replayedJournalId")
|
||||
private long replayedJournalId;
|
||||
private String version;
|
||||
private long feStartTime;
|
||||
|
||||
public FrontendHbResponse() {
|
||||
super(HeartbeatResponse.Type.FRONTEND);
|
||||
}
|
||||
|
||||
public FrontendHbResponse(String name, int queryPort, int rpcPort,
|
||||
long replayedJournalId, long hbTime, String version) {
|
||||
long replayedJournalId, long hbTime, String version, long feStartTime) {
|
||||
super(HeartbeatResponse.Type.FRONTEND);
|
||||
this.status = HbStatus.OK;
|
||||
this.name = name;
|
||||
@ -54,6 +55,7 @@ public class FrontendHbResponse extends HeartbeatResponse implements Writable {
|
||||
this.replayedJournalId = replayedJournalId;
|
||||
this.hbTime = hbTime;
|
||||
this.version = version;
|
||||
this.feStartTime = feStartTime;
|
||||
}
|
||||
|
||||
public FrontendHbResponse(String name, String errMsg) {
|
||||
@ -83,6 +85,10 @@ public class FrontendHbResponse extends HeartbeatResponse implements Writable {
|
||||
return version;
|
||||
}
|
||||
|
||||
public long getFeStartTime() {
|
||||
return feStartTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFields(DataInput in) throws IOException {
|
||||
super.readFields(in);
|
||||
@ -101,6 +107,7 @@ public class FrontendHbResponse extends HeartbeatResponse implements Writable {
|
||||
sb.append(", queryPort: ").append(queryPort);
|
||||
sb.append(", rpcPort: ").append(rpcPort);
|
||||
sb.append(", replayedJournalId: ").append(replayedJournalId);
|
||||
sb.append(", festartTime: ").append(feStartTime);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ import org.apache.doris.common.Version;
|
||||
import org.apache.doris.common.util.MasterDaemon;
|
||||
import org.apache.doris.persist.HbPackage;
|
||||
import org.apache.doris.resource.Tag;
|
||||
import org.apache.doris.service.ExecuteEnv;
|
||||
import org.apache.doris.service.FrontendOptions;
|
||||
import org.apache.doris.system.HeartbeatResponse.HbStatus;
|
||||
import org.apache.doris.system.SystemInfoService.HostInfo;
|
||||
@ -112,7 +113,7 @@ public class HeartbeatMgr extends MasterDaemon {
|
||||
for (Frontend frontend : frontends) {
|
||||
FrontendHeartbeatHandler handler = new FrontendHeartbeatHandler(frontend,
|
||||
Env.getCurrentEnv().getClusterId(),
|
||||
Env.getCurrentEnv().getToken());
|
||||
Env.getCurrentEnv().getToken(), ExecuteEnv.getInstance().getStartupTime());
|
||||
hbResponses.add(executor.submit(handler));
|
||||
}
|
||||
|
||||
@ -283,6 +284,7 @@ public class HeartbeatMgr extends MasterDaemon {
|
||||
private Frontend fe;
|
||||
private int clusterId;
|
||||
private String token;
|
||||
private long callerFeStartTime;
|
||||
|
||||
public FrontendHeartbeatHandler(Frontend fe, int clusterId, String token) {
|
||||
this.fe = fe;
|
||||
@ -290,6 +292,13 @@ public class HeartbeatMgr extends MasterDaemon {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public FrontendHeartbeatHandler(Frontend fe, int clusterId, String token, long callerFeStartTime) {
|
||||
this.fe = fe;
|
||||
this.clusterId = clusterId;
|
||||
this.token = token;
|
||||
this.callerFeStartTime = callerFeStartTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HeartbeatResponse call() {
|
||||
HostInfo selfNode = Env.getCurrentEnv().getSelfNode();
|
||||
@ -298,7 +307,7 @@ public class HeartbeatMgr extends MasterDaemon {
|
||||
if (Env.getCurrentEnv().isReady()) {
|
||||
return new FrontendHbResponse(fe.getNodeName(), Config.query_port, Config.rpc_port,
|
||||
Env.getCurrentEnv().getMaxJournalId(), System.currentTimeMillis(),
|
||||
Version.DORIS_BUILD_VERSION + "-" + Version.DORIS_BUILD_SHORT_HASH);
|
||||
Version.DORIS_BUILD_VERSION + "-" + Version.DORIS_BUILD_SHORT_HASH, callerFeStartTime);
|
||||
} else {
|
||||
return new FrontendHbResponse(fe.getNodeName(), "not ready");
|
||||
}
|
||||
@ -319,7 +328,7 @@ public class HeartbeatMgr extends MasterDaemon {
|
||||
if (result.getStatus() == TFrontendPingFrontendStatusCode.OK) {
|
||||
return new FrontendHbResponse(fe.getNodeName(), result.getQueryPort(),
|
||||
result.getRpcPort(), result.getReplayedJournalId(),
|
||||
System.currentTimeMillis(), result.getVersion());
|
||||
System.currentTimeMillis(), result.getVersion(), result.getLastStartupTime());
|
||||
|
||||
} else {
|
||||
return new FrontendHbResponse(fe.getNodeName(), result.getMsg());
|
||||
|
||||
@ -766,6 +766,7 @@ struct TFrontendPingFrontendResult {
|
||||
4: required i32 rpcPort
|
||||
5: required i64 replayedJournalId
|
||||
6: required string version
|
||||
7: optional i64 lastStartupTime
|
||||
}
|
||||
|
||||
struct TPropertyVal {
|
||||
|
||||
Reference in New Issue
Block a user