@Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeLong(tookInMillis);
   out.writeLong(ingestId);
   shardId.writeTo(out);
   out.writeVInt(successCount);
   out.writeVInt(quorumShards);
   out.writeVInt(actionRequests.size());
   for (ActionRequest actionRequest : actionRequests) {
     if (actionRequest == null) {
       out.writeBoolean(false);
     } else {
       out.writeBoolean(true);
       if (actionRequest instanceof IndexRequest) {
         out.writeBoolean(true);
       } else if (actionRequest instanceof DeleteRequest) {
         out.writeBoolean(false);
       } else {
         throw new ElasticsearchIllegalStateException(
             "action request not supported: " + actionRequest.getClass().getName());
       }
       actionRequest.writeTo(out);
     }
   }
   out.writeVInt(failures.size());
   for (IngestActionFailure f : failures) {
     f.writeTo(out);
   }
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   tookInMillis = in.readLong();
   ingestId = in.readLong();
   shardId = ShardId.readShardId(in);
   successCount = in.readVInt();
   quorumShards = in.readVInt();
   actionRequests = newLinkedList();
   int size = in.readVInt();
   for (int i = 0; i < size; i++) {
     boolean exists = in.readBoolean();
     if (exists) {
       boolean b = in.readBoolean();
       if (b) {
         IndexRequest indexRequest = new IndexRequest();
         indexRequest.readFrom(in);
         actionRequests.add(indexRequest);
       } else {
         DeleteRequest deleteRequest = new DeleteRequest();
         deleteRequest.readFrom(in);
         actionRequests.add(deleteRequest);
       }
     } else {
       actionRequests.add(null);
     }
   }
   failures = newLinkedList();
   size = in.readVInt();
   for (int i = 0; i < size; i++) {
     failures.add(IngestActionFailure.from(in));
   }
 }