当前位置: 首页>>代码示例>>Java>>正文


Java BulkItemResponse.isFailed方法代码示例

本文整理汇总了Java中org.elasticsearch.action.bulk.BulkItemResponse.isFailed方法的典型用法代码示例。如果您正苦于以下问题:Java BulkItemResponse.isFailed方法的具体用法?Java BulkItemResponse.isFailed怎么用?Java BulkItemResponse.isFailed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.action.bulk.BulkItemResponse的用法示例。


在下文中一共展示了BulkItemResponse.isFailed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOKCount

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
@Override
public int getOKCount()
{
	if (_countOK == null)
	{
		int count = 0;
		for (final BulkItemResponse response : esResponse.getItems())
		{
			if (!response.isFailed())
			{
				count++;
			}
		}

		_countOK = count;
	}
	return _countOK;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:19,代码来源:ESIndexerResult.java

示例2: getFailuresCount

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
@Override
public int getFailuresCount()
{
	if (_countFailures == null)
	{
		int count = 0;
		for (final BulkItemResponse response : esResponse.getItems())
		{
			if (response.isFailed())
			{
				count++;
			}
		}
		
		_countFailures = count;
	}
	return _countFailures;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:19,代码来源:ESIndexerResult.java

示例3: writeToNoSQL

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
@Override
public void writeToNoSQL(List<Map<String, Object>> entityList) {
	JSONArray array = JSONArray.fromObject(entityList);
	for (int i = 0; i < array.size(); i++) {
		IndexRequestBuilder builder = client.prepareIndex(index_name, index_type);
		if (getPrimaryKey() != null)
			builder.setId( ((JSONObject)array.get(i)).getString(getPrimaryKey()));
		builder.setSource(array.get(i).toString());
		bulkRequest.add(builder);
	}
	if (bulkRequest.numberOfActions() > 0) {
		long  t1 = System.currentTimeMillis();
		ListenableActionFuture<BulkResponse>  action = bulkRequest.execute();
		long t2 = System.currentTimeMillis();
		BulkResponse response = action.actionGet();
	    for (Iterator<BulkItemResponse> iterator = response.iterator(); iterator.hasNext();) {
	      BulkItemResponse e = (BulkItemResponse) iterator.next();
	      if (e.isFailed()) 
	        throw new FailedCommunicationException("Insertion to ES failed.");
	    }
		log.info("Time taken to Write "+ bulkRequest.numberOfActions() + " documents to ES :" + ((t2-t1))  + " ms");
	}
}
 
开发者ID:msathis,项目名称:SQLToNoSQLImporter,代码行数:24,代码来源:ESWriter.java

示例4: executeBuilder

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
void executeBuilder(BulkRequestBuilder bulkRequestBuilder)
{
	if(bulkRequestBuilder.numberOfActions() == 0)
		return;
	
	++stats.flushes;
	BulkResponse response = bulkRequestBuilder.execute().actionGet();
	if (response.hasFailures()) {
              logger.warn("failed to execute" + response.buildFailureMessage());
          }
	
	for(BulkItemResponse resp : response){
		if(resp.isFailed()){
			stats.failed++;
		}else{
			stats.succeeded++;
		}
	}
}
 
开发者ID:endgameinc,项目名称:elasticsearch-river-kafka,代码行数:20,代码来源:KafkaRiver.java

示例5: afterBulk

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
@Override
public void afterBulk(long executionId, BulkRequest request,
        BulkResponse response) {
    bulksInProgress.decrementAndGet();
    if (response.hasFailures()) {
        for (BulkItemResponse item : response.getItems()) {
            if (item.isFailed()) {
                counts.failures++;
            } else {
                counts.successes++;
            }
        }
    } else {
        counts.successes += response.getItems().length;
    }
    checkRelease();
}
 
开发者ID:crate,项目名称:elasticsearch-inout-plugin,代码行数:18,代码来源:ImportBulkListener.java

示例6: executeESBulkRequest

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
@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());
		}
	}
}
 
开发者ID:searchisko,项目名称:elasticsearch-river-remote,代码行数:23,代码来源:RemoteRiver.java

示例7: doBulkRequest

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
protected void doBulkRequest(BulkRequest bulkRequest) {
    BulkResponse response = getClient().bulk(bulkRequest).actionGet();
    if (response.hasFailures()) {
        for (BulkItemResponse bulkResponse : response) {
            if (bulkResponse.isFailed()) {
                LOGGER.error("Failed to index %s (message: %s)", bulkResponse.getId(), bulkResponse.getFailureMessage());
            }
        }
        throw new MemgraphException("Could not add element.");
    }
}
 
开发者ID:mware-solutions,项目名称:memory-graph,代码行数:12,代码来源:Elasticsearch5SearchIndex.java

示例8: EsBulkResponseSummary

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
public EsBulkResponseSummary(List<BulkResponse> responses) {
  for (BulkResponse br : responses) {
    for (BulkItemResponse itemResponse : br.getItems()) {
      if (itemResponse.isFailed()) {
        failed.put(getItemId(itemResponse), itemResponse.getFailureMessage());
      } else {
        succeeded.put(getItemId(itemResponse), itemResponse.getOpType());
      }
    }
  }
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:12,代码来源:EsBulkResponseSummary.java

示例9: commit

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
@Override
public void commit() throws IOException {
  if (execute != null) {
    // wait for previous to finish
    long beforeWait = System.currentTimeMillis();
    BulkResponse actionGet = execute.actionGet();
    if (actionGet.hasFailures()) {
      for (BulkItemResponse item : actionGet) {
        if (item.isFailed()) {
          throw new RuntimeException("First failure in bulk: "
              + item.getFailureMessage());
        }
      }
    }
    long msWaited = System.currentTimeMillis() - beforeWait;
    LOG.info("Previous took in ms " + actionGet.getTookInMillis()
        + ", including wait " + msWaited);
    execute = null;
  }
  if (bulk != null) {
    if (bulkDocs > 0) {
      // start a flush, note that this is an asynchronous call
      execute = bulk.execute();
    }
    bulk = null;
  }
  if (createNewBulk) {
    // Prepare a new bulk request
    bulk = client.prepareBulk();
    bulkDocs = 0;
    bulkLength = 0;
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:34,代码来源:ElasticIndexWriter.java

示例10: extractFailureCauseFromBulkItemResponse

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
@Override
public Throwable extractFailureCauseFromBulkItemResponse(BulkItemResponse bulkItemResponse) {
	if (!bulkItemResponse.isFailed()) {
		return null;
	} else {
		return new RuntimeException(bulkItemResponse.getFailureMessage());
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:Elasticsearch1ApiCallBridge.java

示例11: extractFailureCauseFromBulkItemResponse

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
@Override
public Throwable extractFailureCauseFromBulkItemResponse(BulkItemResponse bulkItemResponse) {
	if (!bulkItemResponse.isFailed()) {
		return null;
	} else {
		return bulkItemResponse.getFailure().getCause();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:Elasticsearch2ApiCallBridge.java

示例12: extractFailureCauseFromBulkItemResponse

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
@Nullable
@Override
public Throwable extractFailureCauseFromBulkItemResponse(BulkItemResponse bulkItemResponse) {
	if (bulkItemResponse.isFailed()) {
		return new Exception(bulkItemResponse.getFailure().getMessage());
	} else {
		return null;
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:ElasticsearchSinkBaseTest.java

示例13: doBulkRequest

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
protected void doBulkRequest(BulkRequest bulkRequest) {
    BulkResponse response = getClient().bulk(bulkRequest).actionGet();
    if (response.hasFailures()) {
        for (BulkItemResponse bulkResponse : response) {
            if (bulkResponse.isFailed()) {
                LOGGER.error("Failed to index %s (message: %s)", bulkResponse.getId(), bulkResponse.getFailureMessage());
            }
        }
        throw new VertexiumException("Could not add element.");
    }
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:12,代码来源:Elasticsearch5SearchIndex.java

示例14: executeBulkRequest

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
protected void executeBulkRequest(BulkRequestBuilder bulkRequest) {
    BulkResponse bulkResponse = bulkRequest.execute().actionGet();

    getLog().info("Bulk request of batch size: " + bulkRequest.numberOfActions() + " took "
            + bulkResponse.getTookInMillis() + " ms in index builder: " + getName());

    for (BulkItemResponse response : bulkResponse.getItems()) {
        if (response.getResponse() instanceof DeleteResponse) {
            DeleteResponse deleteResponse = response.getResponse();

            if (response.isFailed()) {
                getLog().error("Problem deleting doc: " + response.getId() + " in index builder: " + getName()
                        + " error: " + response.getFailureMessage());
            } else if (!deleteResponse.isFound()) {
                getLog().debug("ES could not find a doc with id: " + deleteResponse.getId()
                        + " to delete in index builder: " + getName());
            } else {
                getLog().debug("ES deleted a doc with id: " + deleteResponse.getId() + " in index builder: "
                        + getName());
            }
        } else if (response.getResponse() instanceof IndexResponse) {
            IndexResponse indexResponse = response.getResponse();

            if (response.isFailed()) {
                getLog().error("Problem updating content for doc: " + response.getId() + " in index builder: "
                        + getName() + " error: " + response.getFailureMessage());
            } else {
                getLog().debug("ES indexed content for doc with id: " + indexResponse.getId()
                        + " in index builder: " + getName());
            }
        }
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:34,代码来源:BaseElasticSearchIndexBuilder.java

示例15: buildWriteReponse

import org.elasticsearch.action.bulk.BulkItemResponse; //导入方法依赖的package包/类
protected BulkWriterResponse buildWriteReponse(Iterable<Tuple> tuples, BulkResponse bulkResponse) throws Exception {
  // Elasticsearch responses are in the same order as the request, giving us an implicit mapping with Tuples
  BulkWriterResponse writerResponse = new BulkWriterResponse();
  if (bulkResponse.hasFailures()) {
    Iterator<BulkItemResponse> respIter = bulkResponse.iterator();
    Iterator<Tuple> tupleIter = tuples.iterator();
    while (respIter.hasNext() && tupleIter.hasNext()) {
      BulkItemResponse item = respIter.next();
      Tuple tuple = tupleIter.next();

      if (item.isFailed()) {
        writerResponse.addError(item.getFailure().getCause(), tuple);
      } else {
        writerResponse.addSuccess(tuple);
      }

      // Should never happen, so fail the entire batch if it does.
      if (respIter.hasNext() != tupleIter.hasNext()) {
        throw new Exception(bulkResponse.buildFailureMessage());
      }
    }
  } else {
    writerResponse.addAllSuccesses(tuples);
  }

  return writerResponse;
}
 
开发者ID:apache,项目名称:metron,代码行数:28,代码来源:ElasticsearchWriter.java


注:本文中的org.elasticsearch.action.bulk.BulkItemResponse.isFailed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。