• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BulkResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.searchbox.core.BulkResult的典型用法代码示例。如果您正苦于以下问题:Java BulkResult类的具体用法?Java BulkResult怎么用?Java BulkResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BulkResult类属于io.searchbox.core包,在下文中一共展示了BulkResult类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: accept

import io.searchbox.core.BulkResult; //导入依赖的package包/类
@Override
public void accept(HTTPBulkLoader.BulkReport report) {
  long tsNowMs = clock.currentTimeMillis();
  BulkResult result = report.bulkResult;
  if (!result.isSucceeded()) {
    if (result.getItems().size() == 0) {
      throw new SamzaException("Elasticsearch API error: " + result.getErrorMessage());
    }
    //Ignore version conflicts
    List<BulkResult.BulkResultItem> fatal = result.getFailedItems().stream().filter(item -> item.status != STATUS_CONFLICT).collect(Collectors.toList());
    if (fatal.size() > 0) {
      fatal.forEach(item -> logger.error(String.format("Error: index %s/%s, id %s, status %s, error %s",
          item.index, item.type, item.id, item.status, item.error)));
      throw new SamzaException(String.format("Elasticsearch bulk result contained %s errors", fatal.size()));
    }
  }
  logger.debug(String.format("Wrote %s actions to Elasticsearch system %s", result.getItems().size(), systemName));
  updateSuccessMetrics(report, tsNowMs);
}
 
开发者ID:quantiply,项目名称:rico,代码行数:20,代码来源:ElasticsearchSystemProducer.java


示例2: execute

import io.searchbox.core.BulkResult; //导入依赖的package包/类
@Override
public BulkResponse execute(Bulk bulk) throws IOException {
  final BulkResult result = client.execute(bulk);

  if (result.isSucceeded()) {
    return BulkResponse.success();
  }

  boolean retriable = true;

  final List<Key> versionConflicts = new ArrayList<>();
  final List<String> errors = new ArrayList<>();

  for (BulkResult.BulkResultItem item : result.getItems()) {
    if (item.error != null) {
      final ObjectNode parsedError = (ObjectNode) OBJECT_MAPPER.readTree(item.error);
      final String errorType = parsedError.get("type").asText("");
      if ("version_conflict_engine_exception".equals(errorType)) {
        versionConflicts.add(new Key(item.index, item.type, item.id));
      } else if ("mapper_parse_exception".equals(errorType)) {
        retriable = false;
        errors.add(item.error);
      } else {
        errors.add(item.error);
      }
    }
  }

  if (!versionConflicts.isEmpty()) {
    LOG.debug("Ignoring version conflicts for items: {}", versionConflicts);
    if (errors.isEmpty()) {
      // The only errors were version conflicts
      return BulkResponse.success();
    }
  }

  final String errorInfo = errors.isEmpty() ? result.getErrorMessage() : errors.toString();

  return BulkResponse.failure(retriable, errorInfo);
}
 
开发者ID:chaokunyang,项目名称:jkes,代码行数:41,代码来源:BulkDeletingClient.java


示例3: executeBulk

import io.searchbox.core.BulkResult; //导入依赖的package包/类
public int executeBulk(Bulk bulk) throws CouldNotCompleteBulkOperationException {
    try {

        BulkResult result = client.execute(bulk);
        return result.getFailedItems().size();

    } catch (IOException e) {
        throw new CouldNotCompleteBulkOperationException(e);
    }
}
 
开发者ID:logzio,项目名称:elasticsearch-benchmark-tool,代码行数:11,代码来源:ElasticsearchController.java


示例4: testMetrics

import io.searchbox.core.BulkResult; //导入依赖的package包/类
@Test
public void testMetrics() throws Exception {
  long esWaitMs = 200;
  long receivedMs = 100;
  long eventTsMs = 50;
  long tsNow = 300;
  List<HTTPBulkLoader.SourcedActionRequest> requests = new ArrayList<>();
  requests.add(getIndexRequest(100, 50));
  requests.add(getIndexRequest(100, 50));
  requests.add(getIndexRequest(100, 50));
  requests.add(getIndexRequest(100, 50));
  requests.add(getIndexRequest(100, 50));

  List<BulkResult.BulkResultItem> items = new ArrayList<>();
  items.add(getItemIndexInsert());
  items.add(getItemIndexUpdate());
  items.add(getItemIndexConflict());
  items.add(getItemUpdate());
  items.add(getItemDelete());

  BulkResult bulkResult = mock(BulkResult.class);
  when(bulkResult.getItems()).thenReturn(items);
  HTTPBulkLoader.BulkReport report = new HTTPBulkLoader.BulkReport(bulkResult, HTTPBulkLoader.TriggerType.MAX_ACTIONS, esWaitMs, requests);

  when(flushListener.clock.currentTimeMillis()).thenReturn(tsNow);
  flushListener.accept(report);
  assertEquals(1, metrics.bulkSendSuccess.getCount());
  assertEquals(5.0, metrics.bulkSendBatchSize.getSnapshot().getMean(), 0.0001);
  assertEquals(esWaitMs, metrics.bulkSendWaitMs.getSnapshot().getMean(), 0.0001);
  assertEquals(1, metrics.inserts.getCount());
  assertEquals(2, metrics.updates.getCount());
  assertEquals(1, metrics.conflicts.getCount());
  assertEquals(1, metrics.deletes.getCount());
  assertEquals(0, metrics.triggerFlushCmd.getCount());
  assertEquals(1, metrics.triggerMaxActions.getCount());
  assertEquals(0, metrics.triggerMaxInterval.getCount());
  assertEquals(tsNow - eventTsMs, metrics.lagFromOriginMs.getSnapshot().getMean(), 0.0001);
  assertEquals(tsNow - receivedMs, metrics.lagFromReceiveMs.getSnapshot().getMean(), 0.0001);
}
 
开发者ID:quantiply,项目名称:rico,代码行数:40,代码来源:ElasticsearchSystemProducerTest.java


示例5: processQueue

import io.searchbox.core.BulkResult; //导入依赖的package包/类
/**
  * Process the next item in the queue.
  */
 protected void processQueue() {
     try {
         Collection<RequestMetric> batch = new ArrayList<>(this.batchSize);
         RequestMetric rm = queue.take();
         batch.add(rm);
queue.drainTo(batch, this.batchSize - 1);

Builder builder = new Bulk.Builder();
for (RequestMetric metric : batch) {
          Index index = new Index.Builder(metric).refresh(false)
                  .index(getIndexName())
                  .type("request").build(); //$NON-NLS-1$
	builder.addAction(index);
}
         
         BulkResult result = getClient().execute(builder.build());
         if (!result.isSucceeded()) {
             System.err.println("Failed to add metric(s) to ES: " + result.getErrorMessage()); //$NON-NLS-1$
         }
     } catch (Exception e) {
         // TODO better logging of this unlikely error
         System.err.println("Error adding metric to ES:"); //$NON-NLS-1$
         e.printStackTrace();
         return;
     }
 }
 
开发者ID:apiman,项目名称:apiman,代码行数:30,代码来源:ESMetrics.java


示例6: updateSuccessMetrics

import io.searchbox.core.BulkResult; //导入依赖的package包/类
protected void updateSuccessMetrics(HTTPBulkLoader.BulkReport report, long tsNowMs) {
  metrics.bulkSendSuccess.inc();
  metrics.bulkSendBatchSize.update(report.requests.size());
  metrics.bulkSendWaitMs.update(report.esWaitMs);
  switch (report.triggerType) {
    case MAX_ACTIONS:
      metrics.triggerMaxActions.inc();
      break;
    case MAX_INTERVAL:
      metrics.triggerMaxInterval.inc();
      break;
    case FLUSH_CMD:
      metrics.triggerFlushCmd.inc();
      break;
  }

  int i = 0;
  for (Iterator<BulkResult.BulkResultItem> it = report.bulkResult.getItems().iterator(); it.hasNext(); i++) {
    BulkResult.BulkResultItem item = it.next();
    if (item.status == STATUS_CONFLICT) {
      metrics.conflicts.inc();
    }
    else {
      switch (item.operation) {
        case "index":
          if (item.status == STATUS_INDEX_DOC_INSERTED) {
            metrics.inserts.inc();
          }
          else {
            metrics.updates.inc();
          }
          break;
        case "create":
          metrics.inserts.inc();
          break;
        case "update":
          metrics.updates.inc();
          break;
        case "delete":
          metrics.deletes.inc();
      }
    }
    metrics.lagFromReceiveMs.update(tsNowMs - report.requests.get(i).request.receivedTsMs);
    Long eventTsMs = report.requests.get(i).request.key.getEventTsUnixMs();
    if (eventTsMs != null) {
      metrics.lagFromOriginMs.update(tsNowMs - eventTsMs);
    }
  }
}
 
开发者ID:quantiply,项目名称:rico,代码行数:50,代码来源:ElasticsearchSystemProducer.java


示例7: getItemIndexInsert

import io.searchbox.core.BulkResult; //导入依赖的package包/类
private BulkResult.BulkResultItem getItemIndexInsert() {
  return new BulkResult(new Gson()).new BulkResultItem("index", "test", "test", "test", 201, "");
}
 
开发者ID:quantiply,项目名称:rico,代码行数:4,代码来源:ElasticsearchSystemProducerTest.java


示例8: getItemIndexUpdate

import io.searchbox.core.BulkResult; //导入依赖的package包/类
private BulkResult.BulkResultItem getItemIndexUpdate() {
  return new BulkResult(new Gson()).new BulkResultItem("index", "test", "test", "test", 200, "");
}
 
开发者ID:quantiply,项目名称:rico,代码行数:4,代码来源:ElasticsearchSystemProducerTest.java


示例9: getItemIndexConflict

import io.searchbox.core.BulkResult; //导入依赖的package包/类
private BulkResult.BulkResultItem getItemIndexConflict() {
  return new BulkResult(new Gson()).new BulkResultItem("index", "test", "test", "test", 409, "");
}
 
开发者ID:quantiply,项目名称:rico,代码行数:4,代码来源:ElasticsearchSystemProducerTest.java


示例10: getItemUpdate

import io.searchbox.core.BulkResult; //导入依赖的package包/类
private BulkResult.BulkResultItem getItemUpdate() {
  return new BulkResult(new Gson()).new BulkResultItem("update", "test", "test", "test", 200, "");
}
 
开发者ID:quantiply,项目名称:rico,代码行数:4,代码来源:ElasticsearchSystemProducerTest.java


示例11: getItemDelete

import io.searchbox.core.BulkResult; //导入依赖的package包/类
private BulkResult.BulkResultItem getItemDelete() {
  return new BulkResult(new Gson()).new BulkResultItem("delete", "test", "test", "test", 200, "");
}
 
开发者ID:quantiply,项目名称:rico,代码行数:4,代码来源:ElasticsearchSystemProducerTest.java



注:本文中的io.searchbox.core.BulkResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XYBoxAnnotation类代码示例发布时间:2022-05-22
下一篇:
Java WxMpXmlMessage类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap