use of io.grpc.InternalChannelz.ServerList in project grpc-java by grpc.
the class ChannelzService method getServers.
/**
* Returns servers.
*/
@Override
public void getServers(GetServersRequest request, StreamObserver<GetServersResponse> responseObserver) {
ServerList servers = channelz.getServers(request.getStartServerId(), maxPageSize);
GetServersResponse resp;
try {
resp = ChannelzProtoUtil.toGetServersResponse(servers);
} catch (StatusRuntimeException e) {
responseObserver.onError(e);
return;
}
responseObserver.onNext(resp);
responseObserver.onCompleted();
}
use of io.grpc.InternalChannelz.ServerList in project grpc-java by grpc.
the class ChannelzProtoUtilTest method toGetServersResponse.
@Test
public void toGetServersResponse() {
// empty results
assertEquals(GetServersResponse.getDefaultInstance(), ChannelzProtoUtil.toGetServersResponse(new ServerList(Collections.<InternalInstrumented<ServerStats>>emptyList(), false)));
// 1 result, paginated
assertEquals(GetServersResponse.newBuilder().addServer(serverProto).build(), ChannelzProtoUtil.toGetServersResponse(new ServerList(ImmutableList.<InternalInstrumented<ServerStats>>of(server), false)));
// 1 result, end
assertEquals(GetServersResponse.newBuilder().addServer(serverProto).setEnd(true).build(), ChannelzProtoUtil.toGetServersResponse(new ServerList(ImmutableList.<InternalInstrumented<ServerStats>>of(server), true)));
TestServer server2 = new TestServer();
// 2 results, end
assertEquals(GetServersResponse.newBuilder().addServer(serverProto).addServer(ChannelzProtoUtil.toServer(server2)).setEnd(true).build(), ChannelzProtoUtil.toGetServersResponse(new ServerList(ImmutableList.<InternalInstrumented<ServerStats>>of(server, server2), true)));
}
Aggregations