/** * For write failures before operation was assigned a sequence number. * * use @{link {@link #Failure(String, String, String, Exception, long)}} * to record operation sequence no with failure */ public Failure(String index, String type, String id, Exception cause) { this(index, type, id, cause, ExceptionsHelper.status(cause), SequenceNumbers.UNASSIGNED_SEQ_NO, false); }
public TaskOperationFailure(String nodeId, long taskId, Exception e) { this.nodeId = nodeId; this.taskId = taskId; this.reason = e; status = ExceptionsHelper.status(e); }
/** * Build the exception with the status derived from the cause. */ public ElasticsearchSecurityException(String msg, Exception cause, Object... args) { this(msg, ExceptionsHelper.status(cause), cause, args); }
/** For write failures after operation was assigned a sequence number. */ public Failure(String index, String type, String id, Exception cause, long seqNo) { this(index, type, id, cause, ExceptionsHelper.status(cause), seqNo, false); }
public Failure(String index, String type, String id, Exception cause, boolean aborted) { this(index, type, id, cause, ExceptionsHelper.status(cause), SequenceNumbers.UNASSIGNED_SEQ_NO, aborted); }
public BytesRestResponse(RestChannel channel, Exception e) throws IOException { this(channel, ExceptionsHelper.status(e), e); }
/** * Returns the rest status code associated with this exception. */ public RestStatus status() { Throwable cause = unwrapCause(); if (cause == this) { return RestStatus.INTERNAL_SERVER_ERROR; } else { return ExceptionsHelper.status(cause); } }
public DefaultShardOperationFailedException(String index, int shardId, Throwable cause) { super(index, shardId, detailedMessage(cause), ExceptionsHelper.status(cause), cause); }
@Override public void onFailure(Exception replicaException) { logger.trace(() -> new ParameterizedMessage( "[{}] failure while performing [{}] on replica {}, request [{}]", shard.shardId(), opType, shard, replicaRequest), replicaException); // Only report "critical" exceptions - TODO: Reach out to the master node to get the latest shard state then report. if (TransportActions.isShardNotAvailableException(replicaException) == false) { RestStatus restStatus = ExceptionsHelper.status(replicaException); shardReplicaFailures.add(new ReplicationResponse.ShardInfo.Failure( shard.shardId(), shard.currentNodeId(), replicaException, restStatus, false)); } String message = String.format(Locale.ROOT, "failed to perform %s on replica %s", opType, shard); replicasProxy.failShardIfNeeded(shard, message, replicaException, ReplicationOperation.this::decPendingAndFinishIfNeeded, ReplicationOperation.this::onPrimaryDemoted, throwable -> decPendingAndFinishIfNeeded()); } });
onOperationRecovered.run(); } catch (Exception e) { if (ExceptionsHelper.status(e) == RestStatus.BAD_REQUEST) {
@Override public void onFailure(Exception e) { logger.trace("{}: got failure from {}", actionName, shardId); int totalNumCopies = clusterState.getMetaData().getIndexSafe(shardId.getIndex()).getNumberOfReplicas() + 1; ShardResponse shardResponse = newShardResponse(); ReplicationResponse.ShardInfo.Failure[] failures; if (TransportActions.isShardNotAvailableException(e)) { failures = new ReplicationResponse.ShardInfo.Failure[0]; } else { ReplicationResponse.ShardInfo.Failure failure = new ReplicationResponse.ShardInfo.Failure(shardId, null, e, ExceptionsHelper.status(e), true); failures = new ReplicationResponse.ShardInfo.Failure[totalNumCopies]; Arrays.fill(failures, failure); } shardResponse.setShardInfo(new ReplicationResponse.ShardInfo(totalNumCopies, 0, failures)); shardsResponses.add(shardResponse); if (responsesCountDown.countDown()) { finishAndNotifyListener(listener, shardsResponses); } } };
public NotSerializableExceptionWrapper(Throwable other) { super(ElasticsearchException.getExceptionName(other) + ": " + other.getMessage(), other.getCause()); this.name = ElasticsearchException.getExceptionName(other); this.status = ExceptionsHelper.status(other); setStackTrace(other.getStackTrace()); for (Throwable otherSuppressed : other.getSuppressed()) { addSuppressed(otherSuppressed); } if (other instanceof ElasticsearchException) { ElasticsearchException ex = (ElasticsearchException) other; for (String key : ex.getHeaderKeys()) { this.addHeader(key, ex.getHeader(key)); } for (String key : ex.getMetadataKeys()) { this.addMetadata(key, ex.getMetadata(key)); } } }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.startArray(Fields.RESPONSES); for (Item item : items) { builder.startObject(); if (item.isFailure()) { ElasticsearchException.generateFailureXContent(builder, params, item.getFailure(), true); builder.field(Fields.STATUS, ExceptionsHelper.status(item.getFailure()).getStatus()); } else { item.getResponse().innerToXContent(builder, params); builder.field(Fields.STATUS, item.getResponse().status().getStatus()); } builder.endObject(); } builder.endArray(); builder.endObject(); return builder; }
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; } }
public Failure(String index, String type, String id, Throwable t) { this.index = index; this.type = type; this.id = id; this.cause = t; this.status = ExceptionsHelper.status(t); }
/** * Read from a stream. */ public Failure(StreamInput in) throws IOException { index = in.readString(); type = in.readString(); id = in.readOptionalString(); cause = in.readException(); status = ExceptionsHelper.status(cause); if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { seqNo = in.readZLong(); } else { seqNo = SequenceNumbers.UNASSIGNED_SEQ_NO; } if (supportsAbortedFlag(in.getVersion())) { aborted = in.readBoolean(); } else { aborted = false; } }
@Override public void onFailure(Throwable e) { try { channel.sendResponse(new BytesRestResponse(ExceptionsHelper.status(e))); } catch (Exception e1) { logger.error("Failed to send failure response", e1); } } });
public ShardSearchFailure(Exception e, @Nullable SearchShardTarget shardTarget) { final Throwable actual = ExceptionsHelper.unwrapCause(e); if (actual != null && actual instanceof SearchException) { this.shardTarget = ((SearchException) actual).shard(); } else if (shardTarget != null) { this.shardTarget = shardTarget; } status = ExceptionsHelper.status(actual); this.reason = ExceptionsHelper.detailedMessage(e); this.cause = actual; }
public ShardSearchFailure(Throwable t, @Nullable SearchShardTarget shardTarget) { Throwable actual = ExceptionsHelper.unwrapCause(t); if (actual != null && actual instanceof SearchException) { this.shardTarget = ((SearchException) actual).shard(); } else if (shardTarget != null) { this.shardTarget = shardTarget; } status = ExceptionsHelper.status(actual); this.reason = ExceptionsHelper.detailedMessage(t); this.cause = actual; }
/** * Read from a stream. */ public Failure(StreamInput in) throws IOException { index = in.readString(); type = in.readString(); id = in.readOptionalString(); cause = in.readException(); status = ExceptionsHelper.status(cause); }