Skip to content

Commit

Permalink
fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
deardeng committed Jan 29, 2024
1 parent 7c14a58 commit 06508f8
Showing 1 changed file with 29 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,6 @@ private void checkDiffNode(Map<String, ClusterPB> remoteClusterIdToPB,
protected void runAfterCatalogReady() {
getCloudBackends();
updateCloudMetrics();
LOG.info("daemon cluster get cluster info succ, current cloudClusterIdToBackendMap: {}",
Env.getCurrentSystemInfo().getCloudClusterIdToBackend());
getCloudObserverFes();
}

Expand Down Expand Up @@ -415,35 +413,38 @@ private void getCloudBackends() {
&& response.getStatus().getCode() != MetaServiceCode.CLUSTER_NOT_FOUND)) {
LOG.warn("failed to get cloud cluster due to incomplete response, "
+ "cloud_unique_id={}, response={}", Config.cloud_unique_id, response);
} else {
Set<String> localClusterIds = clusterIdToBackend.keySet();
// clusterId -> clusterPB
Map<String, ClusterPB> remoteClusterIdToPB = response.getClusterList().stream()
.filter(c -> c.getType() != Type.SQL)
.collect(Collectors.toMap(ClusterPB::getClusterId, clusterPB -> clusterPB));
LOG.info("get cluster info clusterIds: {}", remoteClusterIdToPB);

try {
// cluster_ids diff remote <clusterId, nodes> and local <clusterId, nodes>
// remote - local > 0, add bes to local
checkToAddCluster(remoteClusterIdToPB, localClusterIds);

// local - remote > 0, drop bes from local
checkToDelCluster(remoteClusterIdToPB, localClusterIds, clusterIdToBackend);

if (remoteClusterIdToPB.keySet().size() != clusterIdToBackend.keySet().size()) {
LOG.warn("impossible cluster id size not match, check it local {}, remote {}",
clusterIdToBackend, remoteClusterIdToPB);
}
// clusterID local == remote, diff nodes
checkDiffNode(remoteClusterIdToPB, clusterIdToBackend);
return;
}
Set<String> localClusterIds = clusterIdToBackend.keySet();
// clusterId -> clusterPB
Map<String, ClusterPB> remoteClusterIdToPB = response.getClusterList().stream()
.filter(c -> c.getType() != Type.SQL)
.collect(Collectors.toMap(ClusterPB::getClusterId, clusterPB -> clusterPB));
LOG.info("get cluster info clusterIds: {}", remoteClusterIdToPB);

try {
// cluster_ids diff remote <clusterId, nodes> and local <clusterId, nodes>
// remote - local > 0, add bes to local
checkToAddCluster(remoteClusterIdToPB, localClusterIds);

// local - remote > 0, drop bes from local
checkToDelCluster(remoteClusterIdToPB, localClusterIds, clusterIdToBackend);

// check mem map
checkFeNodesMapValid();
} catch (Exception e) {
LOG.warn("diff cluster has exception, {}", e.getMessage(), e);
if (remoteClusterIdToPB.keySet().size() != clusterIdToBackend.keySet().size()) {
LOG.warn("impossible cluster id size not match, check it local {}, remote {}",
clusterIdToBackend, remoteClusterIdToPB);
}
// clusterID local == remote, diff nodes
checkDiffNode(remoteClusterIdToPB, clusterIdToBackend);

// check mem map
checkFeNodesMapValid();
} catch (Exception e) {
LOG.warn("diff cluster has exception, {}", e.getMessage(), e);

}
LOG.info("daemon cluster get cluster info succ, current cloudClusterIdToBackendMap: {}",
Env.getCurrentSystemInfo().getCloudClusterIdToBackend());
}

private void updateCloudMetrics() {
Expand Down

0 comments on commit 06508f8

Please sign in to comment.