Search in sources :

Example 1 with Channel

use of io.grpc.channelz.v1.Channel in project ysoserial by frohoff.

the class JBoss method getChannel.

private static Channel getChannel(ConnectionProviderContextImpl context, ConnectionHandler ch, OptionMap options) throws IOException {
    Channel c;
    FutureResult<Channel> chResult = new FutureResult<Channel>(context.getExecutor());
    ch.open("jmx", chResult, options);
    IoFuture<Channel> cFuture = chResult.getIoFuture();
    Status s2 = cFuture.await();
    if (s2 == Status.FAILED) {
        System.err.println("Cannot connect");
        if (cFuture.getException() != null) {
            throw new IOException("Connect failed", cFuture.getException());
        }
    } else if (s2 != Status.DONE) {
        cFuture.cancel();
        throw new IOException("Connect timeout");
    }
    c = cFuture.get();
    return c;
}
Also used : Status(org.xnio.IoFuture.Status) FutureResult(org.xnio.FutureResult) Channel(org.jboss.remoting3.Channel) IOException(java.io.IOException)

Example 2 with Channel

use of io.grpc.channelz.v1.Channel 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 3 with Channel

use of io.grpc.channelz.v1.Channel in project grpc-java by grpc.

the class ChannelzProtoUtilTest method channelTrace_withEvents.

@Test
public void channelTrace_withEvents() {
    Event event1 = new Event.Builder().setDescription("event1").setSeverity(Severity.CT_ERROR).setTimestampNanos(12).setSubchannelRef(subchannel).build();
    Event event2 = new Event.Builder().setDescription("event2").setTimestampNanos(34).setSeverity(Severity.CT_INFO).setChannelRef(channel).build();
    ChannelStats stats = toBuilder(channel.stats).setChannelTrace(new InternalChannelz.ChannelTrace.Builder().setNumEventsLogged(1234).setCreationTimeNanos(1000).setEvents(Arrays.asList(event1, event2)).build()).build();
    ChannelTraceEvent protoEvent1 = ChannelTraceEvent.newBuilder().setDescription("event1").setTimestamp(Timestamps.fromNanos(12)).setSeverity(ChannelTraceEvent.Severity.CT_ERROR).setSubchannelRef(subchannelRef).build();
    ChannelTraceEvent protoEvent2 = ChannelTraceEvent.newBuilder().setDescription("event2").setTimestamp(Timestamps.fromNanos(34)).setSeverity(ChannelTraceEvent.Severity.CT_INFO).setChannelRef(channelRef).build();
    ChannelData protoStats = channelData.toBuilder().setTrace(channelTrace.toBuilder().addAllEvents(Arrays.asList(protoEvent1, protoEvent2)).build()).build();
    assertEquals(ChannelzProtoUtil.extractChannelData(stats), protoStats);
}
Also used : ChannelStats(io.grpc.InternalChannelz.ChannelStats) ChannelData(io.grpc.channelz.v1.ChannelData) InternalChannelz(io.grpc.InternalChannelz) ChannelTraceEvent(io.grpc.channelz.v1.ChannelTraceEvent) Event(io.grpc.InternalChannelz.ChannelTrace.Event) ChannelTraceEvent(io.grpc.channelz.v1.ChannelTraceEvent) Test(org.junit.Test)

Example 4 with Channel

use of io.grpc.channelz.v1.Channel in project ysoserial by frohoff.

the class JBoss method doRun.

private static void doRun(URI u, final Object payloadObject, String username, String password) {
    ConnectionProvider instance = null;
    ConnectionProviderContextImpl context = null;
    ConnectionHandler ch = null;
    Channel c = null;
    VersionedConnection vc = null;
    try {
        Logger logger = LogManager.getLogManager().getLogger("");
        logger.addHandler(new ConsoleLogHandler());
        logger.setLevel(Level.INFO);
        OptionMap options = OptionMap.builder().set(Options.SSL_ENABLED, u.getScheme().equals("https")).getMap();
        context = new ConnectionProviderContextImpl(options, "endpoint");
        instance = new HttpUpgradeConnectionProviderFactory().createInstance(context, options);
        String host = u.getHost();
        int port = u.getPort() > 0 ? u.getPort() : 9990;
        SocketAddress destination = new InetSocketAddress(host, port);
        ConnectionHandlerFactory chf = getConnection(destination, username, password, context, instance, options);
        ch = chf.createInstance(new ConnectionHandlerContextImpl(context));
        c = getChannel(context, ch, options);
        System.err.println("Connected");
        vc = makeVersionedConnection(c);
        MBeanServerConnection mbc = vc.getMBeanServerConnection(null);
        doExploit(payloadObject, mbc);
        System.err.println("DONE");
    } catch (Throwable e) {
        e.printStackTrace(System.err);
    } finally {
        cleanup(instance, context, ch, c, vc);
    }
}
Also used : ConnectionHandlerFactory(org.jboss.remoting3.spi.ConnectionHandlerFactory) InetSocketAddress(java.net.InetSocketAddress) Channel(org.jboss.remoting3.Channel) Logger(java.util.logging.Logger) Endpoint(org.jboss.remoting3.Endpoint) ConnectionProvider(org.jboss.remoting3.spi.ConnectionProvider) ConnectionHandler(org.jboss.remoting3.spi.ConnectionHandler) OptionMap(org.xnio.OptionMap) HttpUpgradeConnectionProviderFactory(org.jboss.remoting3.remote.HttpUpgradeConnectionProviderFactory) VersionedConnection(org.jboss.remotingjmx.VersionedConnection) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) MBeanServerConnection(javax.management.MBeanServerConnection)

Example 5 with Channel

use of io.grpc.channelz.v1.Channel in project grpc-java by grpc.

the class ChannelzService method getTopChannels.

/**
 * Returns top level channel aka {@link io.grpc.ManagedChannel}.
 */
@Override
public void getTopChannels(GetTopChannelsRequest request, StreamObserver<GetTopChannelsResponse> responseObserver) {
    InternalChannelz.RootChannelList rootChannels = channelz.getRootChannels(request.getStartChannelId(), maxPageSize);
    GetTopChannelsResponse resp;
    try {
        resp = ChannelzProtoUtil.toGetTopChannelResponse(rootChannels);
    } catch (StatusRuntimeException e) {
        responseObserver.onError(e);
        return;
    }
    responseObserver.onNext(resp);
    responseObserver.onCompleted();
}
Also used : GetTopChannelsResponse(io.grpc.channelz.v1.GetTopChannelsResponse) InternalChannelz(io.grpc.InternalChannelz) StatusRuntimeException(io.grpc.StatusRuntimeException)

Aggregations

ChannelStats (io.grpc.InternalChannelz.ChannelStats)3 InternalChannelz (io.grpc.InternalChannelz)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 Channel (org.jboss.remoting3.Channel)2 Event (io.grpc.InternalChannelz.ChannelTrace.Event)1 InternalWithLogId (io.grpc.InternalWithLogId)1 Channel (io.grpc.channelz.v1.Channel)1 ChannelData (io.grpc.channelz.v1.ChannelData)1 ChannelTraceEvent (io.grpc.channelz.v1.ChannelTraceEvent)1 GetChannelResponse (io.grpc.channelz.v1.GetChannelResponse)1 GetTopChannelsResponse (io.grpc.channelz.v1.GetTopChannelsResponse)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 Logger (java.util.logging.Logger)1 MBeanServerConnection (javax.management.MBeanServerConnection)1 Endpoint (org.jboss.remoting3.Endpoint)1 HttpUpgradeConnectionProviderFactory (org.jboss.remoting3.remote.HttpUpgradeConnectionProviderFactory)1 ConnectionHandler (org.jboss.remoting3.spi.ConnectionHandler)1 ConnectionHandlerFactory (org.jboss.remoting3.spi.ConnectionHandlerFactory)1