Search in sources :

Example 66 with ThreadPool

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

the class ActionModuleTests method testPluginCanRegisterAction.

public void testPluginCanRegisterAction() {
    class FakeRequest extends ActionRequest {

        @Override
        public ActionRequestValidationException validate() {
            return null;
        }
    }
    class FakeTransportAction extends TransportAction<FakeRequest, ActionResponse> {

        protected FakeTransportAction(Settings settings, String actionName, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, TaskManager taskManager) {
            super(settings, actionName, threadPool, actionFilters, indexNameExpressionResolver, taskManager);
        }

        @Override
        protected void doExecute(FakeRequest request, ActionListener<ActionResponse> listener) {
        }
    }
    class FakeAction extends GenericAction<FakeRequest, ActionResponse> {

        protected FakeAction() {
            super("fake");
        }

        @Override
        public ActionResponse newResponse() {
            return null;
        }
    }
    FakeAction action = new FakeAction();
    ActionPlugin registersFakeAction = new ActionPlugin() {

        @Override
        public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
            return singletonList(new ActionHandler<>(action, FakeTransportAction.class));
        }
    };
    assertThat(ActionModule.setupActions(singletonList(registersFakeAction)), hasEntry("fake", new ActionHandler<>(action, FakeTransportAction.class)));
}
Also used : ThreadPool(org.elasticsearch.threadpool.ThreadPool) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) ActionPlugin(org.elasticsearch.plugins.ActionPlugin) ActionFilters(org.elasticsearch.action.support.ActionFilters) TransportAction(org.elasticsearch.action.support.TransportAction) TaskManager(org.elasticsearch.tasks.TaskManager) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) ActionHandler(org.elasticsearch.plugins.ActionPlugin.ActionHandler) Settings(org.elasticsearch.common.settings.Settings) IndexScopedSettings(org.elasticsearch.common.settings.IndexScopedSettings) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings)

Example 67 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 68 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 69 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 70 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)

Aggregations

ThreadPool (org.elasticsearch.threadpool.ThreadPool)74 Settings (org.elasticsearch.common.settings.Settings)48 TestThreadPool (org.elasticsearch.threadpool.TestThreadPool)45 TimeUnit (java.util.concurrent.TimeUnit)25 Before (org.junit.Before)25 IOException (java.io.IOException)22 TimeValue (org.elasticsearch.common.unit.TimeValue)22 Collections (java.util.Collections)21 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)21 ClusterState (org.elasticsearch.cluster.ClusterState)20 BigArrays (org.elasticsearch.common.util.BigArrays)20 TransportService (org.elasticsearch.transport.TransportService)19 List (java.util.List)18 ESTestCase (org.elasticsearch.test.ESTestCase)18 CountDownLatch (java.util.concurrent.CountDownLatch)17 Version (org.elasticsearch.Version)17 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)17 AtomicReference (java.util.concurrent.atomic.AtomicReference)16 ActionListener (org.elasticsearch.action.ActionListener)16 Arrays (java.util.Arrays)15