Search in sources :

Example 76 with ClusterSettings

use of org.elasticsearch.common.settings.ClusterSettings 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 77 with ClusterSettings

use of org.elasticsearch.common.settings.ClusterSettings in project elasticsearch by elastic.

the class ScalingThreadPoolTests method testScalingThreadPoolIsBounded.

public void testScalingThreadPoolIsBounded() throws InterruptedException {
    final String threadPoolName = randomThreadPool(ThreadPool.ThreadPoolType.SCALING);
    final int size = randomIntBetween(32, 512);
    final Settings settings = Settings.builder().put("thread_pool." + threadPoolName + ".max", size).build();
    runScalingThreadPoolTest(settings, (clusterSettings, threadPool) -> {
        final CountDownLatch latch = new CountDownLatch(1);
        final int numberOfTasks = 2 * size;
        final CountDownLatch taskLatch = new CountDownLatch(numberOfTasks);
        for (int i = 0; i < numberOfTasks; i++) {
            threadPool.executor(threadPoolName).execute(() -> {
                try {
                    latch.await();
                    taskLatch.countDown();
                } catch (final InterruptedException e) {
                    throw new RuntimeException(e);
                }
            });
        }
        final ThreadPoolStats.Stats stats = stats(threadPool, threadPoolName);
        assertThat(stats.getQueue(), equalTo(numberOfTasks - size));
        assertThat(stats.getLargest(), equalTo(size));
        latch.countDown();
        try {
            taskLatch.await();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    });
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) Settings(org.elasticsearch.common.settings.Settings)

Example 78 with ClusterSettings

use of org.elasticsearch.common.settings.ClusterSettings in project elasticsearch by elastic.

the class ScalingThreadPoolTests method runScalingThreadPoolTest.

public void runScalingThreadPoolTest(final Settings settings, final BiConsumer<ClusterSettings, ThreadPool> consumer) throws InterruptedException {
    ThreadPool threadPool = null;
    try {
        final String test = Thread.currentThread().getStackTrace()[2].getMethodName();
        final Settings nodeSettings = Settings.builder().put(settings).put("node.name", test).build();
        threadPool = new ThreadPool(nodeSettings);
        final ClusterSettings clusterSettings = new ClusterSettings(nodeSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
        consumer.accept(clusterSettings, threadPool);
    } finally {
        terminateThreadPoolIfNeeded(threadPool);
    }
}
Also used : ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) Settings(org.elasticsearch.common.settings.Settings)

Example 79 with ClusterSettings

use of org.elasticsearch.common.settings.ClusterSettings in project elasticsearch by elastic.

the class ScalingThreadPoolTests method testScalingThreadPoolConfiguration.

public void testScalingThreadPoolConfiguration() throws InterruptedException {
    final String threadPoolName = randomThreadPool(ThreadPool.ThreadPoolType.SCALING);
    final Settings.Builder builder = Settings.builder();
    final int core;
    if (randomBoolean()) {
        core = randomIntBetween(0, 8);
        builder.put("thread_pool." + threadPoolName + ".core", core);
    } else {
        // the defaults
        core = "generic".equals(threadPoolName) ? 4 : 1;
    }
    final int maxBasedOnNumberOfProcessors;
    if (randomBoolean()) {
        final int processors = randomIntBetween(1, 64);
        maxBasedOnNumberOfProcessors = expectedSize(threadPoolName, processors);
        builder.put("processors", processors);
    } else {
        maxBasedOnNumberOfProcessors = expectedSize(threadPoolName, Math.min(32, Runtime.getRuntime().availableProcessors()));
    }
    final int expectedMax;
    if (maxBasedOnNumberOfProcessors < core || randomBoolean()) {
        expectedMax = randomIntBetween(Math.max(1, core), 16);
        builder.put("thread_pool." + threadPoolName + ".max", expectedMax);
    } else {
        expectedMax = maxBasedOnNumberOfProcessors;
    }
    final long keepAlive;
    if (randomBoolean()) {
        keepAlive = randomIntBetween(1, 300);
        builder.put("thread_pool." + threadPoolName + ".keep_alive", keepAlive + "s");
    } else {
        // the defaults
        keepAlive = "generic".equals(threadPoolName) ? 30 : 300;
    }
    runScalingThreadPoolTest(builder.build(), (clusterSettings, threadPool) -> {
        final Executor executor = threadPool.executor(threadPoolName);
        assertThat(executor, instanceOf(EsThreadPoolExecutor.class));
        final EsThreadPoolExecutor esThreadPoolExecutor = (EsThreadPoolExecutor) executor;
        final ThreadPool.Info info = info(threadPool, threadPoolName);
        assertThat(info.getName(), equalTo(threadPoolName));
        assertThat(info.getThreadPoolType(), equalTo(ThreadPool.ThreadPoolType.SCALING));
        assertThat(info.getKeepAlive().seconds(), equalTo(keepAlive));
        assertThat(esThreadPoolExecutor.getKeepAliveTime(TimeUnit.SECONDS), equalTo(keepAlive));
        assertNull(info.getQueueSize());
        assertThat(esThreadPoolExecutor.getQueue().remainingCapacity(), equalTo(Integer.MAX_VALUE));
        assertThat(info.getMin(), equalTo(core));
        assertThat(esThreadPoolExecutor.getCorePoolSize(), equalTo(core));
        assertThat(info.getMax(), equalTo(expectedMax));
        assertThat(esThreadPoolExecutor.getMaximumPoolSize(), equalTo(expectedMax));
    });
}
Also used : Executor(java.util.concurrent.Executor) EsThreadPoolExecutor(org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor) EsThreadPoolExecutor(org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) Settings(org.elasticsearch.common.settings.Settings)

Example 80 with ClusterSettings

use of org.elasticsearch.common.settings.ClusterSettings in project crate by crate.

the class JobsLogsTest method testErrorIsRaisedInitiallyOnInvalidFilterExpression.

@Test
public void testErrorIsRaisedInitiallyOnInvalidFilterExpression() {
    Settings settings = Settings.builder().put(JobsLogService.STATS_JOBS_LOG_FILTER.getKey(), "invalid_column = 10").build();
    expectedException.expectMessage("Invalid filter expression: invalid_column = 10: Column invalid_column unknown");
    new JobsLogService(settings, clusterService::localNode, clusterSettings, nodeCtx, scheduler, breakerService);
}
Also used : Settings(org.elasticsearch.common.settings.Settings) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Aggregations

ClusterSettings (org.elasticsearch.common.settings.ClusterSettings)109 Settings (org.elasticsearch.common.settings.Settings)58 ClusterState (org.elasticsearch.cluster.ClusterState)50 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)30 RoutingTable (org.elasticsearch.cluster.routing.RoutingTable)25 Matchers.containsString (org.hamcrest.Matchers.containsString)25 Test (org.junit.Test)25 MetaData (org.elasticsearch.cluster.metadata.MetaData)21 BalancedShardsAllocator (org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator)21 AllocationService (org.elasticsearch.cluster.routing.allocation.AllocationService)20 ClusterInfo (org.elasticsearch.cluster.ClusterInfo)18 DiskUsage (org.elasticsearch.cluster.DiskUsage)18 ShardRouting (org.elasticsearch.cluster.routing.ShardRouting)18 ImmutableOpenMap (org.elasticsearch.common.collect.ImmutableOpenMap)18 TestGatewayAllocator (org.elasticsearch.test.gateway.TestGatewayAllocator)18 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)17 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)15 RoutingNode (org.elasticsearch.cluster.routing.RoutingNode)14 HashSet (java.util.HashSet)13 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)13