Search in sources :

Example 21 with PinpointClientFactory

use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.

the class ClusterTest method clusterTest3.

@Test
public void clusterTest3() throws Exception {
    PinpointClientFactory clientFactory = null;
    PinpointClient client = null;
    ZooKeeper zookeeper = null;
    try {
        zookeeper = new ZooKeeper(zookeeperAddress, 5000, null);
        awaitZookeeperConnected(zookeeper);
        Assert.assertEquals(0, clusterConnectionManager.getClusterList().size());
        clientFactory = new DefaultPinpointClientFactory();
        clientFactory.setMessageListener(SimpleMessageListener.INSTANCE);
        client = clientFactory.connect(DEFAULT_IP, acceptorPort);
        awaitPinpointClientConnected(clusterConnectionManager);
        Assert.assertEquals(1, clusterConnectionManager.getClusterList().size());
    } finally {
        closePinpointSocket(clientFactory, client);
        if (zookeeper != null) {
            zookeeper.close();
        }
    }
}
Also used : DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) PinpointClient(com.navercorp.pinpoint.rpc.client.PinpointClient) ZooKeeper(org.apache.zookeeper.ZooKeeper) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) Test(org.junit.Test)

Example 22 with PinpointClientFactory

use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.

the class MockApplicationContextModule method configure.

@Override
protected void configure() {
    final DataSender spanDataSender = newUdpSpanDataSender();
    logger.debug("spanDataSender:{}", spanDataSender);
    bind(DataSender.class).annotatedWith(SpanDataSender.class).toInstance(spanDataSender);
    final DataSender statDataSender = newUdpStatDataSender();
    logger.debug("statDataSender:{}", statDataSender);
    bind(DataSender.class).annotatedWith(StatDataSender.class).toInstance(statDataSender);
    StorageFactory storageFactory = newStorageFactory(spanDataSender);
    logger.debug("spanFactory:{}", spanDataSender);
    bind(StorageFactory.class).toInstance(storageFactory);
    bind(PinpointClientFactory.class).toProvider(Providers.of((PinpointClientFactory) null));
    bind(PinpointClient.class).toProvider(Providers.of((PinpointClient) null));
    EnhancedDataSender enhancedDataSender = newTcpDataSender();
    logger.debug("enhancedDataSender:{}", enhancedDataSender);
    bind(EnhancedDataSender.class).toInstance(enhancedDataSender);
    ServerMetaDataHolder serverMetaDataHolder = newServerMetaDataHolder();
    logger.debug("serverMetaDataHolder:{}", serverMetaDataHolder);
    bind(ServerMetaDataHolder.class).toInstance(serverMetaDataHolder);
    bind(PluginContextLoadResult.class).toProvider(MockPluginContextLoadResultProvider.class).in(Scopes.SINGLETON);
}
Also used : SpanDataSender(com.navercorp.pinpoint.profiler.context.module.SpanDataSender) StatDataSender(com.navercorp.pinpoint.profiler.context.module.StatDataSender) StorageFactory(com.navercorp.pinpoint.profiler.context.storage.StorageFactory) PinpointClient(com.navercorp.pinpoint.rpc.client.PinpointClient) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) SpanDataSender(com.navercorp.pinpoint.profiler.context.module.SpanDataSender) StatDataSender(com.navercorp.pinpoint.profiler.context.module.StatDataSender) EnhancedDataSender(com.navercorp.pinpoint.profiler.sender.EnhancedDataSender) DataSender(com.navercorp.pinpoint.profiler.sender.DataSender) EnhancedDataSender(com.navercorp.pinpoint.profiler.sender.EnhancedDataSender) ServerMetaDataHolder(com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder)

Example 23 with PinpointClientFactory

use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.

the class PinpointClientProvider method get.

@Override
public PinpointClient get() {
    PinpointClientFactory pinpointClientFactory = clientFactory.get();
    PinpointClient pinpointClient = ClientFactoryUtils.createPinpointClient(profilerConfig.getCollectorTcpServerIp(), profilerConfig.getCollectorTcpServerPort(), pinpointClientFactory);
    return pinpointClient;
}
Also used : PinpointClient(com.navercorp.pinpoint.rpc.client.PinpointClient) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory)

Example 24 with PinpointClientFactory

use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.

the class DefaultApplicationContext method closeTcpDataSender.

private void closeTcpDataSender() {
    final EnhancedDataSender tcpDataSender = this.tcpDataSender;
    if (tcpDataSender != null) {
        tcpDataSender.stop();
    }
    final PinpointClient client = this.client;
    if (client != null) {
        client.close();
    }
    final PinpointClientFactory clientFactory = this.clientFactory;
    if (clientFactory != null) {
        clientFactory.release();
    }
}
Also used : PinpointClient(com.navercorp.pinpoint.rpc.client.PinpointClient) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) EnhancedDataSender(com.navercorp.pinpoint.profiler.sender.EnhancedDataSender)

Example 25 with PinpointClientFactory

use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory 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)

Aggregations

PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)34 PinpointClient (com.navercorp.pinpoint.rpc.client.PinpointClient)28 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)25 Test (org.junit.Test)22 PinpointServerAcceptor (com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor)16 TcpDataSender (com.navercorp.pinpoint.profiler.sender.TcpDataSender)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)5 ServerMetaDataHolder (com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder)3 EnhancedDataSender (com.navercorp.pinpoint.profiler.sender.EnhancedDataSender)3 ArrayList (java.util.ArrayList)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 SpanDataSender (com.navercorp.pinpoint.profiler.context.module.SpanDataSender)2 StatDataSender (com.navercorp.pinpoint.profiler.context.module.StatDataSender)2 StorageFactory (com.navercorp.pinpoint.profiler.context.storage.StorageFactory)2 DataSender (com.navercorp.pinpoint.profiler.sender.DataSender)2 TestAwaitTaskUtils (com.navercorp.pinpoint.rpc.TestAwaitTaskUtils)2 PinpointClientReconnectEventListener (com.navercorp.pinpoint.rpc.client.PinpointClientReconnectEventListener)2 PinpointServer (com.navercorp.pinpoint.rpc.server.PinpointServer)2 TApiMetaData (com.navercorp.pinpoint.thrift.dto.TApiMetaData)2