private void processChunksToStitch() throws RouterException {
    long totalSize = 0;
    long intermediateChunkSize =
        routerConfig.routerMetadataContentVersion == MessageFormatRecord.Metadata_Content_Version_V2
            ? chunksToStitch.get(0).getChunkSizeInBytes() : routerConfig.routerMaxPutChunkSizeBytes;
    metadataPutChunk.setIntermediateChunkSize(intermediateChunkSize);
    for (ListIterator<ChunkInfo> iter = chunksToStitch.listIterator(); iter.hasNext(); ) {
      int chunkIndex = iter.nextIndex();
      ChunkInfo chunkInfo = iter.next();
      BlobId chunkId = unwrapChunkInfo(chunkInfo, intermediateChunkSize, !iter.hasNext());
      metadataPutChunk.addChunkId(chunkId, chunkInfo.getChunkSizeInBytes(), chunkIndex);
      totalSize += chunkInfo.getChunkSizeInBytes();
    }
    blobSize = totalSize;
    // Update blobSize in passedInBlobProperties. This can be used by Handlers after Router finishes stitching the blob
    passedInBlobProperties.setBlobSize(blobSize);
    chunkFillingCompletedSuccessfully = true;
  }
Process the list of data chunks provided and prepare a metadata chunk with the provided chunk IDs.
@throws RouterException if validation of the chunks to stitch failed.
ambry-router/src/main/java/com/github/ambry/router/PutOperation.java