@Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   fromNode.writeTo(out);
   out.writeVInt(indices.length);
   for (IndexMetaData indexMetaData : indices) {
     indexMetaData.writeTo(out);
   }
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   indicesLevelRequest.writeTo(out);
   int size = shards.size();
   out.writeVInt(size);
   for (int i = 0; i < size; i++) {
     shards.get(i).writeTo(out);
   }
   out.writeString(nodeId);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeLong(recoveryId);
   shardId.writeTo(out);
   if (out.getVersion().onOrAfter(Version.V_1_5_0)) {
     snapshotFiles.writeTo(out);
   } else {
     out.writeVInt(snapshotFiles.size());
     for (StoreFileMetaData snapshotFile : snapshotFiles) {
       out.writeString(snapshotFile.name());
     }
   }
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   if (out.getVersion().before(Version.V_1_4_0)) {
     // older nodes expect the concrete index as part of the request
     request.index(shardId.getIndex());
   }
   request.writeTo(out);
   if (out.getVersion().onOrAfter(Version.V_1_4_0)) {
     shardId.writeTo(out);
   } else {
     out.writeVInt(shardId.id());
   }
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeLong(recoveryId);
   shardId.writeTo(out);
   out.writeString(metaData.name());
   out.writeVLong(position);
   out.writeVLong(metaData.length());
   out.writeOptionalString(metaData.checksum());
   out.writeBytesReference(content);
   if (out.getVersion().onOrAfter(org.elasticsearch.Version.V_1_3_0)) {
     out.writeOptionalString(metaData.writtenBy() == null ? null : metaData.writtenBy().name());
   }
 }
Esempio n. 6
0
  @Override
  public void sendRequest(
      final DiscoveryNode node,
      final long requestId,
      final String action,
      final TransportRequest request,
      TransportRequestOptions options)
      throws IOException, TransportException {
    final Version version = Version.smallest(node.getVersion(), this.version);

    try (BytesStreamOutput stream = new BytesStreamOutput()) {
      stream.setVersion(version);

      stream.writeLong(requestId);
      byte status = 0;
      status = TransportStatus.setRequest(status);
      stream.writeByte(status); // 0 for request, 1 for response.

      threadPool.getThreadContext().writeTo(stream);
      stream.writeString(action);
      request.writeTo(stream);

      stream.close();

      final LocalTransport targetTransport = connectedNodes.get(node);
      if (targetTransport == null) {
        throw new NodeNotConnectedException(node, "Node not connected");
      }

      final byte[] data = stream.bytes().toBytes();
      transportServiceAdapter.sent(data.length);
      transportServiceAdapter.onRequestSent(node, requestId, action, request, options);
      targetTransport
          .workers()
          .execute(
              () -> {
                ThreadContext threadContext = targetTransport.threadPool.getThreadContext();
                try (ThreadContext.StoredContext context = threadContext.stashContext()) {
                  targetTransport.messageReceived(
                      data, action, LocalTransport.this, version, requestId);
                }
              });
    }
  }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   shardRouting.writeTo(out);
   out.writeString(reason);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeString(index);
   out.writeString(nodeId);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeLong(recoveryId);
   shardId.writeTo(out);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeOptionalString(fromNodeId);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeString(repository);
   out.writeString(verificationToken);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   shardSearchLocalRequest.innerWriteTo(out, false);
   OriginalIndices.writeOriginalIndices(originalIndices, out);
 }