Search in sources :

Example 1 with ServerMetaDataHolder

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();
}
Also used : ServerMetaDataHolder(com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder)

Example 2 with ServerMetaDataHolder

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);
}
Also used : ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) ServerMetaDataHolder(com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Vector(java.util.Vector) ServerMetaData(com.navercorp.pinpoint.bootstrap.context.ServerMetaData) Test(org.junit.Test)

Example 3 with ServerMetaDataHolder

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();
}
Also used : ServerMetaDataHolder(com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder)

Example 4 with ServerMetaDataHolder

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();
}
Also used : ServerMetaDataHolder(com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder)

Example 5 with ServerMetaDataHolder

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);
}
Also used : ResettableServerMetaDataHolder(com.navercorp.pinpoint.test.ResettableServerMetaDataHolder) TBaseRecorder(com.navercorp.pinpoint.test.TBaseRecorder) ListenableDataSender(com.navercorp.pinpoint.test.ListenableDataSender) DataSender(com.navercorp.pinpoint.profiler.sender.DataSender) ResettableServerMetaDataHolder(com.navercorp.pinpoint.test.ResettableServerMetaDataHolder) ServerMetaDataHolder(com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder) ListenableDataSender(com.navercorp.pinpoint.test.ListenableDataSender) MockApplicationContext(com.navercorp.pinpoint.test.MockApplicationContext)

Aggregations

ServerMetaDataHolder (com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder)14 DataSender (com.navercorp.pinpoint.profiler.sender.DataSender)3 PinpointClient (com.navercorp.pinpoint.rpc.client.PinpointClient)3 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)3 ArrayList (java.util.ArrayList)3 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Test (org.junit.Test)3 ServerMetaData (com.navercorp.pinpoint.bootstrap.context.ServerMetaData)2 DefaultServerMetaDataHolder (com.navercorp.pinpoint.profiler.context.DefaultServerMetaDataHolder)2 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 EnhancedDataSender (com.navercorp.pinpoint.profiler.sender.EnhancedDataSender)2 AgentInfoSender (com.navercorp.pinpoint.profiler.AgentInfoSender)1 TcpDataSender (com.navercorp.pinpoint.profiler.sender.TcpDataSender)1 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)1 PinpointServerAcceptor (com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor)1 ListenableDataSender (com.navercorp.pinpoint.test.ListenableDataSender)1 MockApplicationContext (com.navercorp.pinpoint.test.MockApplicationContext)1