Search in sources :

Example 6 with InternalWithLogId

use of io.grpc.InternalWithLogId in project pinpoint by naver.

the class ServerFactory method build.

public Server build() throws SSLException {
    InetSocketAddress bindAddress = new InetSocketAddress(this.hostname, this.port);
    PinpointNettyServerBuilder serverBuilder = PinpointNettyServerBuilder.forAddress(bindAddress);
    serverBuilder.serverListenerDelegator(new LogIdServerListenerDelegator());
    logger.info("ChannelType:{}", channelType.getSimpleName());
    serverBuilder.channelType(channelType);
    serverBuilder.bossEventLoopGroup(bossEventLoopGroup);
    serverBuilder.workerEventLoopGroup(workerEventLoopGroup);
    setupInternal(serverBuilder);
    for (Object service : this.bindableServices) {
        if (service instanceof BindableService) {
            logger.info("Add BindableService={}, server={}", service, name);
            serverBuilder.addService((BindableService) service);
        } else if (service instanceof ServerServiceDefinition) {
            final ServerServiceDefinition definition = (ServerServiceDefinition) service;
            logger.info("Add ServerServiceDefinition={}, server={}", definition.getServiceDescriptor(), name);
            serverBuilder.addService(definition);
        }
    }
    for (ServerTransportFilter transportFilter : this.serverTransportFilters) {
        logger.info("Add transportFilter={}, server={}", transportFilter, name);
        serverBuilder.addTransportFilter(transportFilter);
    }
    for (ServerInterceptor serverInterceptor : this.serverInterceptors) {
        logger.info("Add intercept={}, server={}", serverInterceptor, name);
        serverBuilder.intercept(serverInterceptor);
    }
    serverBuilder.executor(serverExecutor);
    setupServerOption(serverBuilder);
    if (sslServerConfig.isEnable()) {
        logger.debug("Enable sslConfig.({})", sslServerConfig);
        SslContext sslContext = SslContextFactory.create(sslServerConfig);
        serverBuilder.sslContext(sslContext);
    }
    Server server = serverBuilder.build();
    if (server instanceof InternalWithLogId) {
        final InternalWithLogId logId = (InternalWithLogId) server;
        final long serverLogId = logId.getLogId().getId();
        logger.info("{} serverLogId:{}", name, serverLogId);
        if (channelzRegistry != null) {
            channelzRegistry.addServer(serverLogId, name);
        }
    }
    return server;
}
Also used : Server(io.grpc.Server) PinpointNettyServerBuilder(io.grpc.netty.PinpointNettyServerBuilder) InetSocketAddress(java.net.InetSocketAddress) ServerServiceDefinition(io.grpc.ServerServiceDefinition) ServerInterceptor(io.grpc.ServerInterceptor) InternalWithLogId(io.grpc.InternalWithLogId) ServerTransportFilter(io.grpc.ServerTransportFilter) LogIdServerListenerDelegator(io.grpc.netty.LogIdServerListenerDelegator) BindableService(io.grpc.BindableService) SslContext(io.netty.handler.ssl.SslContext)

Example 7 with InternalWithLogId

use of io.grpc.InternalWithLogId in project pinpoint by naver.

the class DefaultChannelzReporter method toLogIdArray.

public long[] toLogIdArray(List<InternalWithLogId> logIdList) {
    if (logIdList == null) {
        return new long[0];
    }
    long[] longs = new long[logIdList.size()];
    for (int i = 0; i < logIdList.size(); i++) {
        InternalWithLogId internalWithLogId = logIdList.get(i);
        longs[i] = internalWithLogId.getLogId().getId();
    }
    return longs;
}
Also used : 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