protected void handleResponse(
     Channel channel, StreamInput buffer, final TransportResponseHandler handler) {
   final TransportResponse response = handler.newInstance();
   response.remoteAddress(
       new InetSocketTransportAddress((InetSocketAddress) channel.getRemoteAddress()));
   response.remoteAddress();
   try {
     response.readFrom(buffer);
   } catch (Throwable e) {
     handleException(
         handler,
         new TransportSerializationException(
             "Failed to deserialize response of type [" + response.getClass().getName() + "]", e));
     return;
   }
   try {
     if (handler.executor() == ThreadPool.Names.SAME) {
       //noinspection unchecked
       handler.handleResponse(response);
     } else {
       threadPool.executor(handler.executor()).execute(new ResponseHandler(handler, response));
     }
   } catch (Throwable e) {
     handleException(handler, new ResponseHandlerFailureTransportException(e));
   }
 }
  @Override
  public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    int size = in.readVInt();
    phase1FileNames = Lists.newArrayListWithCapacity(size);
    for (int i = 0; i < size; i++) {
      phase1FileNames.add(in.readUTF());
    }
    size = in.readVInt();
    phase1FileSizes = Lists.newArrayListWithCapacity(size);
    for (int i = 0; i < size; i++) {
      phase1FileSizes.add(in.readVLong());
    }

    size = in.readVInt();
    phase1ExistingFileNames = Lists.newArrayListWithCapacity(size);
    for (int i = 0; i < size; i++) {
      phase1ExistingFileNames.add(in.readUTF());
    }
    size = in.readVInt();
    phase1ExistingFileSizes = Lists.newArrayListWithCapacity(size);
    for (int i = 0; i < size; i++) {
      phase1ExistingFileSizes.add(in.readVLong());
    }

    phase1TotalSize = in.readVLong();
    phase1ExistingTotalSize = in.readVLong();
    phase1Time = in.readVLong();
    phase1ThrottlingWaitTime = in.readVLong();
    startTime = in.readVLong();
    phase2Operations = in.readVInt();
    phase2Time = in.readVLong();
    phase3Operations = in.readVInt();
    phase3Time = in.readVLong();
  }
  @Override
  public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeVInt(phase1FileNames.size());
    for (String name : phase1FileNames) {
      out.writeUTF(name);
    }
    out.writeVInt(phase1FileSizes.size());
    for (long size : phase1FileSizes) {
      out.writeVLong(size);
    }

    out.writeVInt(phase1ExistingFileNames.size());
    for (String name : phase1ExistingFileNames) {
      out.writeUTF(name);
    }
    out.writeVInt(phase1ExistingFileSizes.size());
    for (long size : phase1ExistingFileSizes) {
      out.writeVLong(size);
    }

    out.writeVLong(phase1TotalSize);
    out.writeVLong(phase1ExistingTotalSize);
    out.writeVLong(phase1Time);
    out.writeVLong(phase1ThrottlingWaitTime);
    out.writeVLong(startTime);
    out.writeVInt(phase2Operations);
    out.writeVLong(phase2Time);
    out.writeVInt(phase3Operations);
    out.writeVLong(phase3Time);
  }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   shardTarget = readSearchShardTarget(in);
   result = readQueryFetchSearchResult(in);
   result.shardTarget(shardTarget);
 }
Esempio n. 5
0
 protected void handleResponse(
     StreamInput buffer, LocalTransport sourceTransport, final TransportResponseHandler handler) {
   buffer = new NamedWriteableAwareStreamInput(buffer, namedWriteableRegistry);
   final TransportResponse response = handler.newInstance();
   response.remoteAddress(sourceTransport.boundAddress.publishAddress());
   try {
     response.readFrom(buffer);
   } catch (Throwable e) {
     handleException(
         handler,
         new TransportSerializationException(
             "Failed to deserialize response of type [" + response.getClass().getName() + "]", e));
     return;
   }
   handleParsedResponse(response, handler);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeString(nodeId);
   out.writeVInt(totalShards);
   out.writeVInt(results.size());
   for (ShardOperationResult result : results) {
     out.writeOptionalStreamable(result);
   }
   out.writeBoolean(exceptions != null);
   if (exceptions != null) {
     int failureShards = exceptions.size();
     out.writeVInt(failureShards);
     for (int i = 0; i < failureShards; i++) {
       exceptions.get(i).writeTo(out);
     }
   }
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   nodeId = in.readString();
   totalShards = in.readVInt();
   int resultsSize = in.readVInt();
   results = new ArrayList<>(resultsSize);
   for (; resultsSize > 0; resultsSize--) {
     final ShardOperationResult result = in.readBoolean() ? readShardResult(in) : null;
     results.add(result);
   }
   if (in.readBoolean()) {
     int failureShards = in.readVInt();
     exceptions = new ArrayList<>(failureShards);
     for (int i = 0; i < failureShards; i++) {
       exceptions.add(new BroadcastShardOperationFailedException(in));
     }
   } else {
     exceptions = null;
   }
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeBoolean(ack);
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   ack = in.readBoolean();
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeBoolean(connectedToMaster);
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   connectedToMaster = in.readBoolean();
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   shardTarget.writeTo(out);
   result.writeTo(out);
 }