Search in sources :

Example 1 with InternalWithLogId

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);
        }
    }
}
Also used : InternalChannelz(io.grpc.InternalChannelz) InternalWithLogId(io.grpc.InternalWithLogId)

Example 2 with InternalWithLogId

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);
}
Also used : InternalWithLogId(io.grpc.InternalWithLogId)

Example 3 with InternalWithLogId

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();
}
Also used : ChannelStats(io.grpc.InternalChannelz.ChannelStats) Channel(io.grpc.channelz.v1.Channel) InternalWithLogId(io.grpc.InternalWithLogId)

Example 4 with InternalWithLogId

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());
}
Also used : InternalWithLogId(io.grpc.InternalWithLogId) MockClientTransportInfo(io.grpc.internal.TestUtils.MockClientTransportInfo) SocketAddress(java.net.SocketAddress) Test(org.junit.Test)

Example 5 with InternalWithLogId

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();
}
Also used : ChannelStats(io.grpc.InternalChannelz.ChannelStats) Subchannel(io.grpc.channelz.v1.Subchannel) InternalWithLogId(io.grpc.InternalWithLogId)

Aggregations

InternalWithLogId (io.grpc.InternalWithLogId)7 ChannelStats (io.grpc.InternalChannelz.ChannelStats)2 BindableService (io.grpc.BindableService)1 InternalChannelz (io.grpc.InternalChannelz)1 Server (io.grpc.Server)1 ServerInterceptor (io.grpc.ServerInterceptor)1 ServerServiceDefinition (io.grpc.ServerServiceDefinition)1 ServerTransportFilter (io.grpc.ServerTransportFilter)1 Channel (io.grpc.channelz.v1.Channel)1 Subchannel (io.grpc.channelz.v1.Subchannel)1 MockClientTransportInfo (io.grpc.internal.TestUtils.MockClientTransportInfo)1 LogIdServerListenerDelegator (io.grpc.netty.LogIdServerListenerDelegator)1 PinpointNettyServerBuilder (io.grpc.netty.PinpointNettyServerBuilder)1 SslContext (io.netty.handler.ssl.SslContext)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 Test (org.junit.Test)1