Search in sources :

Example 11 with MetaDataType

use of com.navercorp.pinpoint.profiler.metadata.MetaDataType in project pinpoint by naver.

the class NioUdpDataSenderTest method sendTest1.

@Test
public void sendTest1() throws Exception {
    NioUDPDataSender<MetaDataType> sender = newNioUdpDataSender();
    int sendMessageCount = 10;
    for (int i = 0; i < 10; i++) {
        MetaDataType metaData = new StringMetaData(i, "test");
        sender.send(metaData);
    }
    try {
        waitMessageReceived(sendMessageCount);
    } finally {
        sender.stop();
    }
}
Also used : StringMetaData(com.navercorp.pinpoint.profiler.metadata.StringMetaData) MetaDataType(com.navercorp.pinpoint.profiler.metadata.MetaDataType) Test(org.junit.Test)

Example 12 with MetaDataType

use of com.navercorp.pinpoint.profiler.metadata.MetaDataType in project pinpoint by naver.

the class NioUdpDataSenderTest method exceedMessageSendTest.

@Test(expected = IOException.class)
public void exceedMessageSendTest() throws IOException {
    String random = RandomStringUtils.randomAlphabetic(ThriftUdpMessageSerializer.UDP_MAX_PACKET_LENGTH + 100);
    MetaDataType metaData = new StringMetaData(1, random);
    NioUDPDataSender<MetaDataType> sender = newNioUdpDataSender();
    sender.send(metaData);
    waitMessageReceived(1);
}
Also used : StringMetaData(com.navercorp.pinpoint.profiler.metadata.StringMetaData) MetaDataType(com.navercorp.pinpoint.profiler.metadata.MetaDataType) Test(org.junit.Test)

Example 13 with MetaDataType

use of com.navercorp.pinpoint.profiler.metadata.MetaDataType 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();
}
Also used : NameResolverProvider(io.grpc.NameResolverProvider) GrpcNameResolverProvider(com.navercorp.pinpoint.profiler.context.provider.grpc.GrpcNameResolverProvider) HeaderFactory(com.navercorp.pinpoint.grpc.client.HeaderFactory) AgentHeaderFactory(com.navercorp.pinpoint.grpc.AgentHeaderFactory) ChannelFactory(com.navercorp.pinpoint.grpc.client.ChannelFactory) ChannelFactoryBuilder(com.navercorp.pinpoint.grpc.client.ChannelFactoryBuilder) DefaultChannelFactoryBuilder(com.navercorp.pinpoint.grpc.client.DefaultChannelFactoryBuilder) DefaultChannelFactoryBuilder(com.navercorp.pinpoint.grpc.client.DefaultChannelFactoryBuilder) MetaDataType(com.navercorp.pinpoint.profiler.metadata.MetaDataType) GrpcNameResolverProvider(com.navercorp.pinpoint.profiler.context.provider.grpc.GrpcNameResolverProvider) GrpcMetadataMessageConverter(com.navercorp.pinpoint.profiler.context.grpc.GrpcMetadataMessageConverter) AgentInfo(com.navercorp.pinpoint.profiler.metadata.AgentInfo) DnsExecutorServiceProvider(com.navercorp.pinpoint.profiler.context.provider.grpc.DnsExecutorServiceProvider) ClientOption(com.navercorp.pinpoint.grpc.client.config.ClientOption) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) AgentHeaderFactory(com.navercorp.pinpoint.grpc.AgentHeaderFactory)

Example 14 with MetaDataType

use of com.navercorp.pinpoint.profiler.metadata.MetaDataType 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);
}
Also used : ReconnectExecutor(com.navercorp.pinpoint.profiler.sender.grpc.ReconnectExecutor) MetaDataType(com.navercorp.pinpoint.profiler.metadata.MetaDataType) ChannelFactory(com.navercorp.pinpoint.grpc.client.ChannelFactory) ProfilerCommandServiceLocator(com.navercorp.pinpoint.profiler.receiver.ProfilerCommandServiceLocator) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) ChannelFactoryBuilder(com.navercorp.pinpoint.grpc.client.ChannelFactoryBuilder) DefaultChannelFactoryBuilder(com.navercorp.pinpoint.grpc.client.DefaultChannelFactoryBuilder)

Example 15 with MetaDataType

use of com.navercorp.pinpoint.profiler.metadata.MetaDataType in project pinpoint by naver.

the class AgentInfoSenderTest method agentInfoShouldRetryUntilSuccess.

@Test
public void agentInfoShouldRetryUntilSuccess() {
    final long agentInfoSendRetryIntervalMs = 100L;
    final int maxTryPerAttempt = 3;
    final int expectedTriesUntilSuccess = maxTryPerAttempt;
    final ResponseServerMessageListenerFactory messageListenerFactory = new ResponseServerMessageListenerFactory(expectedTriesUntilSuccess);
    ResponseServerMessageListener messageListener = messageListenerFactory.create();
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(messageListenerFactory);
    int bindPort = testPinpointServerAcceptor.bind();
    PinpointClientFactory socketFactory = createPinpointClientFactory();
    EnhancedDataSender<MetaDataType> dataSender = newTcpDataSender(socketFactory, bindPort);
    AgentInfoSender agentInfoSender = new AgentInfoSender.Builder(dataSender, agentInfoFactory).maxTryPerAttempt(maxTryPerAttempt).sendInterval(agentInfoSendRetryIntervalMs).setMessageConverter(resultResponseMessageConverter).build();
    try {
        agentInfoSender.start();
        waitExpectedRequestCount(expectedTriesUntilSuccess, messageListener);
    } finally {
        closeAll(agentInfoSender, socketFactory);
        testPinpointServerAcceptor.close();
    }
    assertEquals(expectedTriesUntilSuccess, messageListener.getRequestCount());
    assertEquals(1, messageListener.getSuccessCount());
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) MetaDataType(com.navercorp.pinpoint.profiler.metadata.MetaDataType) Test(org.junit.Test)

Aggregations

MetaDataType (com.navercorp.pinpoint.profiler.metadata.MetaDataType)19 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)12 Test (org.junit.Test)10 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)9 TestPinpointServerAcceptor (com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor)8 ServerMetaDataRegistryService (com.navercorp.pinpoint.profiler.context.ServerMetaDataRegistryService)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 TypeLiteral (com.google.inject.TypeLiteral)2 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)2 ChannelFactory (com.navercorp.pinpoint.grpc.client.ChannelFactory)2 ChannelFactoryBuilder (com.navercorp.pinpoint.grpc.client.ChannelFactoryBuilder)2 DefaultChannelFactoryBuilder (com.navercorp.pinpoint.grpc.client.DefaultChannelFactoryBuilder)2 SpanType (com.navercorp.pinpoint.profiler.context.SpanType)2 DefaultTransactionIdEncoder (com.navercorp.pinpoint.profiler.context.thrift.DefaultTransactionIdEncoder)2 StringMetaData (com.navercorp.pinpoint.profiler.metadata.StringMetaData)2 MetricType (com.navercorp.pinpoint.profiler.monitor.metric.MetricType)2 DataSender (com.navercorp.pinpoint.profiler.sender.DataSender)2 EnhancedDataSender (com.navercorp.pinpoint.profiler.sender.EnhancedDataSender)2 PinpointClient (com.navercorp.pinpoint.rpc.client.PinpointClient)2 PinpointClientReconnectEventListener (com.navercorp.pinpoint.rpc.client.PinpointClientReconnectEventListener)2