static public ReplicaId getPeerForFileCopy(@Nonnull PartitionId partitionId, @Nonnull String datacenterName) {
    Objects.requireNonNull(partitionId, "partitionId must not be null");
    Objects.requireNonNull(datacenterName, "datacenterName must not be null");

    List<? extends ReplicaId> replicaIds = partitionId.getReplicaIdsByState(ReplicaState.LEADER, datacenterName);
    if (replicaIds.isEmpty()) {
      return null;
    }
    ReplicaId leaderReplicaId = replicaIds.get(0);
    return leaderReplicaId.isDown() ? null : leaderReplicaId;
  }
Get the peer replica in the given datacenter for file copy. We should only copy from healthy LEADER replicas.
@param partitionId the {@link PartitionId} of the replica.
@param datacenterName the name of the datacenter.
@return the peer replica in the given datacenter for file copy.
ambry-file-transfer/src/main/java/com/github/ambry/filetransfer/utils/FileCopyUtils.java