List of usage examples for com.google.common.collect HashBiMap put
@Override
public V put(@Nullable K key, @Nullable V value)
From source file:org.apache.hadoop.hbase.extended.loadbalance.strategies.hotspot.HotSpotLoadBalancer.java
private double addRegionsToCompleteMap(Map<String, HRegionInfo> regionNameRegionInfoMap, ServerName serverName, NavigableMap<HotSpotServerAndLoad, List<HotSpotRegionLoad>> serversByLoad, Map<String, RegionLoad> regionalLoadMapforServer, HashBiMap<HRegionInfo, HotSpotRegionLoad> allRegionsLoadBiMap) { double loadAccumulator = 0.0; List<HotSpotRegionLoad> modRegionLoadList = new ArrayList<HotSpotRegionLoad>(); boolean isHotspot = false; HRegionInfo regionInfo = null;// www . jav a2s . c o m TreeMap<HotSpotRegionLoad, HRegionInfo> regionLoadMap = new TreeMap<HotSpotRegionLoad, HRegionInfo>( HotSpotRegionLoad.DESC_LOAD); for (Map.Entry<String, RegionLoad> loadItem : regionalLoadMapforServer.entrySet()) { regionInfo = regionNameRegionInfoMap.get(loadItem.getKey()); if (regionInfo == null) { String message = "######################## as regionInfo is null from regionNameRegionInfoMap for the region name =" + loadItem.getKey() + " determined from regionNameRegionInfoMap. The rest of the balancing is useless. " + "We need to return to the assignment manager."; LOG.warn(message); } else { HotSpotRegionLoad readHotSpotRegionLoad = getHotSpotRegionLoadInstance(loadItem, this.divideFactor); LOG.debug("######################## loadItem = " + loadItem + "\n readHotSpotRegionLoad= " + readHotSpotRegionLoad); regionLoadMap.put(readHotSpotRegionLoad, regionInfo); loadAccumulator += readHotSpotRegionLoad.getLoad(); LOG.debug("######################## current loadAccumulator=" + loadAccumulator); modRegionLoadList.add(readHotSpotRegionLoad); allRegionsLoadBiMap.put(regionInfo, readHotSpotRegionLoad); } } // iterate over regionLoadMap and find if the top x% have y% load isHotspot = isHotSpot(regionLoadMap, modRegionLoadList, loadAccumulator); HotSpotServerAndLoad msl = new HotSpotServerAndLoad(serverName, loadAccumulator, isHotspot); Collections.sort(modRegionLoadList, HotSpotRegionLoad.DESC_LOAD); serversByLoad.put(msl, modRegionLoadList); return loadAccumulator; }