use of org.opensearch.client.ParentTaskAssigningClient in project OpenSearch by opensearch-project.
the class TransportUpdateByQueryAction method doExecute.
@Override
protected void doExecute(Task task, UpdateByQueryRequest request, ActionListener<BulkByScrollResponse> listener) {
BulkByScrollTask bulkByScrollTask = (BulkByScrollTask) task;
BulkByScrollParallelizationHelper.startSlicedAction(request, bulkByScrollTask, UpdateByQueryAction.INSTANCE, listener, client, clusterService.localNode(), () -> {
ClusterState state = clusterService.state();
ParentTaskAssigningClient assigningClient = new ParentTaskAssigningClient(client, clusterService.localNode(), bulkByScrollTask);
new AsyncIndexBySearchAction(bulkByScrollTask, logger, assigningClient, threadPool, scriptService, request, state, listener).start();
});
}
use of org.opensearch.client.ParentTaskAssigningClient in project OpenSearch by opensearch-project.
the class AsyncBulkByScrollActionTests method testStartNextScrollRetriesOnRejectionAndSucceeds.
public void testStartNextScrollRetriesOnRejectionAndSucceeds() throws Exception {
// this test primarily tests ClientScrollableHitSource but left it to test integration to status
client.scrollsToReject = randomIntBetween(0, testRequest.getMaxRetries() - 1);
// use fail() onResponse handler because mocked search never fires on listener.
ClientScrollableHitSource hitSource = new ClientScrollableHitSource(logger, buildTestBackoffPolicy(), threadPool, testTask.getWorkerState()::countSearchRetry, r -> fail(), ExceptionsHelper::reThrowIfNotNull, new ParentTaskAssigningClient(client, localNode, testTask), testRequest.getSearchRequest());
hitSource.setScroll(scrollId());
hitSource.startNextScroll(TimeValue.timeValueSeconds(0));
assertBusy(() -> assertEquals(client.scrollsToReject + 1, client.scrollAttempts.get()));
if (listener.isDone()) {
Object result = listener.get();
fail("Expected listener not to be done but it was and had " + result);
}
assertBusy(() -> assertNotNull("There should be a scroll attempt pending that we didn't reject", client.lastScroll.get()));
assertEquals(client.scrollsToReject, testTask.getStatus().getSearchRetries());
}
use of org.opensearch.client.ParentTaskAssigningClient 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());
}
use of org.opensearch.client.ParentTaskAssigningClient in project OpenSearch by opensearch-project.
the class TransportDeleteByQueryAction method doExecute.
@Override
public void doExecute(Task task, DeleteByQueryRequest request, ActionListener<BulkByScrollResponse> listener) {
BulkByScrollTask bulkByScrollTask = (BulkByScrollTask) task;
BulkByScrollParallelizationHelper.startSlicedAction(request, bulkByScrollTask, DeleteByQueryAction.INSTANCE, listener, client, clusterService.localNode(), () -> {
ParentTaskAssigningClient assigningClient = new ParentTaskAssigningClient(client, clusterService.localNode(), bulkByScrollTask);
new AsyncDeleteByQueryAction(bulkByScrollTask, logger, assigningClient, threadPool, request, scriptService, listener).start();
});
}
use of org.opensearch.client.ParentTaskAssigningClient in project OpenSearch by opensearch-project.
the class Reindexer method execute.
public void execute(BulkByScrollTask task, ReindexRequest request, ActionListener<BulkByScrollResponse> listener) {
ActionListener<BulkByScrollResponse> remoteReindexActionListener = getRemoteReindexWrapperListener(listener, request);
BulkByScrollParallelizationHelper.executeSlicedAction(task, request, ReindexAction.INSTANCE, listener, client, clusterService.localNode(), () -> {
ParentTaskAssigningClient assigningClient = new ParentTaskAssigningClient(client, clusterService.localNode(), task);
AsyncIndexBySearchAction searchAction = new AsyncIndexBySearchAction(task, logger, assigningClient, threadPool, scriptService, reindexSslConfig, request, remoteReindexActionListener, getInterceptor(request));
searchAction.start();
});
}
Aggregations