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();
}
}
}
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);
}
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;
}
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();
}
}
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());
}
Aggregations