public AbstractAsyncBulkByScrollAction(BulkByScrollTask task, ESLogger logger, Client client, ThreadPool threadPool, Version smallestNonClientVersion, Request mainRequest, SearchRequest firstSearchRequest, ActionListener<Response> listener) { if (smallestNonClientVersion.before(Version.V_2_3_0)) { throw new IllegalStateException( "Refusing to execute [" + mainRequest + "] because the entire cluster has not been upgraded to 2.3"); } this.task = task; this.logger = logger; this.client = client; this.threadPool = threadPool; this.mainRequest = mainRequest; this.firstSearchRequest = firstSearchRequest; this.listener = listener; retry = Retry.on(EsRejectedExecutionException.class).policy(wrapBackoffPolicy(backoffPolicy())); mainRequest.applyDefaults(); }
public AbstractAsyncBulkByScrollAction(BulkByScrollTask task, ESLogger logger, Client client, ThreadPool threadPool, Version smallestNonClientVersion, Request mainRequest, SearchRequest firstSearchRequest, ActionListener<Response> listener) { if (smallestNonClientVersion.before(Version.V_2_3_0)) { throw new IllegalStateException( "Refusing to execute [" + mainRequest + "] because the entire cluster has not been upgraded to 2.3"); } this.task = task; this.logger = logger; this.client = client; this.threadPool = threadPool; this.mainRequest = mainRequest; this.firstSearchRequest = firstSearchRequest; this.listener = listener; retry = Retry.on(EsRejectedExecutionException.class).policy(wrapBackoffPolicy(backoffPolicy())); mainRequest.applyDefaults(); }
acquired = true; Retry.on(EsRejectedExecutionException.class) .policy(backoffPolicy) .withAsyncBackoff(client, bulkRequest, new ActionListener<BulkResponse>() { @Override
@Override public void execute(BulkRequest bulkRequest, long executionId) { boolean afterCalled = false; try { listener.beforeBulk(executionId, bulkRequest); BulkResponse bulkResponse = Retry .on(EsRejectedExecutionException.class) .policy(backoffPolicy) .withSyncBackoff(client, bulkRequest); afterCalled = true; listener.afterBulk(executionId, bulkRequest, bulkResponse); } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.info((Supplier<?>) () -> new ParameterizedMessage("Bulk request {} has been cancelled.", executionId), e); if (!afterCalled) { listener.afterBulk(executionId, bulkRequest, e); } } catch (Exception e) { logger.warn((Supplier<?>) () -> new ParameterizedMessage("Failed to execute bulk request {}.", executionId), e); if (!afterCalled) { listener.afterBulk(executionId, bulkRequest, e); } } }
acquired = true; Retry.on(EsRejectedExecutionException.class) .policy(backoffPolicy) .withAsyncBackoff(client, bulkRequest, new ActionListener<BulkResponse>() { @Override
@Override public void execute(BulkRequest bulkRequest, long executionId) { boolean afterCalled = false; try { listener.beforeBulk(executionId, bulkRequest); BulkResponse bulkResponse = Retry .on(EsRejectedExecutionException.class) .policy(backoffPolicy) .withSyncBackoff(client, bulkRequest); afterCalled = true; listener.afterBulk(executionId, bulkRequest, bulkResponse); } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.info("Bulk request {} has been cancelled.", e, executionId); if (!afterCalled) { listener.afterBulk(executionId, bulkRequest, e); } } catch (Throwable t) { logger.warn("Failed to execute bulk request {}.", t, executionId); if (!afterCalled) { listener.afterBulk(executionId, bulkRequest, t); } } }