use of com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder in project pinpoint by naver.
the class WebAppInterceptor method dispatchLibJars.
private void dispatchLibJars(String contextKey, List<String> libJars, ServletContext webapp) {
ServerMetaDataHolder holder = this.traceContext.getServerMetaDataHolder();
holder.addServiceInfo(contextKey, libJars);
holder.setServerName(webapp.getServerInfo());
holder.notifyListeners();
}
use of com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder in project pinpoint by naver.
the class DefaultServerMetaDataHolderTest method testRaceConditionWhenAddingAndInteratingServiceInfo.
@Test
public void testRaceConditionWhenAddingAndInteratingServiceInfo() throws InterruptedException {
// Given
final CountDownLatch initLatch = new CountDownLatch(THREAD_COUNT);
final CountDownLatch startLatch = new CountDownLatch(1);
final CountDownLatch endLatch = new CountDownLatch(THREAD_COUNT);
final Queue<Throwable> exceptions = new ConcurrentLinkedQueue<Throwable>();
final TestableServerMetaDataListener listener = new TestableServerMetaDataListener();
final ServerMetaDataHolder metaDataContext = new DefaultServerMetaDataHolder(VM_ARGS);
metaDataContext.addListener(listener);
metaDataContext.setServerName(SERVER_INFO);
// When
final List<ServerMetaData> serverMetaDatas = new Vector<ServerMetaData>(THREAD_COUNT / 2);
for (int i = 0; i < THREAD_COUNT; ++i) {
if (i % 2 == 0) {
final String serviceName = "/name" + i;
final List<String> serviceLibs = new ArrayList<String>();
executorService.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
initLatch.countDown();
try {
startLatch.await();
metaDataContext.addServiceInfo(serviceName, serviceLibs);
metaDataContext.notifyListeners();
} catch (Throwable t) {
exceptions.add(t);
} finally {
endLatch.countDown();
}
return null;
}
});
} else {
executorService.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
initLatch.countDown();
try {
startLatch.await();
ServerMetaData serverMetaData = listener.getServerMetaData();
serverMetaDatas.add(serverMetaData);
} catch (Throwable t) {
exceptions.add(t);
} finally {
endLatch.countDown();
}
return null;
}
});
}
}
initLatch.await();
startLatch.countDown();
endLatch.await();
// Then
assertTrue("Failed with exceptions : " + exceptions, exceptions.isEmpty());
ServerMetaData metaData = listener.getServerMetaData();
assertEquals(metaData.getServerInfo(), SERVER_INFO);
assertEquals(metaData.getVmArgs(), VM_ARGS);
assertEquals(metaData.getServiceInfos().size(), THREAD_COUNT / 2);
assertEquals(serverMetaDatas.size(), THREAD_COUNT / 2);
}
use of com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder in project pinpoint by naver.
the class StandardServiceStartInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
String serverInfo = ServerInfo.getServerInfo();
ServerMetaDataHolder holder = this.traceContext.getServerMetaDataHolder();
holder.setServerName(serverInfo);
holder.notifyListeners();
}
use of com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder in project pinpoint by naver.
the class WebappLoaderStartInterceptor method dispatchLibJars.
private void dispatchLibJars(String contextKey, List<String> libJars) {
ServerMetaDataHolder holder = this.traceContext.getServerMetaDataHolder();
holder.addServiceInfo(contextKey, libJars);
holder.notifyListeners();
}
use of com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder in project pinpoint by naver.
the class BasePinpointTest method setup.
public void setup(TestContext testContext) {
MockApplicationContext mockApplicationContext = testContext.getMockApplicationContext();
DataSender spanDataSender = mockApplicationContext.getSpanDataSender();
if (spanDataSender instanceof ListenableDataSender) {
ListenableDataSender listenableDataSender = (ListenableDataSender) spanDataSender;
final TBaseRecorder tBaseRecord = new TBaseRecorder();
listenableDataSender.setListener(new ListenableDataSender.Listener() {
@Override
public boolean handleSend(TBase<?, ?> data) {
return tBaseRecord.add(data);
}
});
setTBaseRecorder(tBaseRecord);
}
ServerMetaDataHolder serverMetaDataHolder = mockApplicationContext.getTraceContext().getServerMetaDataHolder();
if (serverMetaDataHolder instanceof ResettableServerMetaDataHolder) {
ResettableServerMetaDataHolder resettableServerMetaDataHolder = (ResettableServerMetaDataHolder) serverMetaDataHolder;
this.setServerMetaDataHolder(resettableServerMetaDataHolder);
}
this.serverMetaDataHolder.addListener(this.listener);
}
Aggregations