@Test public void getSubchannel() throws Exception { TestChannel subchannel = new TestChannel(); assertSubchannelNotFound(subchannel.getLogId().getId()); channelz.addSubchannel(subchannel); assertEquals( GetSubchannelResponse .newBuilder() .setSubchannel(ChannelzProtoUtil.toSubchannel(subchannel)) .build(), getSubchannelHelper(subchannel.getLogId().getId())); channelz.removeSubchannel(subchannel); assertSubchannelNotFound(subchannel.getLogId().getId()); }
@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(); }
ChannelzService extends ChannelzGrpc.ChannelzImplBase { @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(); } }
ChannelzService extends ChannelzGrpc.ChannelzImplBase { @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(); } @VisibleForTesting  ChannelzService(InternalChannelz channelz, int maxPageSize); }
ChannelzService extends ChannelzGrpc.ChannelzImplBase { @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(); } @VisibleForTesting  ChannelzService(InternalChannelz channelz, int maxPageSize); static ChannelzService newInstance(int maxPageSize); @Override void getTopChannels(
      GetTopChannelsRequest request, StreamObserver<GetTopChannelsResponse> responseObserver); @Override void getChannel(
      GetChannelRequest request, StreamObserver<GetChannelResponse> responseObserver); @Override void getServers(
      GetServersRequest request, StreamObserver<GetServersResponse> responseObserver); @Override void getSubchannel(
      GetSubchannelRequest request, StreamObserver<GetSubchannelResponse> responseObserver); @Override void getSocket(
      GetSocketRequest request, StreamObserver<GetSocketResponse> responseObserver); @Override void getServerSockets(
      GetServerSocketsRequest request, StreamObserver<GetServerSocketsResponse> responseObserver); }
ChannelzService extends ChannelzGrpc.ChannelzImplBase { @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(); } @VisibleForTesting  ChannelzService(InternalChannelz channelz, int maxPageSize); static ChannelzService newInstance(int maxPageSize); @Override void getTopChannels(
      GetTopChannelsRequest request, StreamObserver<GetTopChannelsResponse> responseObserver); @Override void getChannel(
      GetChannelRequest request, StreamObserver<GetChannelResponse> responseObserver); @Override void getServers(
      GetServersRequest request, StreamObserver<GetServersResponse> responseObserver); @Override void getSubchannel(
      GetSubchannelRequest request, StreamObserver<GetSubchannelResponse> responseObserver); @Override void getSocket(
      GetSocketRequest request, StreamObserver<GetSocketResponse> responseObserver); @Override void getServerSockets(
      GetServerSocketsRequest request, StreamObserver<GetServerSocketsResponse> responseObserver);  }