private ServerName[] singleRackCase(RegionInfo regionInfo, ServerName primaryRS,
    String primaryRack) throws IOException {
    // Single rack case: have to pick the secondary and tertiary
    // from the same rack
    List<ServerName> serverList = getServersFromRack(primaryRack);
    if ((serverList == null) || (serverList.size() <= 2)) {
      // Single region server case: cannot not place the favored nodes
      // on any server;
      return null;
    } else {
      // Randomly select two region servers from the server list and make sure
      // they are not overlap with the primary region server;
      Set<ServerName> serverSkipSet = new HashSet<>();
      serverSkipSet.add(primaryRS);

      // Place the secondary RS
      ServerName secondaryRS = getOneRandomServer(primaryRack, serverSkipSet);
      // Skip the secondary for the tertiary placement
      serverSkipSet.add(secondaryRS);
      ServerName tertiaryRS = getOneRandomServer(primaryRack, serverSkipSet);

      if (secondaryRS == null || tertiaryRS == null) {
        LOG.error("Cannot place the secondary, tertiary favored node for region "
          + regionInfo.getRegionNameAsString());
      }
      // Create the secondary and tertiary pair
      ServerName[] favoredNodes = new ServerName[2];
      favoredNodes[0] = secondaryRS;
      favoredNodes[1] = tertiaryRS;
      return favoredNodes;
    }
  }
For regions that share the primary, avoid placing the secondary and tertiary on a same RS. Used
for generating new assignments for the primary/secondary/tertiary RegionServers
@return the map of regions to the servers the region-files should be hosted on
hbase-balancer/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodeAssignmentHelper.java