Skip to content

Commit

Permalink
add ms
Browse files Browse the repository at this point in the history
  • Loading branch information
deardeng committed Jul 22, 2024
1 parent e4ed733 commit 52b17e8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
21 changes: 16 additions & 5 deletions cloud/src/resource-manager/resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,18 @@ bool ResourceManager::check_cluster_params_valid(const ClusterPB& cluster, std::
std::stringstream ss;
bool no_err = true;
int master_num = 0;
int follower_num = 0;
for (auto& n : cluster.nodes()) {
if (ClusterPB::SQL == cluster.type() && n.has_edit_log_port() && n.edit_log_port() &&
n.has_node_type() &&
(n.node_type() == NodeInfoPB_NodeType_FE_MASTER ||
n.node_type() == NodeInfoPB_NodeType_FE_OBSERVER)) {
n.node_type() == NodeInfoPB_NodeType_FE_OBSERVER ||
n.node_type() == NodeInfoPB_NodeType_FE_FOLLOWER)) {
master_num += n.node_type() == NodeInfoPB_NodeType_FE_MASTER ? 1 : 0;
follower_num += n.node_type() == NodeInfoPB_NodeType_FE_FOLLOWER ? 1 : 0;
continue;
}
if (ClusterPB::COMPUTE == cluster.type() && n.has_heartbeat_port() && n.heartbeat_port()) {
} else if (ClusterPB::COMPUTE == cluster.type() && n.has_heartbeat_port() &&
n.heartbeat_port()) {
continue;
}
ss << "check cluster params failed, node : " << proto_to_json(n);
Expand All @@ -177,8 +180,16 @@ bool ResourceManager::check_cluster_params_valid(const ClusterPB& cluster, std::
// add_node doesn't check it
if (check_master_num && ClusterPB::SQL == cluster.type() && master_num != 1) {
no_err = false;
ss << "cluster is SQL type, must have only one master node, now master count: "
<< master_num;
if (master_num && follower_num) {
ss << "cluster is SQL type, and use multi follower mode, cant set master node, master "
"count: "
<< master_num << " follower count: " << follower_num;
} else if (!follower_num && master_num != 1) {
ss << "cluster is SQL type, must have only one master node, now master count: "
<< master_num;
} else {
ss << "not support SQL type mode";
}
*err = ss.str();
}
return no_err;
Expand Down
1 change: 1 addition & 0 deletions gensrc/proto/cloud.proto
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ message NodeInfoPB {
UNKNOWN = 0;
FE_MASTER = 1;
FE_OBSERVER = 2;
FE_FOLLOWER = 3;
}
optional string cloud_unique_id = 1;
optional string name = 2;
Expand Down

0 comments on commit 52b17e8

Please sign in to comment.