use of org.elasticsearch.threadpool.TestThreadPool in project elasticsearch by elastic.
the class IndexShardTestCase method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
threadPool = new TestThreadPool(getClass().getName());
}
use of org.elasticsearch.threadpool.TestThreadPool in project elasticsearch by elastic.
the class NetworkModuleTests method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
threadPool = new TestThreadPool(NetworkModuleTests.class.getName());
}
use of org.elasticsearch.threadpool.TestThreadPool in project elasticsearch by elastic.
the class PrioritizedExecutorsTests method testTimeoutCleanup.
public void testTimeoutCleanup() throws Exception {
ThreadPool threadPool = new TestThreadPool("test");
final ScheduledThreadPoolExecutor timer = (ScheduledThreadPoolExecutor) threadPool.scheduler();
final AtomicBoolean timeoutCalled = new AtomicBoolean();
PrioritizedEsThreadPoolExecutor executor = EsExecutors.newSinglePrioritizing(getTestName(), EsExecutors.daemonThreadFactory(getTestName()), holder);
final CountDownLatch invoked = new CountDownLatch(1);
executor.execute(new Runnable() {
@Override
public void run() {
invoked.countDown();
}
}, timer, TimeValue.timeValueHours(1), new Runnable() {
@Override
public void run() {
// We should never get here
timeoutCalled.set(true);
}
});
invoked.await();
// the timeout handler is added post execution (and quickly cancelled). We have allow for this
// and use assert busy
assertBusy(new Runnable() {
@Override
public void run() {
assertThat(timer.getQueue().size(), equalTo(0));
}
}, 5, TimeUnit.SECONDS);
assertThat(timeoutCalled.get(), equalTo(false));
assertTrue(terminate(executor));
assertTrue(terminate(threadPool));
}
use of org.elasticsearch.threadpool.TestThreadPool in project elasticsearch by elastic.
the class FileBasedUnicastHostsProviderTests method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
threadPool = new TestThreadPool(FileBasedUnicastHostsProviderTests.class.getName());
executorService = Executors.newSingleThreadExecutor();
}
use of org.elasticsearch.threadpool.TestThreadPool in project elasticsearch by elastic.
the class NettyTransportMultiPortTests method testThatNettyCanBindToMultiplePorts.
public void testThatNettyCanBindToMultiplePorts() throws Exception {
Settings settings = Settings.builder().put("network.host", host).put(TransportSettings.PORT.getKey(), // will not actually bind to this
22).put("transport.profiles.default.port", 0).put("transport.profiles.client1.port", 0).build();
ThreadPool threadPool = new TestThreadPool("tst");
try (TcpTransport<?> transport = startTransport(settings, threadPool)) {
assertEquals(1, transport.profileBoundAddresses().size());
assertEquals(1, transport.boundAddress().boundAddresses().length);
} finally {
terminate(threadPool);
}
}
Aggregations