use of com.dangdang.ddframe.job.executor.handler.impl.DefaultExecutorServiceHandler in project elastic-job by dangdangdotcom.
the class ExecutorServiceHandlerRegistryTest method assertGetExecutorServiceHandlerForConcurrent.
@Test
public void assertGetExecutorServiceHandlerForConcurrent() throws InterruptedException {
int threadCount = 100;
CyclicBarrier barrier = new CyclicBarrier(threadCount);
ExecutorService executorService = Executors.newFixedThreadPool(threadCount);
CountDownLatch latch = new CountDownLatch(threadCount);
Set<ExecutorService> set = new CopyOnWriteArraySet<>();
for (int i = 0; i < threadCount; i++) {
executorService.submit(new GetExecutorServiceHandlerTask(barrier, latch, set));
}
latch.await();
assertThat(set.size(), is(1));
assertThat(ExecutorServiceHandlerRegistry.getExecutorServiceHandler("test_job", new DefaultExecutorServiceHandler()), is(set.iterator().next()));
}
use of com.dangdang.ddframe.job.executor.handler.impl.DefaultExecutorServiceHandler in project elastic-job by dangdangdotcom.
the class SimpleJobExecutorTest method assertNewExecutorWithDefaultHandlers.
@Test
public void assertNewExecutorWithDefaultHandlers() throws NoSuchFieldException {
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestSimpleJobConfiguration("ErrorHandler", Object.class.getName()));
SimpleJobExecutor simpleJobExecutor = new SimpleJobExecutor(new TestSimpleJob(jobCaller), jobFacade);
assertThat(ReflectionUtils.getFieldValue(simpleJobExecutor, AbstractElasticJobExecutor.class.getDeclaredField("executorService")), instanceOf(new DefaultExecutorServiceHandler().createExecutorService("test_job").getClass()));
assertThat(ReflectionUtils.getFieldValue(simpleJobExecutor, AbstractElasticJobExecutor.class.getDeclaredField("jobExceptionHandler")), instanceOf(DefaultJobExceptionHandler.class));
}
use of com.dangdang.ddframe.job.executor.handler.impl.DefaultExecutorServiceHandler in project elastic-job by dangdangdotcom.
the class ExecutorServiceHandlerRegistryTest method assertRemove.
@Test
public void assertRemove() {
ExecutorService actual = ExecutorServiceHandlerRegistry.getExecutorServiceHandler("test_job", new DefaultExecutorServiceHandler());
ExecutorServiceHandlerRegistry.remove("test_job");
assertThat(actual, not(ExecutorServiceHandlerRegistry.getExecutorServiceHandler("test_job", new DefaultExecutorServiceHandler())));
}
Aggregations