use of com.navercorp.pinpoint.grpc.client.ChannelFactory in project pinpoint by naver.
the class GrpcDataSender method release.
protected void release() {
ExecutorUtils.shutdownExecutorService(name, executor);
final ManagedChannel managedChannel = this.managedChannel;
if (managedChannel != null) {
ManagedChannelUtils.shutdownManagedChannel(name, managedChannel);
}
final ChannelFactory channelFactory = this.channelFactory;
if (channelFactory != null) {
channelFactory.close();
}
}
use of com.navercorp.pinpoint.grpc.client.ChannelFactory in project pinpoint by naver.
the class ChannelFactoryTest method build.
@Test
public void build() throws InterruptedException {
HeaderFactory headerFactory = new AgentHeaderFactory("agentId", "agentName", "appName", ServiceType.UNDEFINED.getCode(), System.currentTimeMillis());
CountRecordClientInterceptor countRecordClientInterceptor = new CountRecordClientInterceptor();
ChannelFactoryBuilder channelFactoryBuilder = new DefaultChannelFactoryBuilder(this.getClass().getSimpleName());
channelFactoryBuilder.setHeaderFactory(headerFactory);
channelFactoryBuilder.setNameResolverProvider(nameResolverProvider);
channelFactoryBuilder.addClientInterceptor(countRecordClientInterceptor);
channelFactoryBuilder.setClientOption(new ClientOption());
ChannelFactory channelFactory = channelFactoryBuilder.build();
ManagedChannel managedChannel = channelFactory.build("127.0.0.1", PORT);
managedChannel.getState(false);
SpanGrpc.SpanStub spanStub = SpanGrpc.newStub(managedChannel);
final QueueingStreamObserver<Empty> responseObserver = new QueueingStreamObserver<>();
logger.debug("sendSpan");
StreamObserver<PSpanMessage> sendSpan = spanStub.sendSpan(responseObserver);
PSpan pSpan = newSpan();
PSpanMessage message = PSpanMessage.newBuilder().setSpan(pSpan).build();
logger.debug("client-onNext");
sendSpan.onNext(message);
logger.debug("wait for response");
Empty value = responseObserver.getValue();
logger.debug("response:{}", value);
logger.debug("client-onCompleted");
sendSpan.onCompleted();
Assert.assertEquals(1, countRecordClientInterceptor.getExecutedInterceptCallCount());
logger.debug("state:{}", managedChannel.getState(true));
spanService.awaitOnCompleted();
logger.debug("managedChannel shutdown");
managedChannel.shutdown();
managedChannel.awaitTermination(1000, TimeUnit.MILLISECONDS);
channelFactory.close();
}
use of com.navercorp.pinpoint.grpc.client.ChannelFactory in project pinpoint by naver.
the class AgentGrpcDataSenderTestMain method request.
public void request() throws Exception {
MessageConverter<MetaDataType, GeneratedMessageV3> messageConverter = new GrpcMetadataMessageConverter();
HeaderFactory headerFactory = new AgentHeaderFactory(AGENT_ID, AGENT_NAME, APPLICATION_NAME, SERVICE_TYPE, START_TIME);
DnsExecutorServiceProvider dnsExecutorServiceProvider = new DnsExecutorServiceProvider();
GrpcNameResolverProvider grpcNameResolverProvider = new GrpcNameResolverProvider(dnsExecutorServiceProvider);
NameResolverProvider nameResolverProvider = grpcNameResolverProvider.get();
ChannelFactoryBuilder channelFactoryBuilder = new DefaultChannelFactoryBuilder("TestAgentGrpcDataSender");
channelFactoryBuilder.setHeaderFactory(headerFactory);
channelFactoryBuilder.setNameResolverProvider(nameResolverProvider);
channelFactoryBuilder.setClientOption(new ClientOption());
ChannelFactory channelFactory = channelFactoryBuilder.build();
AgentGrpcDataSender<MetaDataType> sender = new AgentGrpcDataSender<>("localhost", 9997, 1, messageConverter, reconnectExecutor, scheduledExecutorService, channelFactory, null);
AgentInfo agentInfo = newAgentInfo();
sender.request(agentInfo);
TimeUnit.SECONDS.sleep(60);
sender.stop();
}
use of com.navercorp.pinpoint.grpc.client.ChannelFactory in project pinpoint by naver.
the class AgentGrpcDataSenderProvider method get.
@Override
public EnhancedDataSender<MetaDataType> get() {
final String collectorIp = grpcTransportConfig.getAgentCollectorIp();
final int collectorPort = grpcTransportConfig.getAgentCollectorPort();
final boolean sslEnable = grpcTransportConfig.isAgentSslEnable();
final int senderExecutorQueueSize = grpcTransportConfig.getAgentSenderExecutorQueueSize();
final ChannelFactoryBuilder channelFactoryBuilder = newChannelFactoryBuilder(sslEnable);
ChannelFactory channelFactory = channelFactoryBuilder.build();
final ReconnectExecutor reconnectExecutor = reconnectExecutorProvider.get();
final ProfilerCommandServiceLocator profilerCommandServiceLocator = createProfilerCommandServiceLocator(activeTraceRepository);
MessageConverter<MetaDataType, GeneratedMessageV3> messageConverter = this.messageConverter;
return newAgentGrpcDataSender(collectorIp, collectorPort, senderExecutorQueueSize, messageConverter, channelFactory, reconnectExecutor, retransmissionExecutor, profilerCommandServiceLocator);
}
use of com.navercorp.pinpoint.grpc.client.ChannelFactory in project pinpoint by naver.
the class SpanGrpcDataSenderProvider method get.
@Override
public DataSender<SpanType> get() {
final String collectorIp = grpcTransportConfig.getSpanCollectorIp();
final int collectorPort = grpcTransportConfig.getSpanCollectorPort();
final boolean sslEnable = grpcTransportConfig.isSpanSslEnable();
final int senderExecutorQueueSize = grpcTransportConfig.getSpanSenderExecutorQueueSize();
final ChannelFactoryBuilder channelFactoryBuilder = newChannelFactoryBuilder(sslEnable);
final ChannelFactory channelFactory = channelFactoryBuilder.build();
final ReconnectExecutor reconnectExecutor = this.reconnectExecutor.get();
ClientOption spanClientOption = grpcTransportConfig.getSpanClientOption();
final StreamState failState = new SimpleStreamState(spanClientOption.getLimitCount(), spanClientOption.getLimitTime());
logger.info("failState:{}", failState);
final SpanGrpcDataSender spanGrpcDataSender = new SpanGrpcDataSender(collectorIp, collectorPort, senderExecutorQueueSize, messageConverter, reconnectExecutor, channelFactory, failState);
registerChannelzReporter(spanGrpcDataSender);
return spanGrpcDataSender;
}
Aggregations