use of io.grpc.InternalWithLogId in project pinpoint by naver.
the class DefaultChannelzReporter method reportSubChannel.
private void reportSubChannel(long rootChannelId, List<InternalWithLogId> subChannels) {
for (InternalWithLogId subChannelLogId : subChannels) {
final long subChannelId = subChannelLogId.getLogId().getId();
final InternalInstrumented<InternalChannelz.ChannelStats> iSubChannelState = channelz.getSubchannel(subChannelId);
if (iSubChannelState == null) {
continue;
}
final String rootChannelName = rootChannelId + "-SubChannel-" + subChannelId;
final InternalChannelz.ChannelStats subChannelStats = ChannelzUtils.getResult(rootChannelName, iSubChannelState);
if (subChannelStats == null) {
continue;
}
this.reporter.reportChannelStats(rootChannelName, subChannelStats);
for (InternalWithLogId socketId : subChannelStats.sockets) {
reportSocketStats(subChannelId, socketId);
}
}
}
use of io.grpc.InternalWithLogId in project pinpoint by naver.
the class ManagedChannelUtils method getLogId.
public static long getLogId(Channel channel) {
if (channel == null) {
return -1;
}
if (channel instanceof InternalWithLogId) {
InternalWithLogId logId = (InternalWithLogId) channel;
return logId.getLogId().getId();
}
final String channelString = channel.toString();
final int start = channelString.indexOf(LOG_ID_STR);
if (start == -1) {
return -1;
}
final int end = channelString.indexOf(',', start + LOG_ID_STR.length());
if (end == -1) {
return -1;
}
final String logId = channelString.substring(start + LOG_ID_STR.length(), end);
return Long.parseLong(logId);
}
use of io.grpc.InternalWithLogId in project grpc-java by grpc.
the class ChannelzProtoUtil method toChannel.
static Channel toChannel(InternalInstrumented<ChannelStats> channel) {
ChannelStats stats = getFuture(channel.getStats());
Channel.Builder channelBuilder = Channel.newBuilder().setRef(toChannelRef(channel)).setData(extractChannelData(stats));
for (InternalWithLogId subchannel : stats.subchannels) {
channelBuilder.addSubchannelRef(toSubchannelRef(subchannel));
}
return channelBuilder.build();
}
use of io.grpc.InternalWithLogId in project grpc-java by grpc.
the class InternalSubchannelTest method channelzStatContainsTransport.
@Test
public void channelzStatContainsTransport() throws Exception {
SocketAddress addr = new SocketAddress() {
};
assertThat(transports).isEmpty();
createInternalSubchannel(addr);
internalSubchannel.obtainActiveTransport();
InternalWithLogId registeredTransport = Iterables.getOnlyElement(internalSubchannel.getStats().get().sockets);
MockClientTransportInfo actualTransport = Iterables.getOnlyElement(transports);
assertEquals(actualTransport.transport.getLogId(), registeredTransport.getLogId());
}
use of io.grpc.InternalWithLogId in project grpc-java by grpc.
the class ChannelzProtoUtil method toSubchannel.
static Subchannel toSubchannel(InternalInstrumented<ChannelStats> subchannel) {
ChannelStats stats = getFuture(subchannel.getStats());
Subchannel.Builder subchannelBuilder = Subchannel.newBuilder().setRef(toSubchannelRef(subchannel)).setData(extractChannelData(stats));
Preconditions.checkState(stats.sockets.isEmpty() || stats.subchannels.isEmpty());
for (InternalWithLogId childSocket : stats.sockets) {
subchannelBuilder.addSocketRef(toSocketRef(childSocket));
}
for (InternalWithLogId childSubchannel : stats.subchannels) {
subchannelBuilder.addSubchannelRef(toSubchannelRef(childSubchannel));
}
return subchannelBuilder.build();
}
Aggregations