/** * Invokes #accept(BulkRequest, ActionListener). Backs off on the provided exception and delegates results to the * provided listener. Retries will be scheduled using the class's thread pool. * @param consumer The consumer to which apply the request and listener * @param bulkRequest The bulk request that should be executed. * @param listener A listener that is invoked when the bulk request finishes or completes with an exception. The listener is not * @param settings settings * @deprecated Prefer {@link #withBackoff(BiConsumer, BulkRequest, ActionListener)}. The {@link Settings} isn't used. */ @Deprecated public void withBackoff(BiConsumer<BulkRequest, ActionListener<BulkResponse>> consumer, BulkRequest bulkRequest, ActionListener<BulkResponse> listener, Settings settings) { withBackoff(consumer, bulkRequest, listener); }
/** * Invokes #accept(BulkRequest, ActionListener). Backs off on the provided exception. Retries will be scheduled using * the class's thread pool. * * @param consumer The consumer to which apply the request and listener * @param bulkRequest The bulk request that should be executed. * @param settings settings * @return a future representing the bulk response returned by the client. * @deprecated prefer {@link #withBackoff(BiConsumer, BulkRequest)}. The {@link Settings} isn't used. */ @Deprecated public PlainActionFuture<BulkResponse> withBackoff(BiConsumer<BulkRequest, ActionListener<BulkResponse>> consumer, BulkRequest bulkRequest, Settings settings) { return withBackoff(consumer, bulkRequest); }
/** * Invokes #accept(BulkRequest, ActionListener). Backs off on the provided exception. Retries will be scheduled using * the class's thread pool. * * @param consumer The consumer to which apply the request and listener * @param bulkRequest The bulk request that should be executed. * @return a future representing the bulk response returned by the client. */ public PlainActionFuture<BulkResponse> withBackoff(BiConsumer<BulkRequest, ActionListener<BulkResponse>> consumer, BulkRequest bulkRequest) { PlainActionFuture<BulkResponse> future = PlainActionFuture.newFuture(); withBackoff(consumer, bulkRequest, future); return future; }
toRelease = semaphore::release; CountDownLatch latch = new CountDownLatch(1); retry.withBackoff(consumer, bulkRequest, new ActionListener<BulkResponse>() { @Override public void onResponse(BulkResponse response) {
/** * Invokes #accept(BulkRequest, ActionListener). Backs off on the provided exception and delegates results to the * provided listener. Retries will be scheduled using the class's thread pool. * @param consumer The consumer to which apply the request and listener * @param bulkRequest The bulk request that should be executed. * @param listener A listener that is invoked when the bulk request finishes or completes with an exception. The listener is not * @param settings settings * @deprecated Prefer {@link #withBackoff(BiConsumer, BulkRequest, ActionListener)}. The {@link Settings} isn't used. */ @Deprecated public void withBackoff(BiConsumer<BulkRequest, ActionListener<BulkResponse>> consumer, BulkRequest bulkRequest, ActionListener<BulkResponse> listener, Settings settings) { withBackoff(consumer, bulkRequest, listener); }
/** * Invokes #accept(BulkRequest, ActionListener). Backs off on the provided exception. Retries will be scheduled using * the class's thread pool. * * @param consumer The consumer to which apply the request and listener * @param bulkRequest The bulk request that should be executed. * @param settings settings * @return a future representing the bulk response returned by the client. * @deprecated prefer {@link #withBackoff(BiConsumer, BulkRequest)}. The {@link Settings} isn't used. */ @Deprecated public PlainActionFuture<BulkResponse> withBackoff(BiConsumer<BulkRequest, ActionListener<BulkResponse>> consumer, BulkRequest bulkRequest, Settings settings) { return withBackoff(consumer, bulkRequest); }
/** * Invokes #accept(BulkRequest, ActionListener). Backs off on the provided exception. Retries will be scheduled using * the class's thread pool. * * @param consumer The consumer to which apply the request and listener * @param bulkRequest The bulk request that should be executed. * @param settings settings * @return a future representing the bulk response returned by the client. */ public PlainActionFuture<BulkResponse> withBackoff(BiConsumer<BulkRequest, ActionListener<BulkResponse>> consumer, BulkRequest bulkRequest, Settings settings) { PlainActionFuture<BulkResponse> future = PlainActionFuture.newFuture(); withBackoff(consumer, bulkRequest, future, settings); return future; }
/** * Invokes #accept(BulkRequest, ActionListener). Backs off on the provided exception. Retries will be scheduled using * the class's thread pool. * * @param consumer The consumer to which apply the request and listener * @param bulkRequest The bulk request that should be executed. * @return a future representing the bulk response returned by the client. */ public PlainActionFuture<BulkResponse> withBackoff(BiConsumer<BulkRequest, ActionListener<BulkResponse>> consumer, BulkRequest bulkRequest) { PlainActionFuture<BulkResponse> future = PlainActionFuture.newFuture(); withBackoff(consumer, bulkRequest, future); return future; }
toRelease = semaphore::release; CountDownLatch latch = new CountDownLatch(1); retry.withBackoff(consumer, bulkRequest, new ActionListener<BulkResponse>() { @Override public void onResponse(BulkResponse response) {
toRelease = semaphore::release; CountDownLatch latch = new CountDownLatch(1); retry.withBackoff(consumer, bulkRequest, new ActionListener<BulkResponse>() { @Override public void onResponse(BulkResponse response) {
/** * Send a bulk request, handling retries. */ void sendBulkRequest(TimeValue thisBatchStartTime, BulkRequest request) { if (logger.isDebugEnabled()) { logger.debug("[{}]: sending [{}] entry, [{}] bulk request", task.getId(), request.requests().size(), new ByteSizeValue(request.estimatedSizeInBytes())); } if (task.isCancelled()) { logger.debug("[{}]: finishing early because the task was cancelled", task.getId()); finishHim(null); return; } bulkRetry.withBackoff(client::bulk, request, new ActionListener<BulkResponse>() { @Override public void onResponse(BulkResponse response) { onBulkResponse(thisBatchStartTime, response); } @Override public void onFailure(Exception e) { finishHim(e); } }); }