use of io.grpc.channelz.v1.GetSubchannelResponse in project grpc-java by grpc.
the class ChannelzService method getSubchannel.
/**
* Returns a subchannel.
*/
@Override
public void getSubchannel(GetSubchannelRequest request, StreamObserver<GetSubchannelResponse> responseObserver) {
InternalInstrumented<ChannelStats> s = channelz.getSubchannel(request.getSubchannelId());
if (s == null) {
responseObserver.onError(Status.NOT_FOUND.withDescription("Can't find subchannel " + request.getSubchannelId()).asRuntimeException());
return;
}
GetSubchannelResponse resp;
try {
resp = GetSubchannelResponse.newBuilder().setSubchannel(ChannelzProtoUtil.toSubchannel(s)).build();
} catch (StatusRuntimeException e) {
responseObserver.onError(e);
return;
}
responseObserver.onNext(resp);
responseObserver.onCompleted();
}
use of io.grpc.channelz.v1.GetSubchannelResponse in project grpc-java by grpc.
the class ChannelzServiceTest method assertSubchannelNotFound.
private void assertSubchannelNotFound(long id) {
@SuppressWarnings("unchecked") StreamObserver<GetSubchannelResponse> observer = mock(StreamObserver.class);
ArgumentCaptor<Exception> exceptionCaptor = ArgumentCaptor.forClass(Exception.class);
service.getSubchannel(GetSubchannelRequest.newBuilder().setSubchannelId(id).build(), observer);
verify(observer).onError(exceptionCaptor.capture());
Status s = Status.fromThrowable(exceptionCaptor.getValue());
assertWithMessage(s.toString()).that(s.getCode()).isEqualTo(Status.Code.NOT_FOUND);
}
Aggregations