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

The following examples show how to use org.elasticsearch.common.io.stream.StreamOutput#writeByte() . 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: SnapshotsInProgress.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeVInt(entries.size());
    for (Entry entry : entries) {
        entry.snapshotId().writeTo(out);
        out.writeBoolean(entry.includeGlobalState());
        out.writeByte(entry.state().value());
        out.writeVInt(entry.indices().size());
        for (String index : entry.indices()) {
            out.writeString(index);
        }
        out.writeLong(entry.startTime());
        out.writeVInt(entry.shards().size());
        for (Map.Entry<ShardId, ShardSnapshotStatus> shardEntry : entry.shards().entrySet()) {
            shardEntry.getKey().writeTo(out);
            out.writeOptionalString(shardEntry.getValue().nodeId());
            out.writeByte(shardEntry.getValue().state().value());
        }
    }
}
 
Example 2
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 3
Source File: Translog.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeVInt(SERIALIZATION_FORMAT);
    out.writeString(id);
    out.writeString(type);
    out.writeBytesReference(source);
    if (routing == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        out.writeString(routing);
    }
    if (parent == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        out.writeString(parent);
    }
    out.writeLong(version);
    out.writeLong(timestamp);
    out.writeLong(ttl);
    out.writeByte(versionType.getValue());
}
 
Example 4
Source File: IndexMetaData.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.writeLong(version);
    out.writeByte(state.id);
    out.writeLong(tenantId);
    Settings.writeSettingsToStream(settings, out);
    mappings.writeTo(out);
    aliases.writeTo(out);
    customs.writeTo(out);
}
 
Example 5
Source File: SnapshotInfo.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(final StreamOutput out) throws IOException {
    snapshotId.writeTo(out);
    out.writeVInt(indices.size());
    for (String index : indices) {
        out.writeString(index);
    }
    if (state != null) {
        out.writeBoolean(true);
        out.writeByte(state.value());
    } else {
        out.writeBoolean(false);
    }
    out.writeOptionalString(reason);
    out.writeVLong(startTime);
    out.writeVLong(endTime);
    out.writeVInt(totalShards);
    out.writeVInt(successfulShards);
    out.writeVInt(shardFailures.size());
    for (SnapshotShardFailure failure : shardFailures) {
        failure.writeTo(out);
    }
    if (version != null) {
        out.writeBoolean(true);
        Version.writeVersion(version, out);
    } else {
        out.writeBoolean(false);
    }
    out.writeOptionalBoolean(includeGlobalState);
}
 
Example 6
Source File: ShardSearchLocalRequest.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
protected void innerWriteTo(StreamOutput out, boolean asKey) throws IOException {
    out.writeString(index);
    out.writeVInt(shardId);
    out.writeByte(searchType.id());
    if (!asKey) {
        out.writeVInt(numberOfShards);
    }
    if (scroll == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        scroll.writeTo(out);
    }
    out.writeBytesReference(source);
    out.writeBytesReference(extraSource);
    out.writeStringArray(types);
    out.writeStringArrayNullable(filteringAliases);
    if (!asKey) {
        out.writeVLong(nowInMillis);
    }

    out.writeBytesReference(templateSource);
    boolean hasTemplate = template != null;
    out.writeBoolean(hasTemplate);
    if (hasTemplate) {
        template.writeTo(out);
    }
    out.writeOptionalBoolean(requestCache);
}
 
Example 7
Source File: ReplicationRequest.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);
    if (shardId != null) {
        out.writeBoolean(true);
        shardId.writeTo(out);
    } else {
        out.writeBoolean(false);
    }
    out.writeByte(consistencyLevel.id());
    timeout.writeTo(out);
    out.writeString(index);
    out.writeBoolean(canHaveDuplicates);
}
 
Example 8
Source File: PercolateShardResponse.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.writeByte(percolatorTypeId);
    out.writeVLong(requestedSize);
    out.writeVLong(count);
    out.writeVInt(matches.length);
    for (BytesRef match : matches) {
        out.writeBytesRef(match);
    }
    out.writeVLong(scores.length);
    for (float score : scores) {
        out.writeFloat(score);
    }
    out.writeVInt(hls.size());
    for (Map<String, HighlightField> hl : hls) {
        out.writeVInt(hl.size());
        for (Map.Entry<String, HighlightField> entry : hl.entrySet()) {
            out.writeString(entry.getKey());
            entry.getValue().writeTo(out);
        }
    }
    out.writeOptionalStreamable(aggregations);
    if (pipelineAggregators == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        out.writeVInt(pipelineAggregators.size());
        for (PipelineAggregator pipelineAggregator : pipelineAggregators) {
            out.writeBytesReference(pipelineAggregator.type().stream());
            pipelineAggregator.writeTo(out);
        }
    }
}
 
Example 9
Source File: MappingMetaData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(type());
    source().writeTo(out);
    // id
    if (id().hasPath()) {
        out.writeBoolean(true);
        out.writeString(id().path());
    } else {
        out.writeBoolean(false);
    }
    // routing
    out.writeBoolean(routing().required());
    if (routing().hasPath()) {
        out.writeBoolean(true);
        out.writeString(routing().path());
    } else {
        out.writeBoolean(false);
    }
    // timestamp
    out.writeBoolean(timestamp().enabled());
    out.writeOptionalString(timestamp().path());
    out.writeString(timestamp().format());
    out.writeOptionalString(timestamp().defaultTimestamp());
    out.writeOptionalBoolean(timestamp().ignoreMissing());
    out.writeBoolean(hasParentField());
    // mappingVersion
    out.writeLong(mappingVersion());

    if (version().hasPath()) {
        out.writeBoolean(true);
        out.writeString(version().path());
        out.writeByte(version().versionType().getValue());
    } else {
        out.writeBoolean(false);
    }
}
 
Example 10
Source File: SearchRequest.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.writeByte(searchType.id());

    out.writeVInt(indices.length);
    for (String index : indices) {
        out.writeString(index);
    }

    out.writeOptionalString(routing);
    out.writeOptionalString(preference);

    if (scroll == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        scroll.writeTo(out);
    }
    out.writeBytesReference(source);
    out.writeBytesReference(extraSource);
    out.writeStringArray(types);
    indicesOptions.writeIndicesOptions(out);

    out.writeBytesReference(templateSource);
    boolean hasTemplate = template != null;
    out.writeBoolean(hasTemplate);
    if (hasTemplate) {
        template.writeTo(out);
    }

    out.writeOptionalBoolean(requestCache);
}
 
Example 11
Source File: ShardRouting.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Writes shard information to {@link StreamOutput} without writing index name and shard id
 *
 * @param out {@link StreamOutput} to write shard information to
 * @throws IOException if something happens during write
 */
public void writeToThin(StreamOutput out) throws IOException {
    out.writeOptionalString(currentNodeId);
    out.writeOptionalString(relocatingNodeId);
    out.writeBoolean(primary);
    out.writeByte(state.value());
    if (state == ShardRoutingState.UNASSIGNED || state == ShardRoutingState.INITIALIZING) {
        recoverySource.writeTo(out);
    }
    out.writeOptionalWriteable(unassignedInfo);
    out.writeOptionalWriteable(allocationId);
    if (state == ShardRoutingState.RELOCATING || state == ShardRoutingState.INITIALIZING) {
        out.writeLong(expectedShardSize);
    }
}
 
Example 12
Source File: ShardUpsertRequest.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(id);
    if (updateAssignments != null) {
        out.writeVInt(updateAssignments.length);
        for (Symbol updateAssignment : updateAssignments) {
            Symbol.toStream(updateAssignment, out);
        }
    } else {
        out.writeVInt(0);
    }
    // Stream References
    if (insertValues != null) {
        out.writeVInt(insertValues.length);
        for (int i = 0; i < insertValues.length; i++) {
            insertValuesStreamer[i].writeValueTo(out, insertValues[i]);
        }
    } else {
        out.writeVInt(0);
    }

    Version.writeVersion(Version.fromId((int) version), out);
    out.writeByte(versionType.getValue());
    out.writeByte(opType.id());
    boolean sourceAvailable = source != null;
    out.writeBoolean(sourceAvailable);
    if (sourceAvailable) {
        out.writeBytesReference(source);
    }
}
 
Example 13
Source File: ClusterHealthResponse.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(clusterName);
    out.writeByte(clusterHealthStatus.value());
    clusterStateHealth.writeTo(out);
    out.writeInt(numberOfPendingTasks);
    out.writeBoolean(timedOut);
    out.writeInt(numberOfInFlightFetch);
    out.writeInt(delayedUnassignedShards);
    out.writeTimeValue(taskMaxWaitingTime);
}
 
Example 14
Source File: UnassignedInfo.java    From crate 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.writeBoolean(delayed);
    out.writeOptionalString(message);
    out.writeException(failure);
    out.writeVInt(failedAllocations);
    lastAllocationStatus.writeTo(out);
}
 
Example 15
Source File: PutIndexedScriptRequest.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.writeString(scriptLang);
    out.writeOptionalString(id);
    out.writeBytesReference(source);
    out.writeByte(opType.id());
    out.writeLong(version);
    out.writeByte(versionType.getValue());
}
 
Example 16
Source File: RestoreInProgress.java    From crate with Apache License 2.0 4 votes vote down vote up
/**
 * Writes restore status to stream output
 *
 * @param out stream input
 */
public void writeTo(StreamOutput out) throws IOException {
    out.writeOptionalString(nodeId);
    out.writeByte(state.value);
    out.writeOptionalString(reason);
}
 
Example 17
Source File: IndicesShardStoresResponse.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
private void writeTo(StreamOutput out) throws IOException {
    out.writeByte(id);
}
 
Example 18
Source File: SnapshotsInProgress.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public void writeTo(StreamOutput out) throws IOException {
    out.writeOptionalString(nodeId);
    out.writeByte(state.value);
    out.writeOptionalString(reason);
}
 
Example 19
Source File: RestoreInProgress.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Writes restore status to stream output
 *
 * @param out stream input
 */
public void writeTo(StreamOutput out) throws IOException {
    out.writeOptionalString(nodeId);
    out.writeByte(state.value);
    out.writeOptionalString(reason);
}
 
Example 20
Source File: ShardRouting.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Writes shard information to {@link StreamOutput} without writing index name and shard id
 *
 * @param out {@link StreamOutput} to write shard information to
 * @throws IOException if something happens during write
 */
public void writeToThin(StreamOutput out) throws IOException {
    out.writeLong(version);
    if (currentNodeId != null) {
        out.writeBoolean(true);
        out.writeString(currentNodeId);
    } else {
        out.writeBoolean(false);
    }

    if (relocatingNodeId != null) {
        out.writeBoolean(true);
        out.writeString(relocatingNodeId);
    } else {
        out.writeBoolean(false);
    }

    out.writeBoolean(primary);
    out.writeByte(state.value());

    if (restoreSource != null) {
        out.writeBoolean(true);
        restoreSource.writeTo(out);
    } else {
        out.writeBoolean(false);
    }
    if (unassignedInfo != null) {
        out.writeBoolean(true);
        unassignedInfo.writeTo(out);
    } else {
        out.writeBoolean(false);
    }
    if (allocationId != null) {
        out.writeBoolean(true);
        allocationId.writeTo(out);
    } else {
        out.writeBoolean(false);
    }
    if (relocating() || initializing()) {
        out.writeLong(expectedShardSize);
    }

}