Package org.elasticsearch.action.bulk

Examples of org.elasticsearch.action.bulk.BulkResponse


          sinkCounter.incrementBatchCompleteCount();
        }

        sinkCounter.addToEventDrainAttemptCount(size);

        BulkResponse bulkResponse = bulkRequest.execute().actionGet();
        if (bulkResponse.hasFailures()) {
          throw new EventDeliveryException(bulkResponse.buildFailureMessage());
        }
      }
      txn.commit();
      sinkCounter.addToEventDrainSuccessCount(size);
      counterGroup.incrementAndGet("transaction.success");
View Full Code Here


  }

  @Override
  public void execute() throws Exception {
    try {
      BulkResponse bulkResponse = bulkRequestBuilder.execute().actionGet();
      if (bulkResponse.hasFailures()) {
        throw new EventDeliveryException(bulkResponse.buildFailureMessage());
      }
    } finally {
      bulkRequestBuilder = client.prepareBulk();
    }
  }
View Full Code Here

  @Test
  public void shouldExecuteBulkRequestBuilder() throws Exception {
    ListenableActionFuture<BulkResponse> action =
        (ListenableActionFuture<BulkResponse>) mock(ListenableActionFuture.class);
    BulkResponse response = mock(BulkResponse.class);
    when(bulkRequestBuilder.execute()).thenReturn(action);
    when(action.actionGet()).thenReturn(response);
    when(response.hasFailures()).thenReturn(false);

    fixture.addEvent(event, nameBuilder, "bar_type", 10);
    fixture.execute();
    verify(bulkRequestBuilder).execute();
  }
View Full Code Here

  @Test(expected = EventDeliveryException.class)
  public void shouldThrowExceptionOnExecuteFailed() throws Exception {
    ListenableActionFuture<BulkResponse> action =
        (ListenableActionFuture<BulkResponse>) mock(ListenableActionFuture.class);
    BulkResponse response = mock(BulkResponse.class);
    when(bulkRequestBuilder.execute()).thenReturn(action);
    when(action.actionGet()).thenReturn(response);
    when(response.hasFailures()).thenReturn(true);

    fixture.addEvent(event, nameBuilder, "bar_type", 10);
    fixture.execute();
  }
View Full Code Here

    private void processBulk(BulkRequestBuilder bulk, boolean fix) {
        if (fix) {
            if (bulk.numberOfActions() > 0) {
                LOG.info("Executing {} bulk actions", bulk.numberOfActions());
                final BulkResponse bulkResponse = bulk.execute().actionGet();

                if (bulkResponse.hasFailures()) {
                    LOG.error("BULK ERROR {}", bulkResponse.buildFailureMessage());
                } else {
                    LOG.info("Bulk action took {}ms", bulkResponse.getTookInMillis());
                }
            } else {
                LOG.debug("No bulk actions to execute!");
            }
        }
View Full Code Here

        }

        request.setConsistencyLevel(WriteConsistencyLevel.ONE);
        request.setReplicationType(ReplicationType.ASYNC);

        final BulkResponse response = c.bulk(request.request()).actionGet();

        log.debug("Deflector index: Bulk indexed {} messages, took {} ms, failures: {}",
                  response.getItems().length, response.getTookInMillis(), response.hasFailures());

        if (response.hasFailures()) {
            propagateFailure(response.getItems(), messages, response.buildFailureMessage());
        }

        return !response.hasFailures();
    }
View Full Code Here

            request.setConsistencyLevel(WriteConsistencyLevel.ONE);
            request.setReplicationType(ReplicationType.ASYNC);

            if (request.numberOfActions() > 0) {
                BulkResponse response = c.bulk(request.request()).actionGet();

                LOG.info("Moving index <{}> to <{}>: Bulk indexed {} messages, took {} ms, failures: {}",
                        source, target, response.getItems().length, response.getTookInMillis(), response.hasFailures());

                if (response.hasFailures()) {
                    throw new RuntimeException("Failed to move a message. Check your indexer log.");
                }
            }
        }
View Full Code Here

            }
            bulkRequest.add(prepareIndex);
        }

        ListenableActionFuture<BulkResponse> future = bulkRequest.execute();
        BulkResponse bulkResponse = future.actionGet();

        List<String> indexedIds = new LinkedList<String>();
        for (BulkItemResponse response : bulkResponse.getItems()) {
            indexedIds.add(response.getId());
        }
        log.debug("List of successfully indexed document ids : {}", indexedIds);
        exchange.getIn().setBody(indexedIds);
    }
View Full Code Here

  }

  @Override
  public void executeESBulkRequest(BulkRequestBuilder esBulk) throws ElasticsearchException,
      BulkUpdatePartialFailureException {
    BulkResponse response = esBulk.execute().actionGet();
    if (response.hasFailures()) {
      boolean containsSuccess = false;
      int numOfFailures = 0;
      for (BulkItemResponse bir : response.getItems()) {
        if (!bir.isFailed()) {
          containsSuccess = true;
        } else {
          numOfFailures++;
        }
      }
      if (containsSuccess) {
        throw new BulkUpdatePartialFailureException(response.buildFailureMessage(), numOfFailures);
      } else {
        throw new ElasticsearchException("Failed to completely execute ES index bulk update for " + numOfFailures
            + " commands: " + response.buildFailureMessage());
      }
    }
  }
View Full Code Here

    return client.prepareBulk();
  }

  @Override
  public void executeESBulkRequest(BulkRequestBuilder esBulk) throws Exception {
    BulkResponse response = esBulk.execute().actionGet();
    if (response.hasFailures()) {
      throw new ElasticsearchException("Failed to execute ES index bulk update: " + response.buildFailureMessage());
    }
  }
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.bulk.BulkResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.