Search in sources :

Example 1 with GetNodesResponse

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();
}
Also used : HostPort(com.yelp.nrtsearch.server.utils.HostPort) GetNodesResponse(com.yelp.nrtsearch.server.grpc.GetNodesResponse)

Aggregations

GetNodesResponse (com.yelp.nrtsearch.server.grpc.GetNodesResponse)1 HostPort (com.yelp.nrtsearch.server.utils.HostPort)1