Package at.molindo.esi4j.action

Examples of at.molindo.esi4j.action.BulkResponseWrapper


        for (int i = 0; i < _tasks.length; i++) {
          _tasks[i].resolveEntity(entityResolver);
        }
      }

      BulkResponseWrapper response = executor.getTaskProcessor().getIndex()
          .executeBulk(new Esi4JOperation<ListenableActionFuture<BulkResponse>>() {

            @Override
            public ListenableActionFuture<BulkResponse> execute(Client client, String indexName,
                OperationContext helper) {
              BulkRequestBuilder bulk = client.prepareBulk();

              for (int i = 0; i < _tasks.length; i++) {
                _tasks[i].addToBulk(bulk, indexName, helper);
              }

              ListenableActionFuture<BulkResponse> response = bulk.execute();

              return response;
            }
          }).actionGet();

      int failed = 0;
      for (BulkItemResponse item : response.getBulkResponse()) {
        if (item.isFailed()) {
          failed++;
        }
      }

      if (failed > 0) {
        log.warn("failed to index " + failed + " items. index might be out of sync");
      }

      if (log.isDebugEnabled()) {
        int indexed = response.getBulkResponse().getItems().length - failed;
        log.debug("finished bulk indexing " + indexed + " items");
      }
    }
View Full Code Here


  @Override
  public void processTasks(final Esi4JEntityTask[] tasks) {
    _lock.readLock().lock();
    try {
      BulkResponseWrapper response = getIndex().executeBulk(
          new Esi4JOperation<ListenableActionFuture<BulkResponse>>() {

            @Override
            public ListenableActionFuture<BulkResponse> execute(Client client, String indexName,
                OperationContext helper) {
              BulkRequestBuilder bulk = client.prepareBulk();

              for (int i = 0; i < tasks.length; i++) {
                tasks[i].addToBulk(bulk, indexName, helper);
              }

              return bulk.execute();
            }
          }).actionGet();

      if (log.isDebugEnabled()) {
        log.debug("finished bulk indexing " + response.getBulkResponse().getItems().length + " items");
      }
    } finally {
      _lock.readLock().unlock();
    }
  }
View Full Code Here

TOP

Related Classes of at.molindo.esi4j.action.BulkResponseWrapper

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.