Search in sources :

Example 36 with ServerInterceptor

use of io.grpc.ServerInterceptor 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 37 with ServerInterceptor

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

the class HeaderServerInterceptorFactory method newServerInterceptors.

private List<ServerInterceptor> newServerInterceptors(String name) {
    HeaderReader<Header> headerReader = new AgentHeaderReader(name);
    ServerInterceptor interceptor = new HeaderPropagationInterceptor(headerReader);
    return Arrays.asList(interceptor);
}
Also used : AgentHeaderReader(com.navercorp.pinpoint.grpc.server.AgentHeaderReader) Header(com.navercorp.pinpoint.grpc.Header) HeaderPropagationInterceptor(com.navercorp.pinpoint.grpc.server.HeaderPropagationInterceptor) ServerInterceptor(io.grpc.ServerInterceptor)

Aggregations

ServerInterceptor (io.grpc.ServerInterceptor)37 Metadata (io.grpc.Metadata)23 Test (org.junit.Test)15 ServerCall (io.grpc.ServerCall)10 ServerCallHandler (io.grpc.ServerCallHandler)9 SimpleForwardingServerCallListener (io.grpc.ForwardingServerCallListener.SimpleForwardingServerCallListener)7 Server (io.grpc.Server)6 IOException (java.io.IOException)6 SimpleForwardingServerCall (io.grpc.ForwardingServerCall.SimpleForwardingServerCall)4 Status (io.grpc.Status)4 ManagedChannel (io.grpc.ManagedChannel)3 Listener (io.grpc.ServerCall.Listener)3 ServerTransportFilter (io.grpc.ServerTransportFilter)3 InetSocketAddress (java.net.InetSocketAddress)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 TraceContext (brave.propagation.TraceContext)2 GrpcStreamConfiguration (com.navercorp.pinpoint.collector.grpc.config.GrpcStreamConfiguration)2 DefaultServerRequestFactory (com.navercorp.pinpoint.collector.receiver.grpc.service.DefaultServerRequestFactory)2 StreamExecutorServerInterceptorFactory (com.navercorp.pinpoint.collector.receiver.grpc.service.StreamExecutorServerInterceptorFactory)2 MetadataServerTransportFilter (com.navercorp.pinpoint.grpc.server.MetadataServerTransportFilter)2