Search in sources :

Example 81 with ThreadPool

use of org.elasticsearch.threadpool.ThreadPool in project elasticsearch by elastic.

the class ClusterStateHealthTests method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    clusterService = createClusterService(threadPool);
    transportService = new TransportService(clusterService.getSettings(), new CapturingTransport(), threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    transportService.start();
    transportService.acceptIncomingRequests();
}
Also used : MetaData(org.elasticsearch.cluster.metadata.MetaData) ClusterServiceUtils.createClusterService(org.elasticsearch.test.ClusterServiceUtils.createClusterService) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) ClusterState(org.elasticsearch.cluster.ClusterState) ClusterStateUpdateTask(org.elasticsearch.cluster.ClusterStateUpdateTask) Settings(org.elasticsearch.common.settings.Settings) After(org.junit.After) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) RoutingTableGenerator(org.elasticsearch.cluster.routing.RoutingTableGenerator) ThreadPool(org.elasticsearch.threadpool.ThreadPool) ClusterName(org.elasticsearch.cluster.ClusterName) AfterClass(org.junit.AfterClass) ActionFilters(org.elasticsearch.action.support.ActionFilters) Matchers.lessThanOrEqualTo(org.hamcrest.Matchers.lessThanOrEqualTo) PlainActionFuture(org.elasticsearch.action.support.PlainActionFuture) UUIDs(org.elasticsearch.common.UUIDs) Set(java.util.Set) IndexShardRoutingTable(org.elasticsearch.cluster.routing.IndexShardRoutingTable) ObjectCursor(com.carrotsearch.hppc.cursors.ObjectCursor) Sets(org.elasticsearch.common.util.set.Sets) RecoverySource(org.elasticsearch.cluster.routing.RecoverySource) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Version(org.elasticsearch.Version) ClusterHealthRequest(org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest) IndexRoutingTable(org.elasticsearch.cluster.routing.IndexRoutingTable) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData) ImmutableOpenIntMap(org.elasticsearch.common.collect.ImmutableOpenIntMap) Matchers.is(org.hamcrest.Matchers.is) TransportClusterHealthAction(org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction) IntObjectCursor(com.carrotsearch.hppc.cursors.IntObjectCursor) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting) BeforeClass(org.junit.BeforeClass) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) ClusterService(org.elasticsearch.cluster.service.ClusterService) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) ESTestCase(org.elasticsearch.test.ESTestCase) TransportService(org.elasticsearch.transport.TransportService) Before(org.junit.Before) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) TestGatewayAllocator(org.elasticsearch.test.gateway.TestGatewayAllocator) ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) IOException(java.io.IOException) UnassignedInfo(org.elasticsearch.cluster.routing.UnassignedInfo) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) RoutingTable(org.elasticsearch.cluster.routing.RoutingTable) StreamInput(org.elasticsearch.common.io.stream.StreamInput) LocalClusterUpdateTask(org.elasticsearch.cluster.LocalClusterUpdateTask) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) ClusterServiceUtils.setState(org.elasticsearch.test.ClusterServiceUtils.setState) TransportService(org.elasticsearch.transport.TransportService) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) Before(org.junit.Before)

Example 82 with ThreadPool

use of org.elasticsearch.threadpool.ThreadPool in project elasticsearch by elastic.

the class DynamicMappingDisabledTests method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    Settings settings = Settings.builder().put(MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey(), false).build();
    clusterService = createClusterService(threadPool);
    Transport transport = new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE, new NoneCircuitBreakerService(), new NamedWriteableRegistry(Collections.emptyList()), new NetworkService(settings, Collections.emptyList()));
    transportService = new TransportService(clusterService.getSettings(), transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    IndicesService indicesService = getInstanceFromNode(IndicesService.class);
    ShardStateAction shardStateAction = new ShardStateAction(settings, clusterService, transportService, null, null, threadPool);
    ActionFilters actionFilters = new ActionFilters(Collections.emptySet());
    IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(settings);
    AutoCreateIndex autoCreateIndex = new AutoCreateIndex(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), indexNameExpressionResolver);
    UpdateHelper updateHelper = new UpdateHelper(settings, null);
    TransportShardBulkAction shardBulkAction = new TransportShardBulkAction(settings, transportService, clusterService, indicesService, threadPool, shardStateAction, null, updateHelper, actionFilters, indexNameExpressionResolver);
    transportBulkAction = new TransportBulkAction(settings, threadPool, transportService, clusterService, null, shardBulkAction, null, actionFilters, indexNameExpressionResolver, autoCreateIndex, System::currentTimeMillis);
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) ESSingleNodeTestCase(org.elasticsearch.test.ESSingleNodeTestCase) UpdateHelper(org.elasticsearch.action.update.UpdateHelper) BeforeClass(org.junit.BeforeClass) BigArrays(org.elasticsearch.common.util.BigArrays) ClusterServiceUtils.createClusterService(org.elasticsearch.test.ClusterServiceUtils.createClusterService) TransportBulkAction(org.elasticsearch.action.bulk.TransportBulkAction) ClusterService(org.elasticsearch.cluster.service.ClusterService) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TransportShardBulkAction(org.elasticsearch.action.bulk.TransportShardBulkAction) AutoCreateIndex(org.elasticsearch.action.support.AutoCreateIndex) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) IndexRequest(org.elasticsearch.action.index.IndexRequest) NetworkService(org.elasticsearch.common.network.NetworkService) Settings(org.elasticsearch.common.settings.Settings) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) IndexNotFoundException(org.elasticsearch.index.IndexNotFoundException) After(org.junit.After) ThreadPool(org.elasticsearch.threadpool.ThreadPool) Requests(org.elasticsearch.client.Requests) IndicesService(org.elasticsearch.indices.IndicesService) TransportService(org.elasticsearch.transport.TransportService) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) AfterClass(org.junit.AfterClass) ActionFilters(org.elasticsearch.action.support.ActionFilters) Transport(org.elasticsearch.transport.Transport) BulkResponse(org.elasticsearch.action.bulk.BulkResponse) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) TimeUnit(java.util.concurrent.TimeUnit) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) BulkRequest(org.elasticsearch.action.bulk.BulkRequest) Collections(java.util.Collections) ActionListener(org.elasticsearch.action.ActionListener) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) TransportBulkAction(org.elasticsearch.action.bulk.TransportBulkAction) IndicesService(org.elasticsearch.indices.IndicesService) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) ActionFilters(org.elasticsearch.action.support.ActionFilters) TransportShardBulkAction(org.elasticsearch.action.bulk.TransportShardBulkAction) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) UpdateHelper(org.elasticsearch.action.update.UpdateHelper) TransportService(org.elasticsearch.transport.TransportService) NetworkService(org.elasticsearch.common.network.NetworkService) AutoCreateIndex(org.elasticsearch.action.support.AutoCreateIndex) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) Transport(org.elasticsearch.transport.Transport) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) Settings(org.elasticsearch.common.settings.Settings) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Example 83 with ThreadPool

use of org.elasticsearch.threadpool.ThreadPool in project elasticsearch by elastic.

the class GlobalCheckpointSyncActionTests method setUp.

public void setUp() throws Exception {
    super.setUp();
    threadPool = new TestThreadPool(getClass().getName());
    transport = new CapturingTransport();
    clusterService = createClusterService(threadPool);
    transportService = new TransportService(clusterService.getSettings(), transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, boundAddress -> clusterService.localNode(), null);
    transportService.start();
    transportService.acceptIncomingRequests();
    shardStateAction = new ShardStateAction(Settings.EMPTY, clusterService, transportService, null, null, threadPool);
}
Also used : ShardId(org.elasticsearch.index.shard.ShardId) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) ActionFilters(org.elasticsearch.action.support.ActionFilters) Transport(org.elasticsearch.transport.Transport) ClusterServiceUtils.createClusterService(org.elasticsearch.test.ClusterServiceUtils.createClusterService) IndexService(org.elasticsearch.index.IndexService) IndexShard(org.elasticsearch.index.shard.IndexShard) ClusterService(org.elasticsearch.cluster.service.ClusterService) IOUtils(org.apache.lucene.util.IOUtils) Index(org.elasticsearch.index.Index) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) Mockito.verify(org.mockito.Mockito.verify) Settings(org.elasticsearch.common.settings.Settings) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) Translog(org.elasticsearch.index.translog.Translog) ThreadPool(org.elasticsearch.threadpool.ThreadPool) IndicesService(org.elasticsearch.indices.IndicesService) ESTestCase(org.elasticsearch.test.ESTestCase) TransportService(org.elasticsearch.transport.TransportService) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) Collections(java.util.Collections) Mockito.when(org.elasticsearch.mock.orig.Mockito.when) Mockito.mock(org.mockito.Mockito.mock) TransportService(org.elasticsearch.transport.TransportService) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool)

Example 84 with ThreadPool

use of org.elasticsearch.threadpool.ThreadPool in project crate by crate.

the class ThreadPools method newInstance.

public static ThreadPools newInstance(ThreadPool threadPool) {
    ThreadPools threadPools = ThreadPools.newInstance();
    for (ThreadPool.Info info : threadPool.info()) {
        String name = info.getName();
        ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.executor(name);
        threadPools.add(name, ThreadPoolExecutorContext.newInstance(executor));
    }
    return threadPools;
}
Also used : ThreadPool(org.elasticsearch.threadpool.ThreadPool) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 85 with ThreadPool

use of org.elasticsearch.threadpool.ThreadPool in project crate by crate.

the class NodeDisconnectJobMonitorServiceTest method testOnNodeDisconnectedKillsJobOriginatingFromThatNode.

@Test
public void testOnNodeDisconnectedKillsJobOriginatingFromThatNode() throws Exception {
    JobContextService jobContextService = jobContextService();
    JobExecutionContext.Builder builder = jobContextService.newBuilder(UUID.randomUUID());
    builder.addSubContext(new DummySubContext());
    JobExecutionContext context = jobContextService.createContext(builder);
    ThreadPool threadPool = mock(ThreadPool.class);
    when(threadPool.schedule(any(TimeValue.class), anyString(), any(Runnable.class))).thenAnswer((Answer<Object>) invocation -> {
        ((Runnable) invocation.getArguments()[2]).run();
        return null;
    });
    NodeDisconnectJobMonitorService monitorService = new NodeDisconnectJobMonitorService(Settings.EMPTY, threadPool, jobContextService, mock(TransportService.class), mock(TransportKillJobsNodeAction.class));
    monitorService.onNodeDisconnected(new DiscoveryNode("noop_id", DummyTransportAddress.INSTANCE, Version.CURRENT));
    expectedException.expect(ContextMissingException.class);
    jobContextService.getContext(context.jobId());
}
Also used : Arrays(java.util.Arrays) DummySubContext(io.crate.jobs.DummySubContext) Matchers.anyString(org.mockito.Matchers.anyString) TransportKillJobsNodeAction(io.crate.executor.transport.kill.TransportKillJobsNodeAction) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) Answer(org.mockito.stubbing.Answer) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) Settings(org.elasticsearch.common.settings.Settings) TimeValue(org.elasticsearch.common.unit.TimeValue) KillJobsRequest(io.crate.executor.transport.kill.KillJobsRequest) DummyTransportAddress(org.elasticsearch.common.transport.DummyTransportAddress) ThreadPool(org.elasticsearch.threadpool.ThreadPool) TransportService(org.elasticsearch.transport.TransportService) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) ContextMissingException(io.crate.exceptions.ContextMissingException) Test(org.junit.Test) UUID(java.util.UUID) JobsLogs(io.crate.operation.collect.stats.JobsLogs) CrateUnitTest(io.crate.test.integration.CrateUnitTest) JobExecutionContext(io.crate.jobs.JobExecutionContext) Matchers.any(org.mockito.Matchers.any) Mockito(org.mockito.Mockito) Version(org.elasticsearch.Version) JobContextService(io.crate.jobs.JobContextService) ActionListener(org.elasticsearch.action.ActionListener) TransportKillJobsNodeAction(io.crate.executor.transport.kill.TransportKillJobsNodeAction) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) ThreadPool(org.elasticsearch.threadpool.ThreadPool) DummySubContext(io.crate.jobs.DummySubContext) TransportService(org.elasticsearch.transport.TransportService) JobExecutionContext(io.crate.jobs.JobExecutionContext) TimeValue(org.elasticsearch.common.unit.TimeValue) JobContextService(io.crate.jobs.JobContextService) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

ThreadPool (org.elasticsearch.threadpool.ThreadPool)109 Settings (org.elasticsearch.common.settings.Settings)65 TestThreadPool (org.elasticsearch.threadpool.TestThreadPool)61 TimeUnit (java.util.concurrent.TimeUnit)39 IOException (java.io.IOException)36 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)36 Before (org.junit.Before)35 ESTestCase (org.elasticsearch.test.ESTestCase)34 TransportService (org.elasticsearch.transport.TransportService)33 ActionListener (org.elasticsearch.action.ActionListener)32 Version (org.elasticsearch.Version)31 ClusterState (org.elasticsearch.cluster.ClusterState)31 Collections (java.util.Collections)29 List (java.util.List)28 CountDownLatch (java.util.concurrent.CountDownLatch)28 ClusterService (org.elasticsearch.cluster.service.ClusterService)28 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)26 Set (java.util.Set)25 ArrayList (java.util.ArrayList)24 ShardId (org.elasticsearch.index.shard.ShardId)24