private float getOldLocality(ServerName newServer, byte[] regionName,
    Map<ServerName, ServerMetrics> oldServers) {
    ServerMetrics serverMetrics = oldServers.get(newServer);
    if (serverMetrics == null) {
      return -1f;
    }
    RegionMetrics regionMetrics = serverMetrics.getRegionMetrics().get(regionName);
    if (regionMetrics == null) {
      return -1f;
    }

    return regionMetrics.getDataLocality();
  }
If locality for a region has changed, that pretty certainly means our cache is out of date.
Compare oldStatus and newStatus, refreshing any regions which have moved or changed locality.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionHDFSBlockLocationFinder.java