use of com.navercorp.pinpoint.grpc.server.TransportMetadataFactory 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;
}
}
use of com.navercorp.pinpoint.grpc.server.TransportMetadataFactory in project pinpoint by naver.
the class ChannelFactoryTest method addFilter.
private static void addFilter(ServerFactory serverFactory) {
TransportMetadataFactory transportMetadataFactory = new TransportMetadataFactory(ChannelFactoryTest.class.getSimpleName());
final ServerTransportFilter metadataTransportFilter = new MetadataServerTransportFilter(transportMetadataFactory);
serverFactory.addTransportFilter(metadataTransportFilter);
ServerInterceptor transportMetadataServerInterceptor = new TransportMetadataServerInterceptor();
serverFactory.addInterceptor(transportMetadataServerInterceptor);
}
Aggregations