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