public static FileCopyGetChunkResponse readFrom(DataInputStream chunkResponseStream, ClusterMap clusterMap) throws IOException {
    RequestOrResponseType type = RequestOrResponseType.values()[chunkResponseStream.readShort()];
    if (type != RequestOrResponseType.FileCopyGetChunkResponse) {
      throw new IllegalArgumentException("The type of request response is not compatible");
    }
    short versionId = chunkResponseStream.readShort();
    validateVersion(versionId);

    int correlationId = chunkResponseStream.readInt();
    String clientId = Utils.readIntString(chunkResponseStream);

    ServerErrorCode errorCode = ServerErrorCode.values()[chunkResponseStream.readShort()];
    if(errorCode != ServerErrorCode.NoError){
      return new FileCopyGetChunkResponse(correlationId, clientId, errorCode);
    }
    PartitionId partitionId = clusterMap.getPartitionIdFromStream(chunkResponseStream);
    String fileName = Utils.readIntString(chunkResponseStream);
    long startOffset = chunkResponseStream.readLong();
    long sizeInBytes = chunkResponseStream.readLong();
    boolean isLastChunk = chunkResponseStream.readBoolean();

    return new FileCopyGetChunkResponse(versionId, correlationId, clientId, errorCode, partitionId, fileName,
        chunkResponseStream, startOffset, sizeInBytes, isLastChunk);
  }
Serialize the response into a buffer.
@param chunkResponseStream The output stream.
@param clusterMap The cluster map.
@return FileCopyGetChunkResponse
@throws IOException If an I/O error occurs.
ambry-protocol/src/main/java/com/github/ambry/protocol/FileCopyGetChunkResponse.java