/** * Returns the root cause of this exception or multiple if different shards caused different exceptions */ public ElasticsearchException[] guessRootCauses() { final Throwable cause = getCause(); if (cause != null && cause instanceof ElasticsearchException) { return ((ElasticsearchException) cause).guessRootCauses(); } return new ElasticsearchException[]{this}; }
@Override public ElasticsearchException[] guessRootCauses() { ShardOperationFailedException[] failures = ExceptionsHelper.groupBy(shardFailures); List<ElasticsearchException> rootCauses = new ArrayList<>(failures.length); for (ShardOperationFailedException failure : failures) { ElasticsearchException[] guessRootCauses = ElasticsearchException.guessRootCauses(failure.getCause()); rootCauses.addAll(Arrays.asList(guessRootCauses)); } return rootCauses.toArray(new ElasticsearchException[0]); }
if (ex instanceof ElasticsearchException) { return ((ElasticsearchException) ex).guessRootCauses(); if (cause != null) { if (cause instanceof XContentParseException || cause instanceof ElasticsearchException) { return guessRootCauses(ex.getCause());
final ElasticsearchException[] rootCauses = ElasticsearchException.guessRootCauses(e); builder.startObject(ERROR);
final ShardOperationFailedException[] shardSearchFailures = ExceptionsHelper.groupBy(buildShardFailures()); Throwable cause = shardSearchFailures.length == 0 ? null : ElasticsearchException.guessRootCauses(shardSearchFailures[0].getCause())[0]; logger.debug(() -> new ParameterizedMessage("All shards failed for phase: [{}]", getName()), cause); onPhaseFailure(currentPhase, "all shards failed", cause); final ShardOperationFailedException[] shardSearchFailures = ExceptionsHelper.groupBy(buildShardFailures()); Throwable cause = shardSearchFailures.length == 0 ? null : ElasticsearchException.guessRootCauses(shardSearchFailures[0].getCause())[0]; logger.debug(() -> new ParameterizedMessage("{} shards failed for phase: [{}]", shardSearchFailures.length, getName()), cause);
/** * Returns the root cause of this exception or multiple if different shards caused different exceptions */ public ElasticsearchException[] guessRootCauses() { final Throwable cause = getCause(); if (cause != null && cause instanceof ElasticsearchException) { return ((ElasticsearchException) cause).guessRootCauses(); } return new ElasticsearchException[]{this}; }
/** * Returns the root cause of this exception or multiple if different shards caused different exceptions */ public ElasticsearchException[] guessRootCauses() { final Throwable cause = getCause(); if (cause != null && cause instanceof ElasticsearchException) { return ((ElasticsearchException) cause).guessRootCauses(); } return new ElasticsearchException[]{this}; }
/** * Returns the root cause of this exception or multiple if different shards caused different exceptions */ public ElasticsearchException[] guessRootCauses() { final Throwable cause = getCause(); if (cause != null && cause instanceof ElasticsearchException) { return ((ElasticsearchException) cause).guessRootCauses(); } return new ElasticsearchException[]{this}; }
/** * Returns the root cause of this exception or mupltiple if different shards caused different exceptions */ public ElasticsearchException[] guessRootCauses() { final Throwable cause = getCause(); if (cause != null && cause instanceof ElasticsearchException) { return ((ElasticsearchException) cause).guessRootCauses(); } return new ElasticsearchException[] {this}; }
@Override public ElasticsearchException[] guessRootCauses() { ShardOperationFailedException[] failures = ExceptionsHelper.groupBy(shardFailures); List<ElasticsearchException> rootCauses = new ArrayList<>(failures.length); for (ShardOperationFailedException failure : failures) { ElasticsearchException[] guessRootCauses = ElasticsearchException.guessRootCauses(failure.getCause()); rootCauses.addAll(Arrays.asList(guessRootCauses)); } return rootCauses.toArray(new ElasticsearchException[0]); }
@Override public ElasticsearchException[] guessRootCauses() { ShardOperationFailedException[] failures = ExceptionsHelper.groupBy(shardFailures); List<ElasticsearchException> rootCauses = new ArrayList<>(failures.length); for (ShardOperationFailedException failure : failures) { ElasticsearchException[] guessRootCauses = ElasticsearchException.guessRootCauses(failure.getCause()); rootCauses.addAll(Arrays.asList(guessRootCauses)); } return rootCauses.toArray(new ElasticsearchException[0]); }
/** * Returns the root cause of this exception or multiple if different shards caused different exceptions. * If the given exception is not an instance of {@link org.elasticsearch.ElasticsearchException} an empty array * is returned. */ public static ElasticsearchException[] guessRootCauses(Throwable t) { Throwable ex = ExceptionsHelper.unwrapCause(t); if (ex instanceof ElasticsearchException) { return ((ElasticsearchException) ex).guessRootCauses(); } return new ElasticsearchException[]{new ElasticsearchException(t.getMessage(), t) { @Override protected String getExceptionName() { return getExceptionName(getCause()); } }}; }
@Override public ElasticsearchException[] guessRootCauses() { ShardOperationFailedException[] failures = ExceptionsHelper.groupBy(shardFailures); List<ElasticsearchException> rootCauses = new ArrayList<>(failures.length); for (ShardOperationFailedException failure : failures) { ElasticsearchException[] guessRootCauses = ElasticsearchException.guessRootCauses(failure.getCause()); rootCauses.addAll(Arrays.asList(guessRootCauses)); } return rootCauses.toArray(new ElasticsearchException[0]); }
@Override public ElasticsearchException[] guessRootCauses() { ShardOperationFailedException[] failures = ExceptionsHelper.groupBy(shardFailures); List<ElasticsearchException> rootCauses = new ArrayList<>(failures.length); for (ShardOperationFailedException failure : failures) { ElasticsearchException[] guessRootCauses = ElasticsearchException.guessRootCauses(failure.getCause()); rootCauses.addAll(Arrays.asList(guessRootCauses)); } return rootCauses.toArray(new ElasticsearchException[0]); }
/** * Returns the root cause of this exception or mupltiple if different shards caused different exceptions. * If the given exception is not an instance of {@link org.elasticsearch.ElasticsearchException} an empty array * is returned. */ public static ElasticsearchException[] guessRootCauses(Throwable t) { Throwable ex = ExceptionsHelper.unwrapCause(t); if (ex instanceof ElasticsearchException) { return ((ElasticsearchException) ex).guessRootCauses(); } return new ElasticsearchException[] {new ElasticsearchException(t.getMessage(), t) { @Override protected String getExceptionName() { return getExceptionName(getCause()); } }}; }
if (ex instanceof ElasticsearchException) { return ((ElasticsearchException) ex).guessRootCauses(); if (cause != null) { if (cause instanceof XContentParseException || cause instanceof ElasticsearchException) { return guessRootCauses(ex.getCause());
public static void renderThrowable(XContentBuilder builder, Params params, Throwable t) throws IOException { builder.startObject("error"); final ElasticsearchException[] rootCauses = ElasticsearchException.guessRootCauses(t); builder.field("root_cause"); builder.startArray(); for (ElasticsearchException rootCause : rootCauses){ builder.startObject(); rootCause.toXContent(builder, new ToXContent.DelegatingMapParams(Collections.singletonMap(ElasticsearchException.REST_EXCEPTION_SKIP_CAUSE, "true"), params)); builder.endObject(); } builder.endArray(); ElasticsearchException.toXContent(builder, params, t); builder.endObject(); } }
@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 = shardSearchFailures.length == 0 ? null : 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.getSearchShardTarget().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); } }
final ShardOperationFailedException[] shardSearchFailures = ExceptionsHelper.groupBy(buildShardFailures()); Throwable cause = shardSearchFailures.length == 0 ? null : ElasticsearchException.guessRootCauses(shardSearchFailures[0].getCause())[0]; logger.debug(() -> new ParameterizedMessage("All shards failed for phase: [{}]", getName()), cause); onPhaseFailure(currentPhase, "all shards failed", cause); final ShardOperationFailedException[] shardSearchFailures = ExceptionsHelper.groupBy(buildShardFailures()); Throwable cause = shardSearchFailures.length == 0 ? null : ElasticsearchException.guessRootCauses(shardSearchFailures[0].getCause())[0]; logger.debug(() -> new ParameterizedMessage("{} shards failed for phase: [{}]", shardSearchFailures.length, getName()), cause);
final ElasticsearchException[] rootCauses = ElasticsearchException.guessRootCauses(t); builder.field("root_cause"); builder.startArray();