use of com.navercorp.pinpoint.common.util.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);
}
use of com.navercorp.pinpoint.common.util.PinpointThreadFactory in project pinpoint by naver.
the class ZookeeperJobWorker method start.
public void start() {
final ThreadFactory threadFactory = new PinpointThreadFactory(this.getClass().getSimpleName(), true);
this.workerThread = threadFactory.newThread(this);
switch(this.workerState.getCurrentState()) {
case NEW:
if (this.workerState.changeStateInitializing()) {
logger.info("start() started.");
workerState.changeStateStarted();
this.workerThread.start();
logger.info("start() completed.");
break;
}
case INITIALIZING:
logger.info("start() failed. cause: already initializing.");
break;
case STARTED:
logger.info("start() failed. cause: already initializing.");
break;
case DESTROYING:
throw new IllegalStateException("Already destroying.");
case STOPPED:
throw new IllegalStateException(ClassUtils.simpleClassName(this) + " start() failed. caused:Already stopped.");
case ILLEGAL_STATE:
throw new IllegalStateException(ClassUtils.simpleClassName(this) + " start() failed. caused:Invalid State.");
}
}
use of com.navercorp.pinpoint.common.util.PinpointThreadFactory in project pinpoint by naver.
the class PinpointStarter method registerShutdownHook.
private void registerShutdownHook(final Agent pinpointAgent) {
final Runnable stop = new Runnable() {
@Override
public void run() {
pinpointAgent.stop();
}
};
PinpointThreadFactory pinpointThreadFactory = new PinpointThreadFactory("Pinpoint-shutdown-hook");
Thread thread = pinpointThreadFactory.newThread(stop);
Runtime.getRuntime().addShutdownHook(thread);
}
use of com.navercorp.pinpoint.common.util.PinpointThreadFactory in project pinpoint by naver.
the class HbaseTemplate2 method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
Configuration configuration = getConfiguration();
Assert.notNull(configuration, "configuration is required");
Assert.notNull(getTableFactory(), "tableFactory is required");
PinpointThreadFactory parallelScannerThreadFactory = new PinpointThreadFactory("Pinpoint-parallel-scanner");
if (this.maxThreadsPerParallelScan <= 1) {
this.enableParallelScan = false;
this.executor = Executors.newSingleThreadExecutor(parallelScannerThreadFactory);
} else {
this.executor = ExecutorFactory.newFixedThreadPool(this.maxThreads, 1024, parallelScannerThreadFactory);
}
}
use of com.navercorp.pinpoint.common.util.PinpointThreadFactory in project pinpoint by naver.
the class PinpointThreadFactoryTest method testCreateThreadFactory.
@Test
public void testCreateThreadFactory() throws Exception {
final AtomicInteger counter = new AtomicInteger(0);
PinpointThreadFactory pinpoint = new PinpointThreadFactory("pinpoint");
Thread thread = pinpoint.newThread(new Runnable() {
@Override
public void run() {
counter.getAndIncrement();
}
});
thread.start();
thread.join();
Assert.assertEquals(counter.get(), 1);
String threadName = thread.getName();
logger.debug(threadName);
Assert.assertTrue(threadName.startsWith("pinpoint("));
Assert.assertTrue(threadName.endsWith(")"));
Thread thread2 = pinpoint.newThread(new Runnable() {
@Override
public void run() {
}
});
logger.debug(thread2.getName());
}
Aggregations