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


Java ShardOperationFailedException类代码示例

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


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

示例1: buildBroadcastShardsHeader

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
public static void buildBroadcastShardsHeader(XContentBuilder builder, Params params,
                                              int total, int successful, int failed,
                                              ShardOperationFailedException[] shardFailures) throws IOException {
    builder.startObject("_shards");
    builder.field("total", total);
    builder.field("successful", successful);
    builder.field("failed", failed);
    if (shardFailures != null && shardFailures.length > 0) {
        builder.startArray("failures");
        final boolean group = params.paramAsBoolean("group_shard_failures", true); // we group by default
        for (ShardOperationFailedException shardFailure : group ? ExceptionsHelper.groupBy(shardFailures) : shardFailures) {
            builder.startObject();
            shardFailure.toXContent(builder, params);
            builder.endObject();
        }
        builder.endArray();
    }
    builder.endObject();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:RestActions.java

示例2: writeTo

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeVInt(storeStatuses.size());
    for (ObjectObjectCursor<String, ImmutableOpenIntMap<List<StoreStatus>>> indexShards : storeStatuses) {
        out.writeString(indexShards.key);
        out.writeVInt(indexShards.value.size());
        for (IntObjectCursor<List<StoreStatus>> shardStatusesEntry : indexShards.value) {
            out.writeInt(shardStatusesEntry.key);
            out.writeVInt(shardStatusesEntry.value.size());
            for (StoreStatus storeStatus : shardStatusesEntry.value) {
                storeStatus.writeTo(out);
            }
        }
    }
    out.writeVInt(failures.size());
    for (ShardOperationFailedException failure : failures) {
        failure.writeTo(out);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:IndicesShardStoresResponse.java

示例3: newResponse

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
@Override
protected RecoveryResponse newResponse(RecoveryRequest request, int totalShards, int successfulShards, int failedShards, List<RecoveryState> responses, List<ShardOperationFailedException> shardFailures, ClusterState clusterState) {
    Map<String, List<RecoveryState>> shardResponses = new HashMap<>();
    for (RecoveryState recoveryState : responses) {
        if (recoveryState == null) {
            continue;
        }
        String indexName = recoveryState.getShardId().getIndexName();
        if (!shardResponses.containsKey(indexName)) {
            shardResponses.put(indexName, new ArrayList<>());
        }
        if (request.activeOnly()) {
            if (recoveryState.getStage() != RecoveryState.Stage.DONE) {
                shardResponses.get(indexName).add(recoveryState);
            }
        } else {
            shardResponses.get(indexName).add(recoveryState);
        }
    }
    return new RecoveryResponse(totalShards, successfulShards, failedShards, request.detailed(), shardResponses, shardFailures);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:TransportRecoveryAction.java

示例4: executeNextPhase

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
@Override
public final void executeNextPhase(SearchPhase currentPhase, SearchPhase nextPhase) {
    /* This is the main search phase transition where we move to the next phase. At this point we check if there is
     * at least one successful operation left and if so we move to the next phase. If not we immediately fail the
     * search phase as "all shards failed"*/
    if (successfulOps.get() == 0) { // we have 0 successful results that means we shortcut stuff and return a failure
        if (logger.isDebugEnabled()) {
            final ShardOperationFailedException[] shardSearchFailures = ExceptionsHelper.groupBy(buildShardFailures());
            Throwable cause = ElasticsearchException.guessRootCauses(shardSearchFailures[0].getCause())[0];
            logger.debug((Supplier<?>) () -> new ParameterizedMessage("All shards failed for phase: [{}]", getName()),
                cause);
        }
        onPhaseFailure(currentPhase, "all shards failed", null);
    } else {
        if (logger.isTraceEnabled()) {
            final String resultsFrom = results.getSuccessfulResults()
                .map(r -> r.shardTarget().toString()).collect(Collectors.joining(","));
            logger.trace("[{}] Moving to next phase: [{}], based on results from: {} (cluster state version: {})",
                currentPhase.getName(), nextPhase.getName(), resultsFrom, clusterStateVersion);
        }
        executePhase(nextPhase);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:AbstractSearchAsyncAction.java

示例5: metadataToXContent

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
@Override
protected void metadataToXContent(XContentBuilder builder, Params params) throws IOException {
    builder.field("phase", phaseName);
    final boolean group = params.paramAsBoolean("group_shard_failures", true); // we group by default
    builder.field("grouped", group); // notify that it's grouped
    builder.field("failed_shards");
    builder.startArray();
    ShardOperationFailedException[] failures = params.paramAsBoolean("group_shard_failures", true) ?
            ExceptionsHelper.groupBy(shardFailures) : shardFailures;
    for (ShardOperationFailedException failure : failures) {
        builder.startObject();
        failure.toXContent(builder, params);
        builder.endObject();
    }
    builder.endArray();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:SearchPhaseExecutionException.java

示例6: finishAndNotifyListener

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
private void finishAndNotifyListener(ActionListener listener, CopyOnWriteArrayList<ShardResponse> shardsResponses) {
    logger.trace("{}: got all shard responses", actionName);
    int successfulShards = 0;
    int failedShards = 0;
    int totalNumCopies = 0;
    List<ShardOperationFailedException> shardFailures = null;
    for (int i = 0; i < shardsResponses.size(); i++) {
        ReplicationResponse shardResponse = shardsResponses.get(i);
        if (shardResponse == null) {
            // non active shard, ignore
        } else {
            failedShards += shardResponse.getShardInfo().getFailed();
            successfulShards += shardResponse.getShardInfo().getSuccessful();
            totalNumCopies += shardResponse.getShardInfo().getTotal();
            if (shardFailures == null) {
                shardFailures = new ArrayList<>();
            }
            for (ReplicationResponse.ShardInfo.Failure failure : shardResponse.getShardInfo().getFailures()) {
                shardFailures.add(new DefaultShardOperationFailedException(new BroadcastShardOperationFailedException(failure.fullShardId(), failure.getCause())));
            }
        }
    }
    listener.onResponse(newResponse(successfulShards, failedShards, totalNumCopies, shardFailures));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:TransportBroadcastReplicationAction.java

示例7: buildBroadcastShardsHeader

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
public static void buildBroadcastShardsHeader(XContentBuilder builder, ToXContent.Params params, int total, int successful, int failed, ShardOperationFailedException[] shardFailures) throws IOException {
    builder.startObject(Fields._SHARDS);
    builder.field(Fields.TOTAL, total);
    builder.field(Fields.SUCCESSFUL, successful);
    builder.field(Fields.FAILED, failed);
    if (shardFailures != null && shardFailures.length > 0) {
        builder.startArray(Fields.FAILURES);
        final boolean group = params.paramAsBoolean("group_shard_failures", true); // we group by default
        for (ShardOperationFailedException shardFailure : group ? ExceptionsHelper.groupBy(shardFailures) : shardFailures) {
            builder.startObject();
            shardFailure.toXContent(builder, params);
            builder.endObject();
        }
        builder.endArray();
    }
    builder.endObject();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:RestActions.java

示例8: newResponse

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
@Override
protected RecoveryResponse newResponse(RecoveryRequest request, int totalShards, int successfulShards, int failedShards, List<RecoveryState> responses, List<ShardOperationFailedException> shardFailures, ClusterState clusterState) {
    Map<String, List<RecoveryState>> shardResponses = Maps.newHashMap();
    for (RecoveryState recoveryState : responses) {
        if (recoveryState == null) {
            continue;
        }
        String indexName = recoveryState.getShardId().getIndex();
        if (!shardResponses.containsKey(indexName)) {
            shardResponses.put(indexName, new ArrayList<RecoveryState>());
        }
        if (request.activeOnly()) {
            if (recoveryState.getStage() != RecoveryState.Stage.DONE) {
                shardResponses.get(indexName).add(recoveryState);
            }
        } else {
            shardResponses.get(indexName).add(recoveryState);
        }
    }
    return new RecoveryResponse(totalShards, successfulShards, failedShards, request.detailed(), shardResponses, shardFailures);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:TransportRecoveryAction.java

示例9: innerToXContent

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
@Override
protected void innerToXContent(XContentBuilder builder, Params params) throws IOException {
    builder.field("phase", phaseName);
    final boolean group = params.paramAsBoolean("group_shard_failures", true); // we group by default
    builder.field("grouped", group); // notify that it's grouped
    builder.field("failed_shards");
    builder.startArray();
    ShardOperationFailedException[] failures = params.paramAsBoolean("group_shard_failures", true) ? ExceptionsHelper.groupBy(shardFailures) : shardFailures;
    for (ShardOperationFailedException failure : failures) {
        builder.startObject();
        failure.toXContent(builder, params);
        builder.endObject();
    }
    builder.endArray();
    super.innerToXContent(builder, params);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:SearchPhaseExecutionException.java

示例10: finishAndNotifyListener

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
private void finishAndNotifyListener(ActionListener listener, CopyOnWriteArrayList<ShardResponse> shardsResponses) {
    logger.trace("{}: got all shard responses", actionName);
    int successfulShards = 0;
    int failedShards = 0;
    int totalNumCopies = 0;
    List<ShardOperationFailedException> shardFailures = null;
    for (int i = 0; i < shardsResponses.size(); i++) {
        ActionWriteResponse shardResponse = shardsResponses.get(i);
        if (shardResponse == null) {
            // non active shard, ignore
        } else {
            failedShards += shardResponse.getShardInfo().getFailed();
            successfulShards += shardResponse.getShardInfo().getSuccessful();
            totalNumCopies += shardResponse.getShardInfo().getTotal();
            if (shardFailures == null) {
                shardFailures = new ArrayList<>();
            }
            for (ActionWriteResponse.ShardInfo.Failure failure : shardResponse.getShardInfo().getFailures()) {
                shardFailures.add(new DefaultShardOperationFailedException(new BroadcastShardOperationFailedException(new ShardId(failure.index(), failure.shardId()), failure.getCause())));
            }
        }
    }
    listener.onResponse(newResponse(successfulShards, failedShards, totalNumCopies, shardFailures));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:TransportBroadcastReplicationAction.java

示例11: newResponse

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
@Override
protected DfsOnlyResponse newResponse(DfsOnlyRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
    int successfulShards = 0;
    int failedShards = 0;
    List<ShardOperationFailedException> shardFailures = null;
    AtomicArray<DfsSearchResult> dfsResults = new AtomicArray<>(shardsResponses.length());
    for (int i = 0; i < shardsResponses.length(); i++) {
        Object shardResponse = shardsResponses.get(i);
        if (shardResponse == null) {
            // simply ignore non active shards
        } else if (shardResponse instanceof BroadcastShardOperationFailedException) {
            failedShards++;
            if (shardFailures == null) {
                shardFailures = new ArrayList<>();
            }
            shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
        } else {
            dfsResults.set(i, ((ShardDfsOnlyResponse) shardResponse).getDfsSearchResult());
            successfulShards++;
        }
    }
    AggregatedDfs dfs = searchPhaseController.aggregateDfs(dfsResults);
    return new DfsOnlyResponse(dfs, shardsResponses.length(), successfulShards, failedShards, shardFailures, buildTookInMillis(request));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:TransportDfsOnlyAction.java

示例12: validateRespose

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
protected void validateRespose(final SearchResponse response) {
    final int totalShards = response.getTotalShards();
    final int successfulShards = response.getSuccessfulShards();
    if (totalShards != successfulShards) {
        throw new MissingShardsException(totalShards - successfulShards
                + " shards are failed.");
    }
    final ShardSearchFailure[] failures = response.getShardFailures();
    if (failures.length > 0) {
        final StringBuilder buf = new StringBuilder();
        for (final ShardOperationFailedException failure : failures) {
            buf.append('\n').append(failure.toString());
        }
        throw new OperationFailedException("Search Operation Failed: "
                + buf.toString());
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-taste,代码行数:18,代码来源:DefaultRequestHandler.java

示例13: flush

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
public FlushResponse flush(
        final BuilderCallback<FlushRequestBuilder> builder) {
    waitForRelocation();
    final FlushResponse actionGet = builder
            .apply(client().admin().indices().prepareFlush()).execute()
            .actionGet();
    final ShardOperationFailedException[] shardFailures = actionGet
            .getShardFailures();
    if (shardFailures != null && shardFailures.length != 0) {
        final StringBuilder buf = new StringBuilder(100);
        for (final ShardOperationFailedException shardFailure : shardFailures) {
            buf.append(shardFailure.toString()).append('\n');
        }
        onFailure(buf.toString(), actionGet);
    }
    return actionGet;
}
 
开发者ID:codelibs,项目名称:elasticsearch-cluster-runner,代码行数:18,代码来源:ElasticsearchClusterRunner.java

示例14: refresh

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
public RefreshResponse refresh(
        final BuilderCallback<RefreshRequestBuilder> builder) {
    waitForRelocation();
    final RefreshResponse actionGet = builder
            .apply(client().admin().indices().prepareRefresh()).execute()
            .actionGet();
    final ShardOperationFailedException[] shardFailures = actionGet
            .getShardFailures();
    if (shardFailures != null && shardFailures.length != 0) {
        final StringBuilder buf = new StringBuilder(100);
        for (final ShardOperationFailedException shardFailure : shardFailures) {
            buf.append(shardFailure.toString()).append('\n');
        }
        onFailure(buf.toString(), actionGet);
    }
    return actionGet;
}
 
开发者ID:codelibs,项目名称:elasticsearch-cluster-runner,代码行数:18,代码来源:ElasticsearchClusterRunner.java

示例15: upgrade

import org.elasticsearch.action.ShardOperationFailedException; //导入依赖的package包/类
public UpgradeResponse upgrade(
        final BuilderCallback<UpgradeRequestBuilder> builder) {
    waitForRelocation();
    final UpgradeResponse actionGet = builder
            .apply(client().admin().indices().prepareUpgrade()).execute()
            .actionGet();
    final ShardOperationFailedException[] shardFailures = actionGet
            .getShardFailures();
    if (shardFailures != null && shardFailures.length != 0) {
        final StringBuilder buf = new StringBuilder(100);
        for (final ShardOperationFailedException shardFailure : shardFailures) {
            buf.append(shardFailure.toString()).append('\n');
        }
        onFailure(buf.toString(), actionGet);
    }
    return actionGet;
}
 
开发者ID:codelibs,项目名称:elasticsearch-cluster-runner,代码行数:18,代码来源:ElasticsearchClusterRunner.java


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