public static ReplicaId getReplicaFromNode(DataNodeId dataNodeId, PartitionId partitionId, ClusterMap clusterMap) {
    ReplicaId replicaToReturn = null;
    if (partitionId != null) {
      for (ReplicaId replicaId : partitionId.getReplicaIds()) {
        if (replicaId.getDataNodeId().getHostname().equals(dataNodeId.getHostname())) {
          replicaToReturn = replicaId;
          break;
        }
      }
    } else {
      // pick any replica on this node
      replicaToReturn = clusterMap.getReplicaIds(dataNodeId).get(0);
    }
    return replicaToReturn;
  }
Get replica of given {@link PartitionId} from given {@link DataNodeId}. If partitionId is null, it returns any
replica on the certain node.
@param dataNodeId the {@link DataNodeId} on which replica resides.
@param partitionId the {@link PartitionId} which replica belongs to.
@return {@link ReplicaId} from given node.
ambry-tools/src/main/java/com/github/ambry/tools/util/ToolRequestResponseUtil.java