private static XContentBuilder convert(RestRequest request, RestStatus status, Throwable t) throws IOException { XContentBuilder builder = restContentBuilder(request).startObject() .field("error", detailedMessage(t)) .field("status", status.getStatus()); if (t != null && request.paramAsBoolean("error_trace", false)) { builder.startObject("error_trace"); boolean first = true; while (t != null) { if (!first) { builder.startObject("cause"); } buildThrowable(t, builder); if (!first) { builder.endObject(); } t = t.getCause(); first = false; } builder.endObject(); } builder.endObject(); return builder; }
@Override public String toString() { return "failed shard, shard " + routingEntry + ", message [" + message + "], failure [" + ExceptionsHelper.detailedMessage(failure) + "], markAsStale [" + markAsStale + "]"; }
public String getReason() { return detailedMessage(reason); }
@Override public String toString() { List<String> components = new ArrayList<>(6); components.add("shard id [" + shardId + "]"); components.add("allocation id [" + allocationId + "]"); components.add("primary term [" + primaryTerm + "]"); components.add("message [" + message + "]"); if (failure != null) { components.add("failure [" + ExceptionsHelper.detailedMessage(failure) + "]"); } components.add("markAsStale [" + markAsStale + "]"); return String.join(", ", components); }
/** * Builds a string representation of the message and the failure if exists. */ @Nullable public String getDetails() { if (message == null) { return null; } return message + (failure == null ? "" : ", failure " + ExceptionsHelper.detailedMessage(failure)); }
@Override public String toString() { StringBuilder builder = new StringBuilder(); if (metadata.containsKey(INDEX_METADATA_KEY)) { builder.append(getIndex()); if (metadata.containsKey(SHARD_METADATA_KEY)) { builder.append('[').append(getShardId()).append(']'); } builder.append(' '); } return builder.append(ExceptionsHelper.detailedMessage(this).trim()).toString(); }
public DefaultShardOperationFailedException(String index, int shardId, Throwable cause) { super(index, shardId, detailedMessage(cause), ExceptionsHelper.status(cause), cause); }
@Override public void onFailure(Exception e) { logger.warn(() -> new ParameterizedMessage("couldn't store error {}", ExceptionsHelper.detailedMessage(error)), e); listener.onFailure(e); } });
@Override public void onAfter() { final Exception exception = failure.get(); if (exception != null) { final String failure = ExceptionsHelper.detailedMessage(exception); notifyFailedSnapshotShard(snapshot, shardId, localNodeId, failure, masterNode); } else { notifySuccessfulSnapshotShard(snapshot, shardId, localNodeId, masterNode); } } });
public Failure(ShardId shardId, @Nullable String nodeId, Exception cause, RestStatus status, boolean primary) { super(shardId.getIndexName(), shardId.getId(), ExceptionsHelper.detailedMessage(cause), status, cause); this.shardId = shardId; this.nodeId = nodeId; this.primary = primary; }
if (++joinAttempt == this.joinRetryAttempts) { logger.info("failed to send join request to master [{}], reason [{}], tried [{}] times", masterNode, ExceptionsHelper.detailedMessage(e), joinAttempt); return false; } else { logger.trace("master {} failed with [{}]. retrying... (attempts done: [{}])", masterNode, ExceptionsHelper.detailedMessage(e), joinAttempt); } else { logger.info("failed to send join request to master [{}], reason [{}]", masterNode, ExceptionsHelper.detailedMessage(e));
@Override public void snapshotShard(IndexShard shard, Store store, SnapshotId snapshotId, IndexId indexId, IndexCommit snapshotIndexCommit, IndexShardSnapshotStatus snapshotStatus) { SnapshotContext snapshotContext = new SnapshotContext(store, snapshotId, indexId, snapshotStatus, System.currentTimeMillis()); try { snapshotContext.snapshot(snapshotIndexCommit); } catch (Exception e) { snapshotStatus.moveToFailed(System.currentTimeMillis(), ExceptionsHelper.detailedMessage(e)); if (e instanceof IndexShardSnapshotFailedException) { throw (IndexShardSnapshotFailedException) e; } else { throw new IndexShardSnapshotFailedException(store.shardId(), e); } } }
@Override public String toString() { try { XContentBuilder builder = XContentFactory.jsonBuilder(); builder.prettyPrint(); toXContent(builder, EMPTY_PARAMS); return Strings.toString(builder); } catch (Exception e) { return "{ \"error\" : \"" + ExceptionsHelper.detailedMessage(e) + "\"}"; } }
@Override public String toString() { try { XContentBuilder builder = XContentFactory.jsonBuilder(); builder.prettyPrint(); toXContent(builder, EMPTY_PARAMS); return Strings.toString(builder); } catch (Exception e) { return "{ \"error\" : \"" + ExceptionsHelper.detailedMessage(e) + "\"}"; } }
/** * Stores the task failure */ public <Response extends ActionResponse> void storeResult(Task task, Exception error, ActionListener<Response> listener) { DiscoveryNode localNode = lastDiscoveryNodes.getLocalNode(); if (localNode == null) { // too early to store anything, shouldn't really be here - just pass the error along listener.onFailure(error); return; } final TaskResult taskResult; try { taskResult = task.result(localNode, error); } catch (IOException ex) { logger.warn(() -> new ParameterizedMessage("couldn't store error {}", ExceptionsHelper.detailedMessage(error)), ex); listener.onFailure(ex); return; } taskResultsService.storeResult(taskResult, new ActionListener<Void>() { @Override public void onResponse(Void aVoid) { listener.onFailure(error); } @Override public void onFailure(Exception e) { logger.warn(() -> new ParameterizedMessage("couldn't store error {}", ExceptionsHelper.detailedMessage(error)), e); listener.onFailure(e); } }); }
public DefaultShardOperationFailedException(ElasticsearchException e) { super(e.getIndex() == null ? null : e.getIndex().getName(), e.getShardId() == null ? -1 : e.getShardId().getId(), detailedMessage(e), e.status(), e); }
private void cleanupAfterError(Exception exception) { if(snapshotCreated) { try { repositoriesService.repository(snapshot.snapshot().getRepository()) .finalizeSnapshot(snapshot.snapshot().getSnapshotId(), snapshot.indices(), snapshot.startTime(), ExceptionsHelper.detailedMessage(exception), 0, Collections.emptyList(), snapshot.getRepositoryStateId(), snapshot.includeGlobalState()); } catch (Exception inner) { inner.addSuppressed(exception); logger.warn(() -> new ParameterizedMessage("[{}] failed to close snapshot in repository", snapshot.snapshot()), inner); } } userCreateSnapshotListener.onFailure(e); }
public ShardSearchFailure(Exception e, @Nullable SearchShardTarget shardTarget) { super(shardTarget == null ? null : shardTarget.getFullyQualifiedIndexName(), shardTarget == null ? -1 : shardTarget.getShardId().getId(), ExceptionsHelper.detailedMessage(e), ExceptionsHelper.status(ExceptionsHelper.unwrapCause(e)), ExceptionsHelper.unwrapCause(e)); final Throwable actual = ExceptionsHelper.unwrapCause(e); if (actual instanceof SearchException) { this.shardTarget = ((SearchException) actual).shard(); } else if (shardTarget != null) { this.shardTarget = shardTarget; } }
} catch (Exception inner) { inner.addSuppressed(e); files += " (failure=" + ExceptionsHelper.detailedMessage(inner) + ")";
@Override public String toString() { try { XContentBuilder builder = XContentFactory.jsonBuilder(); builder.prettyPrint(); toXContent(builder, EMPTY_PARAMS); return builder.string(); } catch (Exception e) { return "{ \"error\" : \"" + ExceptionsHelper.detailedMessage(e) + "\"}"; } }