Search in sources :

Example 1 with SslServerConfig

use of com.navercorp.pinpoint.grpc.security.SslServerConfig in project pinpoint by naver.

the class GrpcReceiver method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws Exception {
    if (Boolean.FALSE == this.enable) {
        logger.warn("{} is {}", this.beanName, enable);
        return;
    }
    Objects.requireNonNull(this.beanName, "beanName");
    Objects.requireNonNull(this.bindAddress, "bindAddress");
    Objects.requireNonNull(this.addressFilter, "addressFilter");
    Assert.isTrue(CollectionUtils.hasLength(this.serviceList), "serviceList must not be empty");
    Objects.requireNonNull(this.serverOption, "serverOption");
    if (grpcSslConfiguration != null) {
        final SslServerConfig sslServerConfig = grpcSslConfiguration.toSslServerConfig();
        this.serverFactory = new ServerFactory(beanName, this.bindAddress.getIp(), this.bindAddress.getPort(), this.executor, serverOption, sslServerConfig);
    } else {
        this.serverFactory = new ServerFactory(beanName, this.bindAddress.getIp(), this.bindAddress.getPort(), this.executor, serverOption);
    }
    ServerTransportFilter permissionServerTransportFilter = new PermissionServerTransportFilter(this.beanName, addressFilter);
    this.serverFactory.addTransportFilter(permissionServerTransportFilter);
    TransportMetadataFactory transportMetadataFactory = new TransportMetadataFactory(beanName);
    // Mandatory interceptor
    final ServerTransportFilter metadataTransportFilter = new MetadataServerTransportFilter(transportMetadataFactory);
    this.serverFactory.addTransportFilter(metadataTransportFilter);
    if (CollectionUtils.hasLength(transportFilterList)) {
        for (ServerTransportFilter transportFilter : transportFilterList) {
            this.serverFactory.addTransportFilter(transportFilter);
        }
    }
    // Mandatory interceptor
    ServerInterceptor transportMetadataServerInterceptor = new TransportMetadataServerInterceptor();
    this.serverFactory.addInterceptor(transportMetadataServerInterceptor);
    if (CollectionUtils.hasLength(serverInterceptorList)) {
        for (ServerInterceptor serverInterceptor : serverInterceptorList) {
            this.serverFactory.addInterceptor(serverInterceptor);
        }
    }
    if (channelzRegistry != null) {
        this.serverFactory.setChannelzRegistry(channelzRegistry);
    }
    // Add service
    addService();
    this.server = serverFactory.build();
    if (logger.isInfoEnabled()) {
        logger.info("Start {} server {}", this.beanName, this.server);
    }
    try {
        this.server.start();
    } catch (Throwable th) {
        final Throwable rootCause = NestedExceptionUtils.getRootCause(th);
        if (rootCause instanceof BindException) {
            logger.error("Server bind failed. {} address:{}", this.beanName, this.bindAddress, rootCause);
        } else {
            logger.error("Server start failed. {} address:{}", this.beanName, this.bindAddress);
        }
        throw th;
    }
}
Also used : TransportMetadataServerInterceptor(com.navercorp.pinpoint.grpc.server.TransportMetadataServerInterceptor) ServerInterceptor(io.grpc.ServerInterceptor) TransportMetadataFactory(com.navercorp.pinpoint.grpc.server.TransportMetadataFactory) TransportMetadataServerInterceptor(com.navercorp.pinpoint.grpc.server.TransportMetadataServerInterceptor) BindException(java.net.BindException) ServerFactory(com.navercorp.pinpoint.grpc.server.ServerFactory) ServerTransportFilter(io.grpc.ServerTransportFilter) MetadataServerTransportFilter(com.navercorp.pinpoint.grpc.server.MetadataServerTransportFilter) MetadataServerTransportFilter(com.navercorp.pinpoint.grpc.server.MetadataServerTransportFilter) SslServerConfig(com.navercorp.pinpoint.grpc.security.SslServerConfig)

Aggregations

SslServerConfig (com.navercorp.pinpoint.grpc.security.SslServerConfig)1 MetadataServerTransportFilter (com.navercorp.pinpoint.grpc.server.MetadataServerTransportFilter)1 ServerFactory (com.navercorp.pinpoint.grpc.server.ServerFactory)1 TransportMetadataFactory (com.navercorp.pinpoint.grpc.server.TransportMetadataFactory)1 TransportMetadataServerInterceptor (com.navercorp.pinpoint.grpc.server.TransportMetadataServerInterceptor)1 ServerInterceptor (io.grpc.ServerInterceptor)1 ServerTransportFilter (io.grpc.ServerTransportFilter)1 BindException (java.net.BindException)1