Search in sources :

Example 1 with TimeValue.timeValueSeconds

use of org.opensearch.common.unit.TimeValue.timeValueSeconds in project OpenSearch by opensearch-project.

the class AsyncBulkByScrollActionTests method testStartNextScrollRetriesOnRejectionButFailsOnTooManyRejections.

public void testStartNextScrollRetriesOnRejectionButFailsOnTooManyRejections() throws Exception {
    // this test primarily tests ClientScrollableHitSource but left it to test integration to status
    client.scrollsToReject = testRequest.getMaxRetries() + randomIntBetween(1, 100);
    assertExactlyOnce(onFail -> {
        Consumer<Exception> validingOnFail = e -> {
            assertNotNull(ExceptionsHelper.unwrap(e, OpenSearchRejectedExecutionException.class));
            onFail.run();
        };
        ClientScrollableHitSource hitSource = new ClientScrollableHitSource(logger, buildTestBackoffPolicy(), threadPool, testTask.getWorkerState()::countSearchRetry, r -> fail(), validingOnFail, new ParentTaskAssigningClient(client, localNode, testTask), testRequest.getSearchRequest());
        hitSource.setScroll(scrollId());
        hitSource.startNextScroll(TimeValue.timeValueSeconds(0));
        assertBusy(() -> assertEquals(testRequest.getMaxRetries() + 1, client.scrollAttempts.get()));
    });
    assertNull("There shouldn't be a scroll attempt pending that we didn't reject", client.lastScroll.get());
    assertEquals(testRequest.getMaxRetries(), testTask.getStatus().getSearchRetries());
}
Also used : OpenSearchRejectedExecutionException(org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException) Matchers.hasToString(org.hamcrest.Matchers.hasToString) RefreshRequest(org.opensearch.action.admin.indices.refresh.RefreshRequest) IndexResponse(org.opensearch.action.index.IndexResponse) TestThreadPool(org.opensearch.threadpool.TestThreadPool) Version(org.opensearch.Version) ActionRequest(org.opensearch.action.ActionRequest) Collections.singletonList(java.util.Collections.singletonList) ReduceSearchPhaseException(org.opensearch.action.search.ReduceSearchPhaseException) SearchFailure(org.opensearch.index.reindex.ScrollableHitSource.SearchFailure) PlainActionFuture(org.opensearch.action.support.PlainActionFuture) Map(java.util.Map) ActionType(org.opensearch.action.ActionType) ActionListener(org.opensearch.action.ActionListener) ActionResponse(org.opensearch.action.ActionResponse) DeleteRequest(org.opensearch.action.delete.DeleteRequest) Client(org.opensearch.client.Client) TimeValue(org.opensearch.common.unit.TimeValue) Index(org.opensearch.index.Index) SearchHit(org.opensearch.search.SearchHit) NoOpClient(org.opensearch.test.client.NoOpClient) ExceptionsHelper(org.opensearch.ExceptionsHelper) Set(java.util.Set) Settings(org.opensearch.common.settings.Settings) TaskManager(org.opensearch.tasks.TaskManager) TimeValue.timeValueSeconds(org.opensearch.common.unit.TimeValue.timeValueSeconds) Failure(org.opensearch.action.bulk.BulkItemResponse.Failure) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ActionFilters(org.opensearch.action.support.ActionFilters) Matchers.contains(org.hamcrest.Matchers.contains) BytesArray(org.opensearch.common.bytes.BytesArray) FilterClient(org.opensearch.client.FilterClient) DocWriteResponse(org.opensearch.action.DocWriteResponse) UpdateRequest(org.opensearch.action.update.UpdateRequest) XContentType(org.opensearch.common.xcontent.XContentType) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.containsString(org.hamcrest.Matchers.containsString) UpdateResponse(org.opensearch.action.update.UpdateResponse) ThreadPool(org.opensearch.threadpool.ThreadPool) DocWriteRequest(org.opensearch.action.DocWriteRequest) SearchHits(org.opensearch.search.SearchHits) ArrayList(java.util.ArrayList) SearchScrollRequest(org.opensearch.action.search.SearchScrollRequest) DeleteResponse(org.opensearch.action.delete.DeleteResponse) SearchRequest(org.opensearch.action.search.SearchRequest) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Before(org.junit.Before) TaskId(org.opensearch.tasks.TaskId) InternalSearchResponse(org.opensearch.search.internal.InternalSearchResponse) TotalHits(org.apache.lucene.search.TotalHits) ExecutionException(java.util.concurrent.ExecutionException) ShardSearchFailure(org.opensearch.action.search.ShardSearchFailure) Hit(org.opensearch.index.reindex.ScrollableHitSource.Hit) SearchPhaseExecutionException(org.opensearch.action.search.SearchPhaseExecutionException) Assert(org.junit.Assert) Matchers.either(org.hamcrest.Matchers.either) AbstractRunnable(org.opensearch.common.util.concurrent.AbstractRunnable) BulkRequest(org.opensearch.action.bulk.BulkRequest) OpenSearchException(org.opensearch.OpenSearchException) Collections.synchronizedSet(java.util.Collections.synchronizedSet) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) Collections.singleton(java.util.Collections.singleton) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BackoffPolicy(org.opensearch.action.bulk.BackoffPolicy) BulkItemResponse(org.opensearch.action.bulk.BulkItemResponse) After(org.junit.After) Delayed(java.util.concurrent.Delayed) IdentityHashMap(java.util.IdentityHashMap) Collections.emptyList(java.util.Collections.emptyList) Matchers.lessThanOrEqualTo(org.hamcrest.Matchers.lessThanOrEqualTo) OpenSearchTestCase(org.opensearch.test.OpenSearchTestCase) Result(org.opensearch.action.DocWriteResponse.Result) Task(org.opensearch.tasks.Task) RestStatus(org.opensearch.rest.RestStatus) BackoffPolicy.constantBackoff(org.opensearch.action.bulk.BackoffPolicy.constantBackoff) TransportAction(org.opensearch.action.support.TransportAction) List(java.util.List) Matchers.equalTo(org.hamcrest.Matchers.equalTo) IntStream(java.util.stream.IntStream) TimeValue.timeValueMillis(org.opensearch.common.unit.TimeValue.timeValueMillis) CheckedConsumer(org.opensearch.common.CheckedConsumer) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) Collections.newSetFromMap(java.util.Collections.newSetFromMap) ClearScrollResponse(org.opensearch.action.search.ClearScrollResponse) SearchResponse(org.opensearch.action.search.SearchResponse) Collections.emptyMap(java.util.Collections.emptyMap) Matchers.empty(org.hamcrest.Matchers.empty) ParentTaskAssigningClient(org.opensearch.client.ParentTaskAssigningClient) Iterator(java.util.Iterator) Collections.emptySet(java.util.Collections.emptySet) VersionConflictEngineException(org.opensearch.index.engine.VersionConflictEngineException) ShardId(org.opensearch.index.shard.ShardId) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) BulkResponse(org.opensearch.action.bulk.BulkResponse) ClearScrollRequest(org.opensearch.action.search.ClearScrollRequest) IndexRequest(org.opensearch.action.index.IndexRequest) TestUtil.randomSimpleString(org.apache.lucene.util.TestUtil.randomSimpleString) Collections(java.util.Collections) ParentTaskAssigningClient(org.opensearch.client.ParentTaskAssigningClient) OpenSearchRejectedExecutionException(org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException) ReduceSearchPhaseException(org.opensearch.action.search.ReduceSearchPhaseException) ExecutionException(java.util.concurrent.ExecutionException) SearchPhaseExecutionException(org.opensearch.action.search.SearchPhaseExecutionException) OpenSearchException(org.opensearch.OpenSearchException) VersionConflictEngineException(org.opensearch.index.engine.VersionConflictEngineException)

Aggregations

ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Collections.emptySet (java.util.Collections.emptySet)1 Collections.newSetFromMap (java.util.Collections.newSetFromMap)1 Collections.singleton (java.util.Collections.singleton)1 Collections.singletonList (java.util.Collections.singletonList)1 Collections.synchronizedSet (java.util.Collections.synchronizedSet)1 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Delayed (java.util.concurrent.Delayed)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1