Skip to content

Commit

Permalink
[fix](cloud) Add more log for backend and disable cloud cluster status (
Browse files Browse the repository at this point in the history
apache#42442)

api request from non-master
  • Loading branch information
deardeng authored Oct 30, 2024
1 parent 1d1c425 commit 04232ca
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import org.apache.doris.system.Frontend;

import com.google.common.collect.Maps;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -44,6 +47,7 @@
@RestController
@RequestMapping(path = {"/rest/v2/manager/cluster", "/rest/v2/manager/compute_group"})
public class ClusterAction extends RestBaseController {
private static final Logger LOG = LogManager.getLogger(ClusterAction.class);

// Returns mysql and http connection information for the cluster.
// {
Expand Down Expand Up @@ -83,32 +87,58 @@ public static class BeClusterInfo {
public volatile int brpcPort;
public volatile long currentFragmentNum = 0;
public volatile long lastFragmentUpdateTime = 0;

@Override
public String toString() {
return "BeClusterInfo{"
+ "host='" + host + '\''
+ ", heartbeatPort=" + heartbeatPort
+ ", bePort=" + bePort
+ ", httpPort=" + httpPort
+ ", brpcPort=" + brpcPort
+ ", currentFragmentNum=" + currentFragmentNum
+ ", lastFragmentUpdateTime=" + lastFragmentUpdateTime
+ '}';
}
}

@RequestMapping(path = {"/cluster_info/cloud_cluster_status", "/compute_group_info/compute_group_status"},
method = RequestMethod.GET)
public Object cloudClusterInfo(HttpServletRequest request, HttpServletResponse response) {
executeCheckPassword(request, response);
checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), PrivPredicate.ADMIN);
ResponseEntity ret = null;
try {
if (!Env.getCurrentEnv().isMaster()) {
ret = ResponseEntityBuilder.badRequest("this api just use in cloud master fe");
} else {
executeCheckPassword(request, response);
checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), PrivPredicate.ADMIN);

// Key: cluster_name Value: be status
Map<String, List<BeClusterInfo>> result = Maps.newHashMap();
// Key: cluster_name Value: be status
Map<String, List<BeClusterInfo>> result = Maps.newHashMap();

((CloudSystemInfoService) Env.getCurrentSystemInfo()).getCloudClusterIdToBackend()
.forEach((clusterId, backends) -> {
List<BeClusterInfo> bis = backends.stream().map(backend -> {
BeClusterInfo bi = new BeClusterInfo();
bi.host = backend.getHost();
bi.heartbeatPort = backend.getHeartbeatPort();
bi.bePort = backend.getBePort();
bi.httpPort = backend.getHttpPort();
bi.brpcPort = backend.getBrpcPort();
bi.currentFragmentNum = backend.getBackendStatus().currentFragmentNum;
bi.lastFragmentUpdateTime = backend.getBackendStatus().lastFragmentUpdateTime;
return bi; }).collect(Collectors.toList());
result.put(clusterId, bis);
});
((CloudSystemInfoService) Env.getCurrentSystemInfo()).getCloudClusterIdToBackend()
.forEach((clusterId, backends) -> {
List<BeClusterInfo> bis = backends.stream().map(backend -> {
BeClusterInfo bi = new BeClusterInfo();
bi.host = backend.getHost();
bi.heartbeatPort = backend.getHeartbeatPort();
bi.bePort = backend.getBePort();
bi.httpPort = backend.getHttpPort();
bi.brpcPort = backend.getBrpcPort();
bi.currentFragmentNum = backend.getBackendStatus().currentFragmentNum;
bi.lastFragmentUpdateTime = backend.getBackendStatus().lastFragmentUpdateTime;
return bi;
}).collect(Collectors.toList());
result.put(clusterId, bis);
});

return ResponseEntityBuilder.ok(result);
ret = ResponseEntityBuilder.ok(result);
}
} finally {
if (LOG.isDebugEnabled()) {
LOG.debug("request {}, response {}", request.getRequestURI(), ret);
}
}
return ret;
}
}
13 changes: 5 additions & 8 deletions fe/fe-core/src/main/java/org/apache/doris/system/Backend.java
Original file line number Diff line number Diff line change
Expand Up @@ -797,13 +797,8 @@ public boolean equals(Object obj) {
public String toString() {
return "Backend [id=" + id + ", host=" + host + ", heartbeatPort=" + heartbeatPort + ", alive=" + isAlive.get()
+ ", lastStartTime=" + TimeUtils.longToTimeString(lastStartTime) + ", process epoch=" + lastStartTime
+ ", isDecommissioned=" + isDecommissioned + ", tags: " + tagMap + "]";
}

public String getHealthyStatus() {
return "Backend [id=" + id + ", isDecommission: " + isDecommissioned
+ ", backendStatus: " + backendStatus + ", isAlive: " + isAlive.get() + ", lastUpdateTime: "
+ TimeUtils.longToTimeString(lastUpdateMs);
+ ", isDecommissioned=" + isDecommissioned + ", tags: " + tagMap + "]"
+ ", backendStatus: " + backendStatus;
}

/**
Expand Down Expand Up @@ -945,7 +940,9 @@ public class BackendStatus {
public String toString() {
return "[" + "lastSuccessReportTabletsTime='" + lastSuccessReportTabletsTime + '\''
+ ", lastStreamLoadTime=" + lastStreamLoadTime + ", isQueryDisabled=" + isQueryDisabled
+ ", isLoadDisabled=" + isLoadDisabled + "]";
+ ", isLoadDisabled=" + isLoadDisabled
+ ", currentFragmentNum=" + currentFragmentNum
+ ", lastFragmentUpdateTime=" + lastFragmentUpdateTime + "]";
}
}

Expand Down

0 comments on commit 04232ca

Please sign in to comment.