當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。