public synchronized void updateFavoredNodes(Map<RegionInfo, List<ServerName>> regionFNMap)
    throws IOException {
    Map<RegionInfo, List<ServerName>> regionToFavoredNodes = new HashMap<>();
    for (Map.Entry<RegionInfo, List<ServerName>> entry : regionFNMap.entrySet()) {
      RegionInfo regionInfo = entry.getKey();
      List<ServerName> servers = entry.getValue();

      /*
       * None of the following error conditions should happen. If it does, there is an issue with
       * favored nodes generation or the regions its called on.
       */
      if (servers.size() != Sets.newHashSet(servers).size()) {
        throw new IOException("Duplicates found: " + servers);
      }

      if (!isFavoredNodeApplicable(regionInfo)) {
        throw new IOException("Can't update FN for a un-applicable region: "
          + regionInfo.getRegionNameAsString() + " with " + servers);
      }

      if (servers.size() != FAVORED_NODES_NUM) {
        throw new IOException(
          "At least " + FAVORED_NODES_NUM + " favored nodes should be present for region : "
            + regionInfo.getEncodedName() + " current FN servers:" + servers);
      }

      List<ServerName> serversWithNoStartCodes = Lists.newArrayList();
      for (ServerName sn : servers) {
        if (sn.getStartcode() == NON_STARTCODE) {
          serversWithNoStartCodes.add(sn);
        } else {
          serversWithNoStartCodes
            .add(ServerName.valueOf(sn.getHostname(), sn.getPort(), NON_STARTCODE));
        }
      }
      regionToFavoredNodes.put(regionInfo, serversWithNoStartCodes);
    }

    // Lets do a bulk update to meta since that reduces the RPC's
    FavoredNodeAssignmentHelper.updateMetaWithFavoredNodesInfo(regionToFavoredNodes,
      provider.getConnection());
    deleteFavoredNodesForRegions(regionToFavoredNodes.keySet());

    for (Map.Entry<RegionInfo, List<ServerName>> entry : regionToFavoredNodes.entrySet()) {
      RegionInfo regionInfo = entry.getKey();
      List<ServerName> serversWithNoStartCodes = entry.getValue();
      globalFavoredNodesAssignmentPlan.updateFavoredNodesMap(regionInfo, serversWithNoStartCodes);
      addToReplicaLoad(regionInfo, serversWithNoStartCodes);
    }
  }
This should only be used when sending FN information to the region servers. Instead of sending
the region server port, we use the datanode port. This helps in centralizing the DN port logic
in Master. The RS uses the port from the favored node list as hints.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodesManager.java