Package at.molindo.esi4j.rebuild.util

Examples of at.molindo.esi4j.rebuild.util.BulkIndexHelper


            new ElasticSearchDownloader(client, indexName, "_type:" + mapping.getTypeAlias(), factory),
            elasticSearchSorter, iteratorFactory, workingDirectory);

        long start = System.currentTimeMillis();

        BulkIndexHelper h = new BulkIndexHelper().setMaxRunning(2);
        h.setResponseHandler(new BulkIndexHelper.IResponseHandler() {

          @Override
          public void handle(String id, String type) {
            if ("delete".equals(type)) {
              onDelete(mapping.getTypeClass(), mapping.toId(id));
            } else if ("index".equals(type)) {
              onIndex(mapping.getTypeClass(), mapping.toId(id));
            } else if ("create".equals(type)) {
              onCreate(mapping.getTypeClass(), mapping.toId(id));
            } else {
              log.warn("unexpected operation type {}", type);
            }
          }
        });

        VerifierListener listener = new VerifierListener(client, indexName, context, mapping, h,
            DEFAULT_BATCH_SIZE);

        try {
          verify(moduleStream, esStream, listener);
        } finally {
          /*
           * TODO let IdAndVersionStreamVerifier do that as it does
           * with streams
           */
          listener.close();
        }

        try {
          h.await();

          long seconds = (System.currentTimeMillis() - start) / 1000;

          // logging
          StringBuilder logMsg = new StringBuilder("finished indexing of ").append(h.getSucceeded())
              .append(" objects of type ").append(rebuildSession.getType().getName()).append(" in ")
              .append(seconds).append(" seconds");

          if (h.getFailed() > 0) {
            logMsg.append(" (").append(h.getFailed()).append(" failed)");
            log.warn(logMsg.toString());
          } else {
            log.info(logMsg.toString());
          }

View Full Code Here


        ElasticSearchIdAndVersionStream esStream = new ElasticSearchIdAndVersionStream(
            new ElasticSearchDownloader(client, indexName, "_type:" + mapping.getTypeAlias(), factory),
            elasticSearchSorter, iteratorFactory, workingDirectory);

        BulkIndexHelper bulkHelper = new BulkIndexHelper().setMaxRunning(2);
        bulkHelper.setResponseHandler(new BulkIndexHelper.IResponseHandler() {

          @Override
          public void handle(String id, String type) {
            if ("delete".equals(type)) {
              onDelete(mapping.getTypeClass(), mapping.toId(id));
View Full Code Here

        ElasticSearchIdAndVersionStream esStream = new ElasticSearchIdAndVersionStream(
            new ElasticSearchDownloader(client, indexName, "_type:" + mapping.getTypeAlias(), factory),
            elasticSearchSorter, iteratorFactory, workingDirectory);

        BulkIndexHelper bulkHelper = new BulkIndexHelper().setMaxRunning(2);
        bulkHelper.setResponseHandler(new BulkIndexHelper.IResponseHandler() {

          @Override
          public void handle(String id, String type) {
            if ("delete".equals(type)) {
              onDelete(mapping.getTypeClass(), mapping.toId(id));
View Full Code Here

    index.updateMapping(type);

    try {

      BulkIndexHelper h = new BulkIndexHelper().setMaxRunning(getMaxRunning());

      List<?> list;
      while ((list = rebuildSession.getNext(_batchSize)).size() > 0) {
        h.bulkIndex(index, list);
      }

      h.await();

      long seconds = (System.currentTimeMillis() - start) / 1000;

      // logging
      StringBuilder logMsg = new StringBuilder("finished indexing of ").append(h.getSucceeded())
          .append(" objects of type ").append(type.getName()).append(" in ").append(seconds)
          .append(" seconds");

      if (h.getFailed() > 0) {
        logMsg.append(" (").append(h.getFailed()).append(" failed)");
        log.warn(logMsg.toString());
      } else {
        log.info(logMsg.toString());
      }
View Full Code Here

            new ElasticSearchDownloader(client, indexName, "_type:" + mapping.getTypeAlias(), factory),
            elasticSearchSorter, iteratorFactory, workingDirectory);

        long start = System.currentTimeMillis();

        BulkIndexHelper h = new BulkIndexHelper().setMaxRunning(2);
        h.setResponseHandler(new BulkIndexHelper.IResponseHandler() {

          @Override
          public void handle(String id, String type) {
            if ("delete".equals(type)) {
              onDelete(mapping.getTypeClass(), mapping.toId(id));
            } else {
              onIndex(mapping.getTypeClass(), mapping.toId(id));
            }
          }

        });

        VerifierListener listener = new VerifierListener(client, indexName, context, mapping, h,
            DEFAULT_BATCH_SIZE);

        try {
          verify(moduleStream, esStream, listener);
        } finally {
          /*
           * TODO let IdAndVersionStreamVerifier do that as it does
           * with streams
           */
          listener.close();
        }

        try {
          h.await();

          long seconds = (System.currentTimeMillis() - start) / 1000;

          // logging
          StringBuilder logMsg = new StringBuilder("finished indexing of ").append(h.getSucceeded())
              .append(" objects of type ").append(rebuildSession.getType().getName()).append(" in ")
              .append(seconds).append(" seconds");

          if (h.getFailed() > 0) {
            logMsg.append(" (").append(h.getFailed()).append(" failed)");
            log.warn(logMsg.toString());
          } else {
            log.info(logMsg.toString());
          }

View Full Code Here

TOP

Related Classes of at.molindo.esi4j.rebuild.util.BulkIndexHelper

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.