Search in sources :

Example 1 with TcpDataSender

use of com.navercorp.pinpoint.profiler.sender.TcpDataSender in project pinpoint by naver.

the class TcpDataSenderProvider method get.

@Override
public EnhancedDataSender<MetaDataType> get() {
    PinpointClientFactory clientFactory = clientFactoryProvider.get();
    String collectorTcpServerIp = thriftTransportConfig.getCollectorTcpServerIp();
    int collectorTcpServerPort = thriftTransportConfig.getCollectorTcpServerPort();
    HeaderTBaseSerializer headerTBaseSerializer = tBaseSerializerProvider.get();
    MessageSerializer<MetaDataType, byte[]> messageSerializer = new ThriftMessageSerializer<>(messageConverter, headerTBaseSerializer);
    return new TcpDataSender<>("Default", collectorTcpServerIp, collectorTcpServerPort, clientFactory, messageSerializer);
}
Also used : HeaderTBaseSerializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer) ThriftMessageSerializer(com.navercorp.pinpoint.profiler.sender.ThriftMessageSerializer) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) MetaDataType(com.navercorp.pinpoint.profiler.metadata.MetaDataType) TcpDataSender(com.navercorp.pinpoint.profiler.sender.TcpDataSender)

Example 2 with TcpDataSender

use of com.navercorp.pinpoint.profiler.sender.TcpDataSender in project pinpoint by naver.

the class AgentInfoSenderTest method serverMetaDataCouldBePublishedFromMultipleThreads.

@Test
public void serverMetaDataCouldBePublishedFromMultipleThreads() throws InterruptedException {
    // Given
    final AtomicInteger requestCount = new AtomicInteger();
    final AtomicInteger successCount = new AtomicInteger();
    final long agentInfoSendRetryIntervalMs = 1000L;
    final int threadCount = 50;
    final CountDownLatch initLatch = new CountDownLatch(threadCount);
    final CountDownLatch startLatch = new CountDownLatch(1);
    final CountDownLatch endLatch = new CountDownLatch(threadCount);
    final ExecutorService executorService = Executors.newFixedThreadPool(threadCount);
    final Queue<Throwable> exceptions = new ConcurrentLinkedQueue<Throwable>();
    ResponseServerMessageListener delayedServerListener = new ResponseServerMessageListener(requestCount, successCount);
    PinpointServerAcceptor serverAcceptor = createServerAcceptor(delayedServerListener);
    PinpointClientFactory clientFactory = createPinpointClientFactory();
    PinpointClient pinpointClient = ClientFactoryUtils.createPinpointClient(HOST, PORT, clientFactory);
    TcpDataSender dataSender = new TcpDataSender(pinpointClient);
    AgentInfoSender agentInfoSender = new AgentInfoSender.Builder(dataSender, getAgentInfo()).sendInterval(agentInfoSendRetryIntervalMs).build();
    final ServerMetaDataHolder metaDataContext = new DefaultServerMetaDataHolder(Collections.<String>emptyList());
    metaDataContext.addListener(agentInfoSender);
    // When
    for (int i = 0; i < threadCount; ++i) {
        final String serviceName = "/name" + i;
        executorService.submit(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                initLatch.countDown();
                try {
                    startLatch.await();
                    metaDataContext.addServiceInfo(serviceName, Collections.<String>emptyList());
                    metaDataContext.notifyListeners();
                } catch (final Throwable t) {
                    exceptions.add(t);
                } finally {
                    endLatch.countDown();
                }
                return null;
            }
        });
    }
    initLatch.await();
    startLatch.countDown();
    endLatch.await();
    executorService.shutdown();
    try {
        waitExpectedRequestCount(requestCount, threadCount);
        waitExpectedRequestCount(successCount, threadCount);
    } finally {
        closeAll(serverAcceptor, agentInfoSender, pinpointClient, clientFactory);
    }
    // Then
    assertTrue("Failed with exceptions : " + exceptions, exceptions.isEmpty());
    assertEquals(threadCount, requestCount.get());
    assertEquals(threadCount, successCount.get());
}
Also used : PinpointClient(com.navercorp.pinpoint.rpc.client.PinpointClient) CountDownLatch(java.util.concurrent.CountDownLatch) TException(org.apache.thrift.TException) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor) ExecutorService(java.util.concurrent.ExecutorService) TcpDataSender(com.navercorp.pinpoint.profiler.sender.TcpDataSender) DefaultServerMetaDataHolder(com.navercorp.pinpoint.profiler.context.DefaultServerMetaDataHolder) ServerMetaDataHolder(com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder) DefaultServerMetaDataHolder(com.navercorp.pinpoint.profiler.context.DefaultServerMetaDataHolder) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Test(org.junit.Test)

Example 3 with TcpDataSender

use of com.navercorp.pinpoint.profiler.sender.TcpDataSender in project pinpoint by naver.

the class AgentInfoSenderTest method serverMetaDataShouldBeSentOnPublish.

@Test
public void serverMetaDataShouldBeSentOnPublish() throws InterruptedException {
    // Given
    final AtomicInteger requestCount = new AtomicInteger();
    final AtomicInteger successCount = new AtomicInteger();
    final long agentInfoSendRetryIntervalMs = 1000L;
    ResponseServerMessageListener serverListener = new ResponseServerMessageListener(requestCount, successCount);
    PinpointServerAcceptor serverAcceptor = createServerAcceptor(serverListener);
    PinpointClientFactory clientFactory = createPinpointClientFactory();
    PinpointClient pinpointClient = ClientFactoryUtils.createPinpointClient(HOST, PORT, clientFactory);
    TcpDataSender dataSender = new TcpDataSender(pinpointClient);
    AgentInfoSender agentInfoSender = new AgentInfoSender.Builder(dataSender, getAgentInfo()).sendInterval(agentInfoSendRetryIntervalMs).build();
    final List<ServerMetaData> serverMetaDataObjects = new ArrayList<ServerMetaData>();
    serverMetaDataObjects.add(new DefaultServerMetaData("server1", Collections.<String>emptyList(), Collections.<Integer, String>emptyMap(), Collections.<ServiceInfo>emptyList()));
    serverMetaDataObjects.add(new DefaultServerMetaData("server2", Collections.<String>emptyList(), Collections.<Integer, String>emptyMap(), Collections.<ServiceInfo>emptyList()));
    serverMetaDataObjects.add(new DefaultServerMetaData("server3", Collections.<String>emptyList(), Collections.<Integer, String>emptyMap(), Collections.<ServiceInfo>emptyList()));
    serverMetaDataObjects.add(new DefaultServerMetaData("server4", Collections.<String>emptyList(), Collections.<Integer, String>emptyMap(), Collections.<ServiceInfo>emptyList()));
    serverMetaDataObjects.add(new DefaultServerMetaData("server5", Collections.<String>emptyList(), Collections.<Integer, String>emptyMap(), Collections.<ServiceInfo>emptyList()));
    // When
    try {
        for (ServerMetaData serverMetaData : serverMetaDataObjects) {
            agentInfoSender.publishServerMetaData(serverMetaData);
        }
        waitExpectedRequestCount(requestCount, 5);
    } finally {
        closeAll(serverAcceptor, agentInfoSender, pinpointClient, clientFactory);
    }
    // Then
    assertEquals(5, requestCount.get());
    assertEquals(5, successCount.get());
}
Also used : PinpointClient(com.navercorp.pinpoint.rpc.client.PinpointClient) ArrayList(java.util.ArrayList) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ServiceInfo(com.navercorp.pinpoint.bootstrap.context.ServiceInfo) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor) TcpDataSender(com.navercorp.pinpoint.profiler.sender.TcpDataSender) DefaultServerMetaData(com.navercorp.pinpoint.profiler.context.DefaultServerMetaData) ServerMetaData(com.navercorp.pinpoint.bootstrap.context.ServerMetaData) DefaultServerMetaData(com.navercorp.pinpoint.profiler.context.DefaultServerMetaData) Test(org.junit.Test)

Example 4 with TcpDataSender

use of com.navercorp.pinpoint.profiler.sender.TcpDataSender in project pinpoint by naver.

the class SpanDataSenderProvider method get.

@Override
public DataSender<SpanType> get() {
    if ("TCP".equalsIgnoreCase(transportType)) {
        if ("OIO".equalsIgnoreCase(ioType)) {
            logger.warn("TCP transport not support OIO type.(only support NIO)");
        }
        PinpointClientFactory pinpointClientFactory = clientFactoryProvider.get();
        MessageSerializer<SpanType, byte[]> messageSerializer = new ThriftMessageSerializer<>(messageConverter);
        return new TcpDataSender<>("SpanDataSender", ip, port, pinpointClientFactory, messageSerializer, writeQueueSize);
    } else {
        UdpDataSenderFactory<SpanType> factory = new UdpDataSenderFactory<>(ip, port, UDP_EXECUTOR_NAME, writeQueueSize, timeout, sendBufferSize, messageConverter);
        return factory.create(ioType);
    }
}
Also used : SpanType(com.navercorp.pinpoint.profiler.context.SpanType) ThriftMessageSerializer(com.navercorp.pinpoint.profiler.sender.ThriftMessageSerializer) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) TcpDataSender(com.navercorp.pinpoint.profiler.sender.TcpDataSender) UdpDataSenderFactory(com.navercorp.pinpoint.profiler.sender.UdpDataSenderFactory)

Example 5 with TcpDataSender

use of com.navercorp.pinpoint.profiler.sender.TcpDataSender in project pinpoint by naver.

the class StatDataSenderProvider method get.

@Override
public DataSender<MetricType> get() {
    if ("TCP".equalsIgnoreCase(transportType)) {
        if ("OIO".equalsIgnoreCase(ioType)) {
            logger.warn("TCP transport not support OIO type.(only support NIO)");
        }
        PinpointClientFactory pinpointClientFactory = clientFactoryProvider.get();
        MessageSerializer<MetricType, byte[]> messageSerializer = new ThriftMessageSerializer<>(messageConverter);
        return new TcpDataSender<>("StatDataSender", ip, port, pinpointClientFactory, messageSerializer, writeQueueSize);
    } else {
        UdpDataSenderFactory<MetricType> factory = new UdpDataSenderFactory<>(ip, port, UDP_EXECUTOR_NAME, writeQueueSize, timeout, sendBufferSize, messageConverter);
        return factory.create(ioType);
    }
}
Also used : ThriftMessageSerializer(com.navercorp.pinpoint.profiler.sender.ThriftMessageSerializer) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) MetricType(com.navercorp.pinpoint.profiler.monitor.metric.MetricType) TcpDataSender(com.navercorp.pinpoint.profiler.sender.TcpDataSender) UdpDataSenderFactory(com.navercorp.pinpoint.profiler.sender.UdpDataSenderFactory)

Aggregations

TcpDataSender (com.navercorp.pinpoint.profiler.sender.TcpDataSender)5 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)5 ThriftMessageSerializer (com.navercorp.pinpoint.profiler.sender.ThriftMessageSerializer)3 UdpDataSenderFactory (com.navercorp.pinpoint.profiler.sender.UdpDataSenderFactory)2 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)2 PinpointClient (com.navercorp.pinpoint.rpc.client.PinpointClient)2 PinpointServerAcceptor (com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Test (org.junit.Test)2 ServerMetaData (com.navercorp.pinpoint.bootstrap.context.ServerMetaData)1 ServerMetaDataHolder (com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder)1 ServiceInfo (com.navercorp.pinpoint.bootstrap.context.ServiceInfo)1 DefaultServerMetaData (com.navercorp.pinpoint.profiler.context.DefaultServerMetaData)1 DefaultServerMetaDataHolder (com.navercorp.pinpoint.profiler.context.DefaultServerMetaDataHolder)1 SpanType (com.navercorp.pinpoint.profiler.context.SpanType)1 MetaDataType (com.navercorp.pinpoint.profiler.metadata.MetaDataType)1 MetricType (com.navercorp.pinpoint.profiler.monitor.metric.MetricType)1 HeaderTBaseSerializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer)1 ArrayList (java.util.ArrayList)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1