protected void executeBulkRequest(BulkRequestBuilder bulkRequest) { if (bulkRequest.numberOfActions() == 0) return; BulkResponse bulkResponse = bulkRequest.execute().actionGet(); if (!bulkResponse.hasFailures()) return; for (BulkItemResponse response : bulkResponse) { if (!response.isFailed()) continue; LOG.warning( String.format( "Unable to save Entity %s in %s/%s, cause: %s", response.getId(), response.getIndex(), response.getType(), response.getFailureMessage())); } }
@Override public void onResponse(BulkResponse response) { semaphore.release(); counter.addAndGet(response.getItems().length); for (BulkItemResponse item : response.getItems()) { if (item.isFailed()) { LOGGER.error( "index [{}], type [{}], id [{}], message [{}]", item.getIndex(), item.getType(), item.getId(), item.getFailureMessage()); } } }
/** * This method processes failures by iterating through each bulk response item * * @param response, a BulkResponse */ private void processBulkResponseFailure(BulkResponse response) { logger.warn("There was failures when executing bulk : " + response.buildFailureMessage()); if (!logger.isDebugEnabled()) return; for (BulkItemResponse item : response.getItems()) { if (item.isFailed()) { logger.debug( "Error {} occurred on index {}, type {}, id {} for {} operation ", item.getFailureMessage(), item.getIndex(), item.getType(), item.getId(), item.getOpType()); } } }