DescribeReplicas()
This operation returns replica topology details, including shard leaders and node placement. Use it to inspect resource-group balancing and serving layout.
Status DescribeReplicas(const DescribeReplicasRequest& request, DescribeReplicasResponse& response)
Request Syntax
auto request = DescribeReplicasRequest()
.WithCollectionName(collection_name)
.WithDatabaseName(db_name);
DescribeReplicasRequest
REQUEST METHODS:
WithCollectionName(const std::string& collection_name)Sets the collection whose replicas you want to inspect.
WithDatabaseName(const std::string& db_name)Sets the target database. If omitted, the default database is used.
RETURNS:
Status with DescribeReplicasResponse
DescribeReplicasResponse
This class represents replica topology returned by DescribeReplicas().
const DescribeReplicasResponse& response = resp;
METHODS:
const std::vector<ReplicaInfo>& Replicas() constReturns replica entries, including shard leaders and node placement details.
ReplicaInfo
This class represents one collection replica entry returned by DescribeReplicasResponse.
const ReplicaInfo& replica = response.Replicas()[0];
METHODS:
int64_t ReplicaID() constReturns replica ID.
int64_t CollectionID() constReturns collection ID.
const std::vector<int64_t>& PartitionIDs() constReturns partition IDs served by this replica.
const std::vector<ShardReplica>& ShardReplicas() constReturns shard-level routing and leader information.
const std::vector<int64_t>& NodeIDs() constReturns node IDs participating in this replica.
const std::string& ResourceGroupName() constReturns assigned resource group name.
const std::unordered_map<std::string, int32_t>& NumOutboundNode() constReturns outbound node counts grouped by resource group.
ShardReplica
This class represents one shard replica entry inside a ReplicaInfo object.
const ShardReplica& shard = replica.ShardReplicas()[0];
METHODS:
int64_t LeaderID() constReturns leader node ID for the shard.
const std::string& LeaderAddress() constReturns network address of the shard leader.
const std::string& ChannelName() constReturns DML channel name associated with the shard.
const std::vector<int64_t>& NodeIDs() constReturns all nodes serving this shard replica.
EXCEPTIONS:
StatusCode
Check
status.Code()andstatus.Message()for invalid collection names or unavailable replica metadata.
Example
#include <milvus/MilvusClientV2.h>
auto client = milvus::MilvusClientV2::Create();
milvus::ConnectParam connect_param{"http://localhost:19530", "root:Milvus"};
auto status = client->Connect(connect_param);
if (!status.IsOk()) {
std::cout << status.Message() << std::endl;
}
milvus::DescribeReplicasResponse response;
status = client->DescribeReplicas(
milvus::DescribeReplicasRequest()
.WithCollectionName("my_collection"),
response);
if (!status.IsOk()) {
std::cout << status.Message() << std::endl;
}
for (const auto& replica : response.Replicas()) {
std::cout << replica.ReplicaID() << std::endl;
}