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);
}
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);
}
});
}
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);
}
}
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));
});
}
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);
}
Aggregations