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;
}
}
Aggregations