@Test public void testKeepRegionLoad() throws Exception { ServerName sn = ServerName.valueOf("test:8080", 100); int numClusterStatusToAdd = 20000; for (int i = 0; i < numClusterStatusToAdd; i++) { ServerLoad sl = mock(ServerLoad.class); RegionLoad rl = mock(RegionLoad.class); when(rl.getStores()).thenReturn(i); Map<byte[], RegionLoad> regionLoadMap = new TreeMap<byte[], RegionLoad>(Bytes.BYTES_COMPARATOR); regionLoadMap.put(Bytes.toBytes(REGION_KEY), rl); when(sl.getRegionsLoad()).thenReturn(regionLoadMap); ClusterStatus clusterStatus = mock(ClusterStatus.class); when(clusterStatus.getServers()).thenReturn(Arrays.asList(sn)); when(clusterStatus.getLoad(sn)).thenReturn(sl); loadBalancer.setClusterStatus(clusterStatus); } assertTrue(loadBalancer.loads.get(REGION_KEY) != null); assertTrue(loadBalancer.loads.get(REGION_KEY).size() == 15); Queue<RegionLoad> loads = loadBalancer.loads.get(REGION_KEY); int i = 0; while(loads.size() > 0) { RegionLoad rl = loads.remove(); assertEquals(i + (numClusterStatusToAdd - 15), rl.getStores()); i ++; } }
@Override public void setClusterStatus(ClusterStatus st) { super.setClusterStatus(st); regionFinder.setClusterStatus(st); updateRegionLoad(); for(CostFromRegionLoadFunction cost : regionLoadFunctions) { cost.setClusterStatus(st); } }
StochasticLoadBalancer extends BaseLoadBalancer { @Override public void setClusterStatus(ClusterStatus st) { super.setClusterStatus(st); regionFinder.setClusterStatus(st); updateRegionLoad(); for(CostFromRegionLoadFunction cost : regionLoadFunctions) { cost.setClusterStatus(st); } } }
StochasticLoadBalancer extends BaseLoadBalancer { @Override public void setClusterStatus(ClusterStatus st) { super.setClusterStatus(st); regionFinder.setClusterStatus(st); updateRegionLoad(); for(CostFromRegionLoadFunction cost : regionLoadFunctions) { cost.setClusterStatus(st); } }  }
StochasticLoadBalancer extends BaseLoadBalancer { @Override public void setClusterStatus(ClusterStatus st) { super.setClusterStatus(st); regionFinder.setClusterStatus(st); updateRegionLoad(); for(CostFromRegionLoadFunction cost : regionLoadFunctions) { cost.setClusterStatus(st); } }  @Override void setConf(Configuration conf); @Override void setClusterStatus(ClusterStatus st); @Override void setMasterServices(MasterServices masterServices); @Override List<RegionPlan> balanceCluster(Map<ServerName, List<HRegionInfo>> clusterState); }
StochasticLoadBalancer extends BaseLoadBalancer { @Override public void setClusterStatus(ClusterStatus st) { super.setClusterStatus(st); regionFinder.setClusterStatus(st); updateRegionLoad(); for(CostFromRegionLoadFunction cost : regionLoadFunctions) { cost.setClusterStatus(st); } }  @Override void setConf(Configuration conf); @Override void setClusterStatus(ClusterStatus st); @Override void setMasterServices(MasterServices masterServices); @Override List<RegionPlan> balanceCluster(Map<ServerName, List<HRegionInfo>> clusterState);  }