@Override
  public void readFrom(StreamInput in) throws IOException {
    index = in.readString();
    numberOfShards = in.readVInt();
    numberOfReplicas = in.readVInt();
    activePrimaryShards = in.readVInt();
    activeShards = in.readVInt();
    relocatingShards = in.readVInt();
    initializingShards = in.readVInt();
    unassignedShards = in.readVInt();
    status = ClusterHealthStatus.fromValue(in.readByte());

    int size = in.readVInt();
    for (int i = 0; i < size; i++) {
      ClusterShardHealth shardHealth = readClusterShardHealth(in);
      shards.put(shardHealth.getId(), shardHealth);
    }
    size = in.readVInt();
    if (size == 0) {
      validationFailures = ImmutableList.of();
    } else {
      for (int i = 0; i < size; i++) {
        validationFailures.add(in.readString());
      }
    }
  }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   clusterName = in.readUTF();
   activePrimaryShards = in.readVInt();
   activeShards = in.readVInt();
   relocatingShards = in.readVInt();
   initializingShards = in.readVInt();
   unassignedShards = in.readVInt();
   numberOfNodes = in.readVInt();
   numberOfDataNodes = in.readVInt();
   status = ClusterHealthStatus.fromValue(in.readByte());
   int size = in.readVInt();
   for (int i = 0; i < size; i++) {
     ClusterIndexHealth indexHealth = readClusterIndexHealth(in);
     indices.put(indexHealth.index(), indexHealth);
   }
   timedOut = in.readBoolean();
   size = in.readVInt();
   if (size == 0) {
     validationFailures = ImmutableList.of();
   } else {
     for (int i = 0; i < size; i++) {
       validationFailures.add(in.readUTF());
     }
   }
 }
  @Override
  public void writeTo(StreamOutput out) throws IOException {
    out.writeString(index);
    out.writeVInt(numberOfShards);
    out.writeVInt(numberOfReplicas);
    out.writeVInt(activePrimaryShards);
    out.writeVInt(activeShards);
    out.writeVInt(relocatingShards);
    out.writeVInt(initializingShards);
    out.writeVInt(unassignedShards);
    out.writeByte(status.value());

    out.writeVInt(shards.size());
    for (ClusterShardHealth shardHealth : this) {
      shardHealth.writeTo(out);
    }

    out.writeVInt(validationFailures.size());
    for (String failure : validationFailures) {
      out.writeString(failure);
    }
  }
  @Override
  public void writeTo(StreamOutput out) throws IOException {
    out.writeUTF(clusterName);
    out.writeVInt(activePrimaryShards);
    out.writeVInt(activeShards);
    out.writeVInt(relocatingShards);
    out.writeVInt(initializingShards);
    out.writeVInt(unassignedShards);
    out.writeVInt(numberOfNodes);
    out.writeVInt(numberOfDataNodes);
    out.writeByte(status.value());
    out.writeVInt(indices.size());
    for (ClusterIndexHealth indexHealth : this) {
      indexHealth.writeTo(out);
    }
    out.writeBoolean(timedOut);

    out.writeVInt(validationFailures.size());
    for (String failure : validationFailures) {
      out.writeUTF(failure);
    }
  }