Search in sources :

Example 21 with ThreadPool

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

the class DiscoveryModuleTests method setupDummyServices.

@Before
public void setupDummyServices() {
    transportService = MockTransportService.createNewService(Settings.EMPTY, Version.CURRENT, null, null);
    clusterService = mock(ClusterService.class);
    namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
    when(clusterService.getClusterSettings()).thenReturn(clusterSettings);
    threadPool = mock(ThreadPool.class);
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) ClusterService(org.elasticsearch.cluster.service.ClusterService) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) ThreadPool(org.elasticsearch.threadpool.ThreadPool) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) Before(org.junit.Before)

Example 22 with ThreadPool

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

the class IndexFieldDataServiceTests method doTestRequireDocValues.

private void doTestRequireDocValues(MappedFieldType ft) {
    ThreadPool threadPool = new TestThreadPool("random_threadpool_name");
    try {
        IndicesFieldDataCache cache = new IndicesFieldDataCache(Settings.EMPTY, null);
        IndexFieldDataService ifds = new IndexFieldDataService(IndexSettingsModule.newIndexSettings("test", Settings.EMPTY), cache, null, null);
        ft.setName("some_long");
        ft.setHasDocValues(true);
        // no exception
        ifds.getForField(ft);
        ft.setHasDocValues(false);
        try {
            ifds.getForField(ft);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e.getMessage(), containsString("doc values"));
        }
    } finally {
        threadPool.shutdown();
    }
}
Also used : IndicesFieldDataCache(org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache) ThreadPool(org.elasticsearch.threadpool.ThreadPool) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool)

Example 23 with ThreadPool

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

the class IngestServiceTests method testIngestPluginDuplicate.

public void testIngestPluginDuplicate() {
    ThreadPool tp = Mockito.mock(ThreadPool.class);
    IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new IngestService(Settings.EMPTY, tp, null, null, null, Arrays.asList(DUMMY_PLUGIN, DUMMY_PLUGIN)));
    assertTrue(e.getMessage(), e.getMessage().contains("already registered"));
}
Also used : ThreadPool(org.elasticsearch.threadpool.ThreadPool)

Example 24 with ThreadPool

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

the class TransportReplicationActionTests method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    transport = new CapturingTransport();
    clusterService = createClusterService(threadPool);
    transportService = new TransportService(clusterService.getSettings(), transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    transportService.start();
    transportService.acceptIncomingRequests();
    shardStateAction = new ShardStateAction(Settings.EMPTY, clusterService, transportService, null, null, threadPool);
    action = new TestAction(Settings.EMPTY, "testAction", transportService, clusterService, shardStateAction, threadPool);
}
Also used : ElasticsearchException(org.elasticsearch.ElasticsearchException) MetaData(org.elasticsearch.cluster.metadata.MetaData) ShardId(org.elasticsearch.index.shard.ShardId) ESAllocationTestCase(org.elasticsearch.cluster.ESAllocationTestCase) StreamOutput(org.elasticsearch.common.io.stream.StreamOutput) TransportRequest(org.elasticsearch.transport.TransportRequest) Nullable(org.elasticsearch.common.Nullable) ClusterServiceUtils.createClusterService(org.elasticsearch.test.ClusterServiceUtils.createClusterService) AlreadyClosedException(org.apache.lucene.store.AlreadyClosedException) AllocationService(org.elasticsearch.cluster.routing.allocation.AllocationService) ClusterBlocks(org.elasticsearch.cluster.block.ClusterBlocks) IndexClosedException(org.elasticsearch.indices.IndexClosedException) NodeClosedException(org.elasticsearch.node.NodeClosedException) ShardNotFoundException(org.elasticsearch.index.shard.ShardNotFoundException) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) Mockito.doThrow(org.mockito.Mockito.doThrow) ClusterState(org.elasticsearch.cluster.ClusterState) Settings(org.elasticsearch.common.settings.Settings) ClusterBlock(org.elasticsearch.cluster.block.ClusterBlock) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IndexNotFoundException(org.elasticsearch.index.IndexNotFoundException) Locale(java.util.Locale) After(org.junit.After) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Mockito.doAnswer(org.mockito.Mockito.doAnswer) ClusterStateCreationUtils.stateWithActivePrimary(org.elasticsearch.action.support.replication.ClusterStateCreationUtils.stateWithActivePrimary) Matchers.anyInt(org.mockito.Matchers.anyInt) ThreadPool(org.elasticsearch.threadpool.ThreadPool) Releasable(org.elasticsearch.common.lease.Releasable) TransportResponseOptions(org.elasticsearch.transport.TransportResponseOptions) AfterClass(org.junit.AfterClass) ActionFilters(org.elasticsearch.action.support.ActionFilters) ClusterStateChanges(org.elasticsearch.indices.cluster.ClusterStateChanges) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ReplicaResponse(org.elasticsearch.action.support.replication.ReplicationOperation.ReplicaResponse) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) PlainActionFuture(org.elasticsearch.action.support.PlainActionFuture) NoNodeAvailableException(org.elasticsearch.client.transport.NoNodeAvailableException) IndexShardRoutingTable(org.elasticsearch.cluster.routing.IndexShardRoutingTable) Collectors(java.util.stream.Collectors) ActiveShardCount(org.elasticsearch.action.support.ActiveShardCount) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) Matchers.any(org.mockito.Matchers.any) List(java.util.List) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) RestStatus(org.elasticsearch.rest.RestStatus) Matchers.equalTo(org.hamcrest.Matchers.equalTo) TransportException(org.elasticsearch.transport.TransportException) TestShardRouting(org.elasticsearch.cluster.routing.TestShardRouting) Mockito.mock(org.mockito.Mockito.mock) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting) ClusterStateCreationUtils.state(org.elasticsearch.action.support.replication.ClusterStateCreationUtils.state) Matchers.arrayWithSize(org.hamcrest.Matchers.arrayWithSize) IndexShardClosedException(org.elasticsearch.index.shard.IndexShardClosedException) TransportChannel(org.elasticsearch.transport.TransportChannel) BeforeClass(org.junit.BeforeClass) ClusterService(org.elasticsearch.cluster.service.ClusterService) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Index(org.elasticsearch.index.Index) ShardRoutingState(org.elasticsearch.cluster.routing.ShardRoutingState) AtomicReference(java.util.concurrent.atomic.AtomicReference) Matchers.anyString(org.mockito.Matchers.anyString) HashSet(java.util.HashSet) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException) Matchers.anyLong(org.mockito.Matchers.anyLong) TransportResponse(org.elasticsearch.transport.TransportResponse) IndicesService(org.elasticsearch.indices.IndicesService) ESTestCase(org.elasticsearch.test.ESTestCase) TransportService(org.elasticsearch.transport.TransportService) ClusterBlockLevel(org.elasticsearch.cluster.block.ClusterBlockLevel) Before(org.junit.Before) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) IndexShardState(org.elasticsearch.index.shard.IndexShardState) IndexService(org.elasticsearch.index.IndexService) IndexShard(org.elasticsearch.index.shard.IndexShard) RoutingNode(org.elasticsearch.cluster.routing.RoutingNode) IOException(java.io.IOException) Mockito.when(org.mockito.Mockito.when) UnavailableShardsException(org.elasticsearch.action.UnavailableShardsException) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) CloseIndexRequest(org.elasticsearch.action.admin.indices.close.CloseIndexRequest) SETTING_WAIT_FOR_ACTIVE_SHARDS(org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_WAIT_FOR_ACTIVE_SHARDS) StreamInput(org.elasticsearch.common.io.stream.StreamInput) Matcher(org.hamcrest.Matcher) AllocationId(org.elasticsearch.cluster.routing.AllocationId) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) Collections(java.util.Collections) ClusterServiceUtils.setState(org.elasticsearch.test.ClusterServiceUtils.setState) ActionListener(org.elasticsearch.action.ActionListener) TransportService(org.elasticsearch.transport.TransportService) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) Before(org.junit.Before)

Example 25 with ThreadPool

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

the class BroadcastReplicationTests method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    MockTcpTransport transport = new MockTcpTransport(Settings.EMPTY, threadPool, BigArrays.NON_RECYCLING_INSTANCE, circuitBreakerService, new NamedWriteableRegistry(Collections.emptyList()), new NetworkService(Settings.EMPTY, Collections.emptyList()));
    clusterService = createClusterService(threadPool);
    transportService = new TransportService(clusterService.getSettings(), transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    transportService.start();
    transportService.acceptIncomingRequests();
    broadcastReplicationAction = new TestBroadcastReplicationAction(Settings.EMPTY, threadPool, clusterService, transportService, new ActionFilters(new HashSet<>()), new IndexNameExpressionResolver(Settings.EMPTY), null);
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) ShardId(org.elasticsearch.index.shard.ShardId) BigArrays(org.elasticsearch.common.util.BigArrays) Date(java.util.Date) ClusterServiceUtils.createClusterService(org.elasticsearch.test.ClusterServiceUtils.createClusterService) ConcurrentCollections(org.elasticsearch.common.util.concurrent.ConcurrentCollections) ClusterState(org.elasticsearch.cluster.ClusterState) Future(java.util.concurrent.Future) Settings(org.elasticsearch.common.settings.Settings) After(org.junit.After) BroadcastRequest(org.elasticsearch.action.support.broadcast.BroadcastRequest) ThreadPool(org.elasticsearch.threadpool.ThreadPool) AfterClass(org.junit.AfterClass) ActionFilters(org.elasticsearch.action.support.ActionFilters) BroadcastResponse(org.elasticsearch.action.support.broadcast.BroadcastResponse) Matchers.lessThanOrEqualTo(org.hamcrest.Matchers.lessThanOrEqualTo) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) Set(java.util.Set) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) List(java.util.List) RestStatus(org.elasticsearch.rest.RestStatus) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Task(org.elasticsearch.tasks.Task) ClusterStateCreationUtils.stateWithNoShard(org.elasticsearch.action.support.replication.ClusterStateCreationUtils.stateWithNoShard) ClusterStateCreationUtils.state(org.elasticsearch.action.support.replication.ClusterStateCreationUtils.state) BeforeClass(org.junit.BeforeClass) ClusterService(org.elasticsearch.cluster.service.ClusterService) ShardRoutingState(org.elasticsearch.cluster.routing.ShardRoutingState) CircuitBreakerService(org.elasticsearch.indices.breaker.CircuitBreakerService) HashSet(java.util.HashSet) NetworkService(org.elasticsearch.common.network.NetworkService) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) ClusterStateCreationUtils.stateWithAssignedPrimariesAndOneReplica(org.elasticsearch.action.support.replication.ClusterStateCreationUtils.stateWithAssignedPrimariesAndOneReplica) ESTestCase(org.elasticsearch.test.ESTestCase) TransportService(org.elasticsearch.transport.TransportService) FlushResponse(org.elasticsearch.action.admin.indices.flush.FlushResponse) Before(org.junit.Before) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) TransportFlushAction(org.elasticsearch.action.admin.indices.flush.TransportFlushAction) IOUtils(org.apache.lucene.util.IOUtils) NoShardAvailableActionException(org.elasticsearch.action.NoShardAvailableActionException) IOException(java.io.IOException) ShardOperationFailedException(org.elasticsearch.action.ShardOperationFailedException) UnavailableShardsException(org.elasticsearch.action.UnavailableShardsException) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) FlushRequest(org.elasticsearch.action.admin.indices.flush.FlushRequest) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) Tuple(org.elasticsearch.common.collect.Tuple) Collections(java.util.Collections) ClusterServiceUtils.setState(org.elasticsearch.test.ClusterServiceUtils.setState) ActionListener(org.elasticsearch.action.ActionListener) TransportService(org.elasticsearch.transport.TransportService) NetworkService(org.elasticsearch.common.network.NetworkService) ActionFilters(org.elasticsearch.action.support.ActionFilters) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) Before(org.junit.Before)

Aggregations

ThreadPool (org.elasticsearch.threadpool.ThreadPool)73 Settings (org.elasticsearch.common.settings.Settings)47 TestThreadPool (org.elasticsearch.threadpool.TestThreadPool)45 TimeUnit (java.util.concurrent.TimeUnit)25 Before (org.junit.Before)24 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 Arrays (java.util.Arrays)15 HashSet (java.util.HashSet)15