use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.
the class PinpointClientFactoryProvider method get.
public PinpointClientFactory get() {
PinpointClientFactory pinpointClientFactory = new DefaultPinpointClientFactory();
pinpointClientFactory.setTimeoutMillis(1000 * 5);
AgentInformation agentInformation = this.agentInformation.get();
Map<String, Object> properties = toMap(agentInformation);
boolean isSupportServerMode = profilerConfig.isTcpDataSenderCommandAcceptEnable();
if (isSupportServerMode) {
pinpointClientFactory.setMessageListener(commandDispatcher);
pinpointClientFactory.setServerStreamChannelMessageListener(commandDispatcher);
properties.put(HandshakePropertyType.SUPPORT_SERVER.getName(), true);
properties.put(HandshakePropertyType.SUPPORT_COMMAND_LIST.getName(), commandDispatcher.getRegisteredCommandServiceCodes());
} else {
properties.put(HandshakePropertyType.SUPPORT_SERVER.getName(), false);
}
pinpointClientFactory.setProperties(properties);
return pinpointClientFactory;
}
use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.
the class DataReceiverGroupTest method receiverGroupTest1.
@Test
public void receiverGroupTest1() throws Exception {
DataReceiverGroupConfiguration mockConfig = createMockConfig(true, true);
TestDispatchHandler dispatchHandler = new TestDispatchHandler(2, 1);
UDPReceiverBean udpReceiverBean = createUdpReceiverBean(mockConfig, dispatchHandler);
TCPReceiverBean tcpReceiverBean = createTcpReceiverBean(mockConfig, dispatchHandler);
DataSender<TBase<?, ?>> udpDataSender = null;
TcpDataSender<TBase<?, ?>> tcpDataSender = null;
PinpointClientFactory pinpointClientFactory = null;
try {
udpReceiverBean.afterPropertiesSet();
tcpReceiverBean.afterPropertiesSet();
udpDataSender = newUdpDataSender(mockConfig);
pinpointClientFactory = createPinpointClientFactory();
tcpDataSender = new TcpDataSender<>(this.getClass().getName(), "127.0.0.1", mockConfig.getTcpBindPort(), pinpointClientFactory);
udpDataSender.send(new TResult());
tcpDataSender.send(new TResult());
tcpDataSender.request(new TResult());
Assert.assertTrue(tcpDataSender.isConnected());
Assert.assertTrue(dispatchHandler.getSendLatch().await(1000, TimeUnit.MILLISECONDS));
Assert.assertTrue(dispatchHandler.getRequestLatch().await(1000, TimeUnit.MILLISECONDS));
} finally {
closeDataSender(udpDataSender);
closeDataSender(tcpDataSender);
closeClientFactory(pinpointClientFactory);
closeBean(udpReceiverBean);
closeBean(tcpReceiverBean);
}
}
use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.
the class DataReceiverGroupTest method createPinpointClientFactory.
private PinpointClientFactory createPinpointClientFactory() {
PinpointClientFactory clientFactory = new DefaultPinpointClientFactory();
clientFactory.setWriteTimeoutMillis(1000 * 3);
clientFactory.setRequestTimeoutMillis(1000 * 5);
clientFactory.setProperties(Collections.emptyMap());
return clientFactory;
}
use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.
the class DataReceiverGroupTest method receiverGroupTest3.
@Test
public void receiverGroupTest3() throws Exception {
DataReceiverGroupConfiguration mockConfig = createMockConfig(false, true);
TestDispatchHandler testDispatchHandler = new TestDispatchHandler(1, 1);
UDPReceiverBean receiver = createUdpReceiverBean(mockConfig, testDispatchHandler);
DataSender<TBase<?, ?>> udpDataSender = null;
TcpDataSender<TBase<?, ?>> tcpDataSender = null;
PinpointClientFactory pinpointClientFactory = null;
try {
receiver.afterPropertiesSet();
udpDataSender = newUdpDataSender(mockConfig);
udpDataSender.send(new TResult());
Assert.assertTrue(testDispatchHandler.getSendLatch().await(1000, TimeUnit.MILLISECONDS));
pinpointClientFactory = createPinpointClientFactory();
tcpDataSender = new TcpDataSender<>(this.getClass().getName(), "127.0.0.1", mockConfig.getTcpBindPort(), pinpointClientFactory);
Assert.assertFalse(tcpDataSender.isConnected());
} finally {
closeDataSender(udpDataSender);
closeDataSender(tcpDataSender);
closeClientFactory(pinpointClientFactory);
closeBean(receiver);
}
}
use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.
the class AgentInfoSenderTest method agentInfoShouldBeRefreshedOnServerMetaDataChangeFromMultipleThreads.
@Test
public void agentInfoShouldBeRefreshedOnServerMetaDataChangeFromMultipleThreads() {
// Given
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<>();
final ResponseServerMessageListenerFactory messageListenerFactory = new ResponseServerMessageListenerFactory();
ResponseServerMessageListener messageListener = messageListenerFactory.create();
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(messageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
PinpointClientFactory clientFactory = createPinpointClientFactory();
EnhancedDataSender<MetaDataType> dataSender = newTcpDataSender(clientFactory, bindPort);
final AgentInfoSender agentInfoSender = new AgentInfoSender.Builder(dataSender, agentInfoFactory).sendInterval(agentInfoSendRetryIntervalMs).setMessageConverter(resultResponseMessageConverter).build();
serverMetaDataRegistryService.addListener(new ServerMetaDataRegistryService.OnChangeListener() {
@Override
public void onServerMetaDataChange() {
agentInfoSender.refresh();
}
});
// When
for (int i = 0; i < threadCount; i++) {
final String serviceName = "/name" + i;
executorService.submit(new Runnable() {
@Override
public void run() {
initLatch.countDown();
try {
startLatch.await();
ServiceInfo serviceInfo = new DefaultServiceInfo(serviceName, Collections.<String>emptyList());
serverMetaDataRegistryService.addServiceInfo(serviceInfo);
serverMetaDataRegistryService.notifyListeners();
} catch (final Throwable t) {
exceptions.add(t);
} finally {
endLatch.countDown();
}
}
});
}
await(initLatch, 3000);
startLatch.countDown();
await(endLatch, 3000);
executorService.shutdown();
try {
waitExpectedRequestCount(threadCount, messageListener);
waitExpectedSuccessCount(threadCount, messageListener);
} finally {
closeAll(agentInfoSender, clientFactory);
testPinpointServerAcceptor.close();
}
// Then
assertTrue("Failed with exceptions : " + exceptions, exceptions.isEmpty());
assertEquals(threadCount, messageListener.getRequestCount());
assertEquals(threadCount, messageListener.getSuccessCount());
}
Aggregations