ReplicaMetadataRequest createReplicaMetadataRequest(List<RemoteReplicaInfo> replicasToReplicatePerNode,
      DataNodeId remoteNode) {
    boolean allLocalStoreInBootstrap = true;
    List<ReplicaMetadataRequestInfo> replicaMetadataRequestInfoList = new ArrayList<>();
    for (RemoteReplicaInfo remoteReplicaInfo : replicasToReplicatePerNode) {
      ReplicaMetadataRequestInfo replicaMetadataRequestInfo =
          new ReplicaMetadataRequestInfo(remoteReplicaInfo.getReplicaId().getPartitionId(),
              remoteReplicaInfo.getToken(), dataNodeId.getHostname(), getLocalReplicaPath(remoteReplicaInfo),
              remoteReplicaInfo.getReplicaId().getReplicaType(), replicationConfig.replicaMetadataRequestVersion);
      replicaMetadataRequestInfoList.add(replicaMetadataRequestInfo);
      logger.trace("Remote node: {} Thread name: {} Remote replica: {} Token going to be sent to remote: {} ",
          remoteNode, threadName, remoteReplicaInfo.getReplicaId(), remoteReplicaInfo.getToken());
      if (remoteReplicaInfo.getLocalStore().getCurrentState() != ReplicaState.BOOTSTRAP) {
        allLocalStoreInBootstrap = false;
      }
    }
    long fetchSize = replicationConfig.replicationFetchSizeInBytes;
    if (allLocalStoreInBootstrap && !replicatingFromRemoteColo) {
      fetchSize = replicationConfig.replicationFetchSizeInBytesForBootstrapIntraColo;
      logger.trace(
          "All local stores are at bootstrap mode, and this is intro colo replication, set the fetch size to {}",
          fetchSize);
    }
    return new ReplicaMetadataRequest(correlationIdGenerator.incrementAndGet(),
        "replication-metadata-" + dataNodeId.getHostname() + "[" + dataNodeId.getDatacenterName() + "]",
        replicaMetadataRequestInfoList, fetchSize, replicationConfig.replicaMetadataRequestVersion);
  }
Create a {@link ReplicaMetadataRequest} for given list of replicas in the {@code replicasToReplicaPerNode}.
@param replicasToReplicatePerNode The list of {@link RemoteReplicaInfo} that contains the remote replica ids and their tokens.
@param remoteNode The remote {@link DataNodeId}.
@return A {@link ReplicaMetadataRequest} to send out later.
ambry-replication/src/main/java/com/github/ambry/replication/ReplicaThread.java