本文整理汇总了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;
}
示例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;
}
示例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");
}
}
示例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++;
}
}
}
示例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();
}
示例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());
}
}
}
示例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.");
}
}
示例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());
}
}
}
}
示例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;
}
}
示例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());
}
}
示例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();
}
}
示例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;
}
}
示例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.");
}
}
示例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());
}
}
}
}
示例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;
}