Java Code Examples for org.elasticsearch.ExceptionsHelper#status()
The following examples show how to use
org.elasticsearch.ExceptionsHelper#status() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotSerializableExceptionWrapper.java From Elasticsearch with Apache License 2.0 | 6 votes |
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)); } } }
Example 2
Source File: ShardSearchFailure.java From Elasticsearch with Apache License 2.0 | 5 votes |
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; }
Example 3
Source File: TransportReplicationAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
private void doFinish() { if (finished.compareAndSet(false, true)) { setPhase(task, "finished"); Releasables.close(indexShardReference); final ActionWriteResponse.ShardInfo.Failure[] failuresArray; if (!shardReplicaFailures.isEmpty()) { int slot = 0; failuresArray = new ActionWriteResponse.ShardInfo.Failure[shardReplicaFailures.size()]; for (Map.Entry<String, Throwable> entry : shardReplicaFailures.entrySet()) { RestStatus restStatus = ExceptionsHelper.status(entry.getValue()); failuresArray[slot++] = new ActionWriteResponse.ShardInfo.Failure( shardId.getIndex(), shardId.getId(), entry.getKey(), entry.getValue(), restStatus, false ); } } else { failuresArray = ActionWriteResponse.EMPTY; } finalResponse.setShardInfo(new ActionWriteResponse.ShardInfo( totalShards, success.get(), failuresArray ) ); try { channel.sendResponse(finalResponse); } catch (IOException responseException) { logger.warn("failed to send error message back to client for action [" + transportReplicaAction + "]", responseException); } if (logger.isTraceEnabled()) { logger.trace("action [{}] completed on all replicas [{}] for request [{}]", transportReplicaAction, shardId, replicaRequest); } } }
Example 4
Source File: BulkItemResponse.java From Elasticsearch with Apache License 2.0 | 5 votes |
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); }
Example 5
Source File: IndexShard.java From crate with Apache License 2.0 | 5 votes |
/** * Replays translog operations from the provided translog {@code snapshot} to the current engine using the given {@code origin}. * The callback {@code onOperationRecovered} is notified after each translog operation is replayed successfully. */ int runTranslogRecovery(Engine engine, Translog.Snapshot snapshot, Engine.Operation.Origin origin, Runnable onOperationRecovered) throws IOException { int opsRecovered = 0; Translog.Operation operation; while ((operation = snapshot.next()) != null) { try { logger.trace("[translog] recover op {}", operation); Engine.Result result = applyTranslogOperation(engine, operation, origin); switch (result.getResultType()) { case FAILURE: throw result.getFailure(); case MAPPING_UPDATE_REQUIRED: throw new IllegalArgumentException("unexpected mapping update: " + result.getRequiredMappingUpdate()); case SUCCESS: break; default: throw new AssertionError("Unknown result type [" + result.getResultType() + "]"); } opsRecovered++; onOperationRecovered.run(); } catch (Exception e) { if (ExceptionsHelper.status(e) == RestStatus.BAD_REQUEST) { // mainly for MapperParsingException and Failure to detect xcontent logger.info("ignoring recovery of a corrupt translog entry", e); } else { throw ExceptionsHelper.convertToRuntime(e); } } } return opsRecovered; }
Example 6
Source File: BytesRestResponse.java From Elasticsearch with Apache License 2.0 | 4 votes |
public BytesRestResponse(RestChannel channel, Throwable t) throws IOException { this(channel, ExceptionsHelper.status(t), t); }
Example 7
Source File: TaskOperationFailure.java From Elasticsearch with Apache License 2.0 | 4 votes |
public TaskOperationFailure(String nodeId, long taskId, Throwable t) { this.nodeId = nodeId; this.taskId = taskId; this.reason = t; status = ExceptionsHelper.status(t); }
Example 8
Source File: DefaultShardOperationFailedException.java From Elasticsearch with Apache License 2.0 | 4 votes |
public DefaultShardOperationFailedException(String index, int shardId, Throwable t) { this.index = index; this.shardId = shardId; this.reason = t; status = ExceptionsHelper.status(t); }
Example 9
Source File: DefaultShardOperationFailedException.java From crate with Apache License 2.0 | 4 votes |
public DefaultShardOperationFailedException(String index, int shardId, Throwable cause) { super(index, shardId, detailedMessage(cause), ExceptionsHelper.status(cause), cause); }