Search in sources :

Example 1 with AsynchronousSearchService

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());
}
Also used : AsynchronousSearchService(org.opensearch.search.asynchronous.service.AsynchronousSearchService) AsynchronousSearchActiveContext(org.opensearch.search.asynchronous.context.active.AsynchronousSearchActiveContext)

Example 2 with AsynchronousSearchService

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);
}
Also used : AsynchronousSearchService(org.opensearch.search.asynchronous.service.AsynchronousSearchService) AsynchronousSearchPersistenceService(org.opensearch.search.asynchronous.service.AsynchronousSearchPersistenceService) InternalAsynchronousSearchStats(org.opensearch.search.asynchronous.stats.InternalAsynchronousSearchStats) AsynchronousSearchActiveStore(org.opensearch.search.asynchronous.context.active.AsynchronousSearchActiveStore)

Example 3 with 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);
}
Also used : AsynchronousSearchService(org.opensearch.search.asynchronous.service.AsynchronousSearchService) SearchRequest(org.opensearch.action.search.SearchRequest) DeleteAsynchronousSearchRequest(org.opensearch.search.asynchronous.request.DeleteAsynchronousSearchRequest) SubmitAsynchronousSearchRequest(org.opensearch.search.asynchronous.request.SubmitAsynchronousSearchRequest) SubmitAsynchronousSearchRequest(org.opensearch.search.asynchronous.request.SubmitAsynchronousSearchRequest) MatchQueryBuilder(org.opensearch.index.query.MatchQueryBuilder) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) AsynchronousSearchResponse(org.opensearch.search.asynchronous.response.AsynchronousSearchResponse) SearchResponse(org.opensearch.action.search.SearchResponse)

Example 4 with AsynchronousSearchService

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);
}
Also used : AsynchronousSearchService(org.opensearch.search.asynchronous.service.AsynchronousSearchService)

Example 5 with AsynchronousSearchService

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);
}
Also used : AsynchronousSearchService(org.opensearch.search.asynchronous.service.AsynchronousSearchService) SearchRequest(org.opensearch.action.search.SearchRequest) DeleteAsynchronousSearchRequest(org.opensearch.search.asynchronous.request.DeleteAsynchronousSearchRequest) SubmitAsynchronousSearchRequest(org.opensearch.search.asynchronous.request.SubmitAsynchronousSearchRequest) SubmitAsynchronousSearchRequest(org.opensearch.search.asynchronous.request.SubmitAsynchronousSearchRequest) MatchQueryBuilder(org.opensearch.index.query.MatchQueryBuilder) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) AsynchronousSearchResponse(org.opensearch.search.asynchronous.response.AsynchronousSearchResponse) SearchResponse(org.opensearch.action.search.SearchResponse)

Aggregations

AsynchronousSearchService (org.opensearch.search.asynchronous.service.AsynchronousSearchService)5 SearchRequest (org.opensearch.action.search.SearchRequest)2 SearchResponse (org.opensearch.action.search.SearchResponse)2 MatchQueryBuilder (org.opensearch.index.query.MatchQueryBuilder)2 DeleteAsynchronousSearchRequest (org.opensearch.search.asynchronous.request.DeleteAsynchronousSearchRequest)2 SubmitAsynchronousSearchRequest (org.opensearch.search.asynchronous.request.SubmitAsynchronousSearchRequest)2 AsynchronousSearchResponse (org.opensearch.search.asynchronous.response.AsynchronousSearchResponse)2 SearchSourceBuilder (org.opensearch.search.builder.SearchSourceBuilder)2 AsynchronousSearchActiveContext (org.opensearch.search.asynchronous.context.active.AsynchronousSearchActiveContext)1 AsynchronousSearchActiveStore (org.opensearch.search.asynchronous.context.active.AsynchronousSearchActiveStore)1 AsynchronousSearchPersistenceService (org.opensearch.search.asynchronous.service.AsynchronousSearchPersistenceService)1 InternalAsynchronousSearchStats (org.opensearch.search.asynchronous.stats.InternalAsynchronousSearchStats)1