use of org.opensearch.threadpool.ScalingExecutorBuilder in project asynchronous-search by opensearch-project.
the class AsynchronousSearchActiveContextTests method testInitializeContext.
public void testInitializeContext() {
TestThreadPool threadPool = null;
try {
int writeThreadPoolSize = randomIntBetween(1, 2);
int writeThreadPoolQueueSize = randomIntBetween(1, 2);
Settings settings = Settings.builder().put("thread_pool." + AsynchronousSearchPlugin.OPEN_DISTRO_ASYNC_SEARCH_GENERIC_THREAD_POOL_NAME + ".size", writeThreadPoolSize).put("thread_pool." + AsynchronousSearchPlugin.OPEN_DISTRO_ASYNC_SEARCH_GENERIC_THREAD_POOL_NAME + ".queue_size", writeThreadPoolQueueSize).build();
final int availableProcessors = OpenSearchExecutors.allocatedProcessors(settings);
ScalingExecutorBuilder scalingExecutorBuilder = new ScalingExecutorBuilder(AsynchronousSearchPlugin.OPEN_DISTRO_ASYNC_SEARCH_GENERIC_THREAD_POOL_NAME, 1, Math.min(2 * availableProcessors, Math.max(128, 512)), TimeValue.timeValueMinutes(30));
threadPool = new TestThreadPool("Tests", settings, scalingExecutorBuilder);
String node = UUID.randomUUID().toString();
AsynchronousSearchProgressListener asProgressListener = mockAsynchronousSearchProgressListener(threadPool);
AsynchronousSearchContextId asContextId = new AsynchronousSearchContextId(UUID.randomUUID().toString(), randomNonNegativeLong());
boolean keepOnCompletion = randomBoolean();
User user = TestClientUtils.randomUser();
TimeValue keepAlive = TimeValue.timeValueDays(randomInt(100));
AsynchronousSearchActiveContext context = new AsynchronousSearchActiveContext(asContextId, node, keepAlive, keepOnCompletion, threadPool, threadPool::absoluteTimeInMillis, asProgressListener, user, () -> true);
assertEquals(AsynchronousSearchState.INIT, context.getAsynchronousSearchState());
assertNull(context.getTask());
assertNull(context.getAsynchronousSearchId());
assertEquals(context.getAsynchronousSearchState(), AsynchronousSearchState.INIT);
} finally {
ThreadPool.terminate(threadPool, 30, TimeUnit.SECONDS);
}
}
use of org.opensearch.threadpool.ScalingExecutorBuilder in project asynchronous-search by opensearch-project.
the class AsynchronousSearchContextPermitsTests method setupThreadPool.
@BeforeClass
public static void setupThreadPool() {
int writeThreadPoolSize = randomIntBetween(1, 2);
int writeThreadPoolQueueSize = randomIntBetween(1, 2);
Settings settings = Settings.builder().put("thread_pool." + AsynchronousSearchPlugin.OPEN_DISTRO_ASYNC_SEARCH_GENERIC_THREAD_POOL_NAME + ".size", writeThreadPoolSize).put("thread_pool." + AsynchronousSearchPlugin.OPEN_DISTRO_ASYNC_SEARCH_GENERIC_THREAD_POOL_NAME + ".queue_size", writeThreadPoolQueueSize).build();
final int availableProcessors = OpenSearchExecutors.allocatedProcessors(settings);
ScalingExecutorBuilder scalingExecutorBuilder = new ScalingExecutorBuilder(AsynchronousSearchPlugin.OPEN_DISTRO_ASYNC_SEARCH_GENERIC_THREAD_POOL_NAME, 1, Math.min(2 * availableProcessors, Math.max(128, 512)), TimeValue.timeValueMinutes(30));
threadPool = new TestThreadPool("PermitsTests", settings, scalingExecutorBuilder);
}
use of org.opensearch.threadpool.ScalingExecutorBuilder in project asynchronous-search by opensearch-project.
the class AsynchronousSearchPlugin method getExecutorBuilders.
// TODO Revisit these once we performance test the feature
@Override
public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings) {
final int availableProcessors = OpenSearchExecutors.allocatedProcessors(settings);
List<ExecutorBuilder<?>> executorBuilders = new ArrayList<>();
executorBuilders.add(new ScalingExecutorBuilder(OPEN_DISTRO_ASYNC_SEARCH_GENERIC_THREAD_POOL_NAME, 1, Math.min(2 * availableProcessors, Math.max(128, 512)), TimeValue.timeValueMinutes(30)));
return executorBuilders;
}
use of org.opensearch.threadpool.ScalingExecutorBuilder in project asynchronous-search by opensearch-project.
the class AsynchronousSearchServiceTests method createObjects.
@Before
public void createObjects() {
settings = Settings.builder().put("node.name", "test").put("cluster.name", "ClusterServiceTests").put(AsynchronousSearchActiveStore.NODE_CONCURRENT_RUNNING_SEARCHES_SETTING.getKey(), 10).put(AsynchronousSearchService.PERSIST_SEARCH_FAILURES_SETTING.getKey(), true).build();
final Set<Setting<?>> settingsSet = Stream.concat(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS.stream(), Stream.of(AsynchronousSearchActiveStore.NODE_CONCURRENT_RUNNING_SEARCHES_SETTING, AsynchronousSearchService.MAX_KEEP_ALIVE_SETTING, AsynchronousSearchService.PERSIST_SEARCH_FAILURES_SETTING, AsynchronousSearchService.MAX_SEARCH_RUNNING_TIME_SETTING, AsynchronousSearchService.MAX_WAIT_FOR_COMPLETION_TIMEOUT_SETTING)).collect(Collectors.toSet());
final int availableProcessors = OpenSearchExecutors.allocatedProcessors(settings);
List<ExecutorBuilder<?>> executorBuilders = new ArrayList<>();
executorBuilders.add(new ScalingExecutorBuilder(AsynchronousSearchPlugin.OPEN_DISTRO_ASYNC_SEARCH_GENERIC_THREAD_POOL_NAME, 1, Math.min(2 * availableProcessors, Math.max(128, 512)), TimeValue.timeValueMinutes(30)));
executorBuilder = executorBuilders.get(0);
clusterSettings = new ClusterSettings(settings, settingsSet);
blockPersistence = false;
}
use of org.opensearch.threadpool.ScalingExecutorBuilder in project asynchronous-search by opensearch-project.
the class AsynchronousSearchPostProcessorTests method createObjects.
@Before
public void createObjects() {
Settings settings = Settings.builder().put("node.name", "test").put("cluster.name", "ClusterServiceTests").put(AsynchronousSearchActiveStore.NODE_CONCURRENT_RUNNING_SEARCHES_SETTING.getKey(), 10).build();
final Set<Setting<?>> settingsSet = Stream.concat(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS.stream(), Stream.of(AsynchronousSearchActiveStore.NODE_CONCURRENT_RUNNING_SEARCHES_SETTING, AsynchronousSearchService.PERSIST_SEARCH_FAILURES_SETTING, AsynchronousSearchService.MAX_KEEP_ALIVE_SETTING, AsynchronousSearchService.MAX_SEARCH_RUNNING_TIME_SETTING, AsynchronousSearchService.MAX_WAIT_FOR_COMPLETION_TIMEOUT_SETTING)).collect(Collectors.toSet());
final int availableProcessors = OpenSearchExecutors.allocatedProcessors(settings);
List<ExecutorBuilder<?>> executorBuilders = new ArrayList<>();
executorBuilders.add(new ScalingExecutorBuilder(AsynchronousSearchPlugin.OPEN_DISTRO_ASYNC_SEARCH_GENERIC_THREAD_POOL_NAME, 1, Math.min(2 * availableProcessors, Math.max(128, 512)), TimeValue.timeValueMinutes(30)));
executorBuilder = executorBuilders.get(0);
clusterSettings = new ClusterSettings(settings, settingsSet);
}
Aggregations