Java Code Examples for org.elasticsearch.common.io.stream.StreamOutput#writeThrowable()

The following examples show how to use org.elasticsearch.common.io.stream.StreamOutput#writeThrowable() . 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: DistributedResultRequest.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeLong(jobId.getMostSignificantBits());
    out.writeLong(jobId.getLeastSignificantBits());
    out.writeVInt(executionPhaseId);
    out.writeVInt(bucketIdx);
    out.writeBoolean(isLast);
    out.writeByte(inputId);

    boolean failure = throwable != null;
    out.writeBoolean(failure);
    if (failure) {
        out.writeThrowable(throwable);
    } else {
        // TODO: we should not rely on another bucket in this class and instead write to the stream directly
        StreamBucket.writeBucket(out, streamers, rows);
    }
}
 
Example 2
Source File: ShardResponse.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeVInt(locations.size());
    for (int i = 0; i < locations.size(); i++) {
        out.writeVInt(locations.get(i));
        if (failures.get(i) == null) {
            out.writeBoolean(false);
        } else {
            out.writeBoolean(true);
            failures.get(i).writeTo(out);
        }
    }
    if (failure != null) {
        out.writeBoolean(true);
        out.writeThrowable(failure);
    } else {
        out.writeBoolean(false);
    }
}
 
Example 3
Source File: ElasticsearchException.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
/**
 * Serializes the given exceptions stacktrace elements as well as it's suppressed exceptions to the given output stream.
 */
public static <T extends Throwable> T writeStackTraces(T throwable, StreamOutput out) throws IOException {
    StackTraceElement[] stackTrace = throwable.getStackTrace();
    out.writeVInt(stackTrace.length);
    for (StackTraceElement element : stackTrace) {
        out.writeString(element.getClassName());
        out.writeOptionalString(element.getFileName());
        out.writeString(element.getMethodName());
        out.writeVInt(element.getLineNumber());
    }
    Throwable[] suppressed = throwable.getSuppressed();
    out.writeVInt(suppressed.length);
    for (Throwable t : suppressed) {
        out.writeThrowable(t);
    }
    return throwable;
}
 
Example 4
Source File: BulkItemResponse.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(getIndex());
    out.writeString(getType());
    out.writeOptionalString(getId());
    out.writeThrowable(getCause());
}
 
Example 5
Source File: MultiTermVectorsResponse.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(index);
    out.writeOptionalString(type);
    out.writeString(id);
    out.writeThrowable(cause);
}
 
Example 6
Source File: ActionWriteResponse.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(index);
    out.writeVInt(shardId);
    out.writeOptionalString(nodeId);
    out.writeThrowable(cause);
    RestStatus.writeTo(out, status);
    out.writeBoolean(primary);
}
 
Example 7
Source File: DefaultShardOperationFailedException.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    if (index == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        out.writeString(index);
    }
    out.writeVInt(shardId);
    out.writeThrowable(reason);
    RestStatus.writeTo(out, status);
}
 
Example 8
Source File: TaskOperationFailure.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(nodeId);
    out.writeLong(taskId);
    out.writeThrowable(reason);
    RestStatus.writeTo(out, status);
}
 
Example 9
Source File: MultiSearchResponse.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    if (response != null) {
        out.writeBoolean(true);
        response.writeTo(out);
    } else {
        out.writeBoolean(false);
        out.writeThrowable(throwable);
    }
}
 
Example 10
Source File: ShardSearchFailure.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    if (shardTarget == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        shardTarget.writeTo(out);
    }
    out.writeString(reason);
    RestStatus.writeTo(out, status);
    out.writeThrowable(cause);
}
 
Example 11
Source File: MultiPercolateResponse.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    if (response != null) {
        out.writeBoolean(true);
        response.writeTo(out);
    } else {
        out.writeBoolean(false);
        out.writeThrowable(throwable);
    }
}
 
Example 12
Source File: TransportShardMultiPercolateAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeVInt(items.size());
    for (Item item : items) {
        out.writeVInt(item.slot);
        if (item.response != null) {
            out.writeBoolean(true);
            item.response.writeTo(out);
        } else {
            out.writeBoolean(false);
            out.writeThrowable(item.error);
        }
    }
}
 
Example 13
Source File: MultiGetResponse.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(index);
    out.writeOptionalString(type);
    out.writeString(id);
    out.writeThrowable(throwable);
}
 
Example 14
Source File: IndicesShardStoresResponse.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    node.writeTo(out);
    out.writeLong(version);
    allocation.writeTo(out);
    if (storeException != null) {
        out.writeBoolean(true);
        out.writeThrowable(storeException);
    } else {
        out.writeBoolean(false);
    }
}
 
Example 15
Source File: ShardStateAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    shardRouting.writeTo(out);
    out.writeString(indexUUID);
    out.writeString(message);
    out.writeString(finderNodeId);
    out.writeThrowable(failure);
}
 
Example 16
Source File: UnassignedInfo.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public void writeTo(StreamOutput out) throws IOException {
    out.writeByte((byte) reason.ordinal());
    out.writeLong(unassignedTimeMillis);
    // Do not serialize unassignedTimeNanos as System.nanoTime() cannot be compared across different JVMs
    out.writeOptionalString(message);
    out.writeThrowable(failure);
}
 
Example 17
Source File: TransportNodesListGatewayStartedShards.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeLong(version);
    out.writeLong(numDocs);
    if (storeException != null) {
        out.writeBoolean(true);
        out.writeThrowable(storeException);
    } else {
        out.writeBoolean(false);
    }
}
 
Example 18
Source File: ElasticsearchException.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public void writeTo(StreamOutput out) throws IOException {
    out.writeOptionalString(this.getMessage());
    out.writeThrowable(this.getCause());
    writeStackTraces(this, out);
    out.writeVInt(headers.size());
    for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
        out.writeString(entry.getKey());
        out.writeVInt(entry.getValue().size());
        for (String v : entry.getValue()) {
            out.writeString(v);
        }
    }
}
 
Example 19
Source File: VerificationFailure.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeOptionalString(nodeId);
    out.writeThrowable(cause);
}