PragmaTwice commented on code in PR #2244:
URL: https://github.com/apache/kvrocks/pull/2244#discussion_r1563732465
##########
src/cluster/cluster.cc:
##########
@@ -469,6 +469,52 @@ Status Cluster::GetClusterNodes(std::string *nodes_str) {
return Status::OK();
}
+Status Cluster::GetReplicas(const std::string &node_id, std::string
*replicas_str) {
+ if (version_ < 0) {
+ return {Status::ClusterDown, errClusterNoInitialized};
+ }
+
+ auto item = nodes_.find(node_id);
+ if (item == nodes_.end()) {
+ return {Status::InvalidArgument, errInvalidNodeID};
+ }
+
+ auto node = item->second;
+ if (node->role != kClusterMaster) {
+ return {Status::InvalidArgument, errNoMasterNode};
+ }
+
+ replicas_str->clear();
+
+ auto now = util::GetTimeStampMS();
+ std::string replicas_desc;
+ for (const auto &replica_id : node->replicas) {
+ auto n = nodes_.find(replica_id);
+ if (n == nodes_.end()) {
+ continue;
+ }
+
+ auto replica = n->second;
+
+ std::string node_str;
+ // ID, host, port
+ node_str.append(replica_id + " ");
+ node_str.append(fmt::format("{}:{}@{} ", replica->host, replica->port,
replica->port + kClusterPortIncr));
Review Comment:
```suggestion
node_str.append(fmt::format("{} {}:{}@{} ", replica_id, replica->host,
replica->port, replica->port + kClusterPortIncr));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]