use of com.yelp.nrtsearch.server.grpc.GetNodesResponse in project nrtsearch by Yelp.
the class GetNodesInfoHandler method handle.
@Override
public GetNodesResponse handle(IndexState indexState, GetNodesRequest getNodesRequest) throws HandlerException {
GetNodesResponse.Builder builder = GetNodesResponse.newBuilder();
ShardState shardState = indexState.getShard(0);
if (!shardState.isPrimary() || !shardState.isStarted()) {
logger.warn("index \"" + indexState.name + "\" is not a primary or was not started yet");
} else {
// shard is a primary and started
Collection<NRTPrimaryNode.ReplicaDetails> replicasInfo = shardState.nrtPrimaryNode.getNodesInfo();
for (NRTPrimaryNode.ReplicaDetails replica : replicasInfo) {
HostPort hostPort = replica.getHostPort();
builder.addNodes(NodeInfo.newBuilder().setHostname(hostPort.getHostName()).setPort(hostPort.getPort()).build());
}
}
return builder.build();
}
Aggregations