@Test public void getChannel() throws ExecutionException, InterruptedException { TestChannel root = new TestChannel(); assertChannelNotFound(root.getLogId().getId()); channelz.addRootChannel(root); assertEquals( GetChannelResponse .newBuilder() .setChannel(ChannelzProtoUtil.toChannel(root)) .build(), getChannelHelper(root.getLogId().getId())); channelz.removeRootChannel(root); assertChannelNotFound(root.getLogId().getId()); }
@Override public void getChannel( GetChannelRequest request, StreamObserver<GetChannelResponse> responseObserver) { InternalInstrumented<ChannelStats> s = channelz.getRootChannel(request.getChannelId()); if (s == null) { responseObserver.onError( Status.NOT_FOUND.withDescription("Can't find channel " + request.getChannelId()) .asRuntimeException()); return; } GetChannelResponse resp; try { resp = GetChannelResponse .newBuilder() .setChannel(ChannelzProtoUtil.toChannel(s)) .build(); } catch (StatusRuntimeException e) { responseObserver.onError(e); return; } responseObserver.onNext(resp); responseObserver.onCompleted(); }
ChannelzService extends ChannelzGrpc.ChannelzImplBase { @Override public void getChannel( GetChannelRequest request, StreamObserver<GetChannelResponse> responseObserver) { InternalInstrumented<ChannelStats> s = channelz.getRootChannel(request.getChannelId()); if (s == null) { responseObserver.onError( Status.NOT_FOUND.withDescription("Can't find channel " + request.getChannelId()) .asRuntimeException()); return; } GetChannelResponse resp; try { resp = GetChannelResponse .newBuilder() .setChannel(ChannelzProtoUtil.toChannel(s)) .build(); } catch (StatusRuntimeException e) { responseObserver.onError(e); return; } responseObserver.onNext(resp); responseObserver.onCompleted(); } }
ChannelzService extends ChannelzGrpc.ChannelzImplBase { @Override public void getChannel( GetChannelRequest request, StreamObserver<GetChannelResponse> responseObserver) { InternalInstrumented<ChannelStats> s = channelz.getRootChannel(request.getChannelId()); if (s == null) { responseObserver.onError( Status.NOT_FOUND.withDescription("Can't find channel " + request.getChannelId()) .asRuntimeException()); return; } GetChannelResponse resp; try { resp = GetChannelResponse .newBuilder() .setChannel(ChannelzProtoUtil.toChannel(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 getChannel( GetChannelRequest request, StreamObserver<GetChannelResponse> responseObserver) { InternalInstrumented<ChannelStats> s = channelz.getRootChannel(request.getChannelId()); if (s == null) { responseObserver.onError( Status.NOT_FOUND.withDescription("Can't find channel " + request.getChannelId()) .asRuntimeException()); return; } GetChannelResponse resp; try { resp = GetChannelResponse .newBuilder() .setChannel(ChannelzProtoUtil.toChannel(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 getChannel( GetChannelRequest request, StreamObserver<GetChannelResponse> responseObserver) { InternalInstrumented<ChannelStats> s = channelz.getRootChannel(request.getChannelId()); if (s == null) { responseObserver.onError( Status.NOT_FOUND.withDescription("Can't find channel " + request.getChannelId()) .asRuntimeException()); return; } GetChannelResponse resp; try { resp = GetChannelResponse .newBuilder() .setChannel(ChannelzProtoUtil.toChannel(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);  }