use of org.opensearch.search.asynchronous.service.AsynchronousSearchService in project asynchronous-search by opensearch-project.
the class AsynchronousSearchSingleNodeTestCase method assertAsynchronousSearchResourceCleanUp.
protected void assertAsynchronousSearchResourceCleanUp(String id) {
assertDocNotPresentInAsynchronousSearchResponseIndex(id);
AsynchronousSearchService asService = getInstanceFromNode(AsynchronousSearchService.class);
Map<Long, AsynchronousSearchActiveContext> activeContexts = asService.getAllActiveContexts();
assertTrue(activeContexts.isEmpty());
}
use of org.opensearch.search.asynchronous.service.AsynchronousSearchService in project asynchronous-search by opensearch-project.
the class AsynchronousSearchPlugin method createComponents.
@Override
public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, IndexNameExpressionResolver indexNameExpressionResolver, Supplier<RepositoriesService> repositoriesServiceSupplier) {
this.persistenceService = new AsynchronousSearchPersistenceService(client, clusterService, threadPool);
this.asynchronousSearchActiveStore = new AsynchronousSearchActiveStore(clusterService);
this.asynchronousSearchService = new AsynchronousSearchService(persistenceService, asynchronousSearchActiveStore, client, clusterService, threadPool, new InternalAsynchronousSearchStats(), namedWriteableRegistry);
return Arrays.asList(persistenceService, asynchronousSearchService);
}
use of org.opensearch.search.asynchronous.service.AsynchronousSearchService in project asynchronous-search by opensearch-project.
the class SubmitAsynchronousSearchSingleNodeIT method testSubmitAsynchronousSearchWithRetainedResponse.
public void testSubmitAsynchronousSearchWithRetainedResponse() throws InterruptedException {
SearchRequest searchRequest = new SearchRequest();
searchRequest.indices("index");
searchRequest.source(new SearchSourceBuilder().query(new MatchQueryBuilder("field", "value0")));
SearchResponse searchResponse = client().search(searchRequest).actionGet();
SubmitAsynchronousSearchRequest submitAsynchronousSearchRequest = new SubmitAsynchronousSearchRequest(searchRequest);
submitAsynchronousSearchRequest.keepOnCompletion(true);
submitAsynchronousSearchRequest.waitForCompletionTimeout(TimeValue.timeValueMillis(randomLongBetween(1, 5000)));
int concurrentRuns = randomIntBetween(20, 50);
assertConcurrentSubmits(submitAsynchronousSearchRequest, searchResponse, (numStartedAsynchronousSearch, numFailedAsynchronousSearch, numErrorResponseAsynchronousSearch) -> {
assertEquals(concurrentRuns, numStartedAsynchronousSearch.get());
assertEquals(0, numFailedAsynchronousSearch.get());
assertEquals(0, numErrorResponseAsynchronousSearch.get());
}, concurrentRuns);
AsynchronousSearchService asynchronousSearchService = getInstanceFromNode(AsynchronousSearchService.class);
waitUntil(asynchronousSearchService.getAllActiveContexts()::isEmpty, 30, TimeUnit.SECONDS);
}
use of org.opensearch.search.asynchronous.service.AsynchronousSearchService in project asynchronous-search by opensearch-project.
the class SubmitAsynchronousSearchSingleNodeIT method testSubmitAsynchronousSearchWithNoRetainedResponseBlocking.
public void testSubmitAsynchronousSearchWithNoRetainedResponseBlocking() throws Exception {
int concurrentRuns = randomIntBetween(asynchronousSearchConcurrentLimit + 10, asynchronousSearchConcurrentLimit + 20);
assertConcurrentSubmitsForBlockedSearch((numStartedAsynchronousSearch, numFailedAsynchronousSearch, numRejectedAsynchronousSearch) -> {
assertEquals(asynchronousSearchConcurrentLimit, numStartedAsynchronousSearch.get());
assertEquals(concurrentRuns - asynchronousSearchConcurrentLimit, numFailedAsynchronousSearch.get());
assertEquals(concurrentRuns - asynchronousSearchConcurrentLimit, numRejectedAsynchronousSearch.get());
}, concurrentRuns);
AsynchronousSearchService asynchronousSearchService = getInstanceFromNode(AsynchronousSearchService.class);
waitUntil(asynchronousSearchService.getAllActiveContexts()::isEmpty, 30, TimeUnit.SECONDS);
}
use of org.opensearch.search.asynchronous.service.AsynchronousSearchService in project asynchronous-search by opensearch-project.
the class SubmitAsynchronousSearchSingleNodeIT method testSubmitAsynchronousSearchWithoutRetainedResponse.
public void testSubmitAsynchronousSearchWithoutRetainedResponse() throws InterruptedException {
SearchRequest searchRequest = new SearchRequest();
searchRequest.indices("index");
searchRequest.source(new SearchSourceBuilder().query(new MatchQueryBuilder("field", "value0")));
SearchResponse searchResponse = client().search(searchRequest).actionGet();
SubmitAsynchronousSearchRequest submitAsynchronousSearchRequest = new SubmitAsynchronousSearchRequest(searchRequest);
submitAsynchronousSearchRequest.keepOnCompletion(false);
submitAsynchronousSearchRequest.waitForCompletionTimeout(TimeValue.timeValueMillis(randomLongBetween(1, 5000)));
int concurrentRuns = randomIntBetween(20, 50);
assertConcurrentSubmits(submitAsynchronousSearchRequest, searchResponse, (numStartedAsynchronousSearch, numFailedAsynchronousSearch, numErrorResponseAsynchronousSearch) -> {
assertEquals(concurrentRuns, numStartedAsynchronousSearch.get());
assertEquals(0, numFailedAsynchronousSearch.get());
assertEquals(0, numErrorResponseAsynchronousSearch.get());
}, concurrentRuns);
AsynchronousSearchService asynchronousSearchService = getInstanceFromNode(AsynchronousSearchService.class);
waitUntil(asynchronousSearchService.getAllActiveContexts()::isEmpty, 30, TimeUnit.SECONDS);
}
Aggregations