@Override
    protected float getRegionCacheRatioOnRegionServer(int region, int regionServerIndex) {
      float cacheRatio = 0.0f;

      // Get the cache ratio if the region is currently hosted on this server
      if (regionServerIndex == regionIndexToServerIndex[region]) {
        return regionServerCacheRatio.get(new Pair<>(region, regionServerIndex));
      }

      // Region is not currently hosted on this server. Check if the region was cached on this
      // server earlier. This can happen when the server was shutdown and the cache was persisted.
      // Search using the index name and server name and not the index id and server id as these
      // ids may change when a server is marked as dead or a new server is added.
      String regionEncodedName = regions[region].getEncodedName();
      ServerName serverName = servers[regionServerIndex];
      if (
        regionCacheRatioOnOldServerMap != null
          && regionCacheRatioOnOldServerMap.containsKey(regionEncodedName)
      ) {
        Pair<ServerName, Float> serverCacheRatio =
          regionCacheRatioOnOldServerMap.get(regionEncodedName);
        if (ServerName.isSameAddress(serverName, serverCacheRatio.getFirst())) {
          cacheRatio = serverCacheRatio.getSecond();
          regionCacheRatioOnOldServerMap.remove(regionEncodedName);
        }
      }
      return cacheRatio;
    }
Data set to testCacheCost: [test][0][0] = mapping of server to number of regions it hosts
[test][region + 1][0] = server that region is hosted on [test][region + 1][server + 1] = size
of region cached on server
hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestCacheAwareLoadBalancerCostFunctions.java