Search in sources :

Example 1 with PinpointThreadFactory

use of com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory in project pinpoint by naver.

the class DefaultChannelzScheduledReporter method newScheduledExecutorService.

private ScheduledExecutorService newScheduledExecutorService() {
    String threadName = PinpointThreadFactory.DEFAULT_THREAD_NAME_PREFIX + DefaultChannelzScheduledReporter.class.getSimpleName();
    ThreadFactory threadFactory = new PinpointThreadFactory(threadName, true);
    return new ScheduledThreadPoolExecutor(1, threadFactory);
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) PinpointThreadFactory(com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) PinpointThreadFactory(com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory)

Example 2 with PinpointThreadFactory

use of com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory in project pinpoint by naver.

the class ActiveThreadCountHandler method start.

@Override
public void start() {
    PinpointThreadFactory flushThreadFactory = new PinpointThreadFactory(ClassUtils.simpleClassName(this) + "-Flush-Thread", true);
    webSocketFlushExecutor = new SimpleOrderedThreadPool(CpuUtils.cpuCount(), 65535, flushThreadFactory);
    flushTimer = newJavaTimer(ClassUtils.simpleClassName(this) + "-Flush-Timer");
    healthCheckTimer = newJavaTimer(ClassUtils.simpleClassName(this) + "-HealthCheck-Timer");
    reactiveTimer = newJavaTimer(ClassUtils.simpleClassName(this) + "-Reactive-Timer");
}
Also used : SimpleOrderedThreadPool(com.navercorp.pinpoint.web.util.SimpleOrderedThreadPool) PinpointThreadFactory(com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory)

Example 3 with PinpointThreadFactory

use of com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory in project pinpoint by naver.

the class DefaultAgent method registerStopHandler.

@Override
public void registerStopHandler() {
    if (applicationContext instanceof DefaultApplicationContext) {
        logger.info("registerStopHandler");
        DefaultApplicationContext context = (DefaultApplicationContext) applicationContext;
        ShutdownHookRegisterProvider shutdownHookRegisterProvider = context.getShutdownHookRegisterProvider();
        ShutdownHookRegister shutdownHookRegister = shutdownHookRegisterProvider.get();
        PinpointThreadFactory pinpointThreadFactory = new PinpointThreadFactory("Pinpoint-shutdown-hook", false);
        Thread shutdownThread = pinpointThreadFactory.newThread(new Runnable() {

            @Override
            public void run() {
                logger.info("stop() started. threadName:" + Thread.currentThread().getName());
                DefaultAgent.this.stop();
            }
        });
        shutdownHookRegister.register(shutdownThread);
    }
}
Also used : DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) ShutdownHookRegisterProvider(com.navercorp.pinpoint.profiler.context.provider.ShutdownHookRegisterProvider) PinpointThreadFactory(com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory)

Example 4 with PinpointThreadFactory

use of com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory in project pinpoint by naver.

the class DefaultChannelFactory method newExecutorService.

private ExecutorService newExecutorService(String name, int executorQueueSize) {
    ThreadFactory threadFactory = new PinpointThreadFactory(PinpointThreadFactory.DEFAULT_THREAD_NAME_PREFIX + name, true);
    BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(executorQueueSize);
    return new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, workQueue, threadFactory);
}
Also used : PinpointThreadFactory(com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) PinpointThreadFactory(com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory)

Example 5 with PinpointThreadFactory

use of com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory in project pinpoint by naver.

the class SimpleOrderedThreadPoolTest method testExecute.

@Test
public void testExecute() throws Exception {
    SimpleOrderedThreadPool threadPool = new SimpleOrderedThreadPool(3, 100, new PinpointThreadFactory("test", true));
    int testCount = 100;
    CountDownLatch latch = new CountDownLatch(testCount);
    for (int i = 0; i < testCount; i++) {
        final int selectKey = random.nextInt();
        threadPool.execute(new TestHashSelectorRunnable(selectKey, latch));
    }
    threadPool.shutdown();
    threadPool.awaitTermination(10000, TimeUnit.MILLISECONDS);
    Assert.assertEquals(latch.getCount(), 0);
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) PinpointThreadFactory(com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory) Test(org.junit.Test)

Aggregations

PinpointThreadFactory (com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory)10 ThreadFactory (java.util.concurrent.ThreadFactory)4 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)2 DefaultApplicationContext (com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext)1 ShutdownHookRegisterProvider (com.navercorp.pinpoint.profiler.context.provider.ShutdownHookRegisterProvider)1 SimpleOrderedThreadPool (com.navercorp.pinpoint.web.util.SimpleOrderedThreadPool)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 Configuration (org.apache.hadoop.conf.Configuration)1 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)1 NioServerBossPool (org.jboss.netty.channel.socket.nio.NioServerBossPool)1 NioServerSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory)1 NioWorkerPool (org.jboss.netty.channel.socket.nio.NioWorkerPool)1 Test (org.junit.Test)1