@Test public void testImmediateAssignment() throws Exception { for(int [] mock : regionsAndServersMocks) { LOG.debug("testImmediateAssignment with " + mock[0] + " regions and " + mock[1] + " servers"); List<HRegionInfo> regions = randomRegions(mock[0]); List<HServerInfo> servers = randomServers(mock[1], 0); Map<HRegionInfo,HServerInfo> assignments = LoadBalancer.immediateAssignment(regions, servers); assertImmediateAssignment(regions, servers, assignments); returnRegions(regions); returnServers(servers); } }
public static Map<HRegionInfo,HServerInfo> immediateAssignment( List<HRegionInfo> regions, List<HServerInfo> servers) { Map<HRegionInfo,HServerInfo> assignments = new TreeMap<HRegionInfo,HServerInfo>(); for(HRegionInfo region : regions) { assignments.put(region, servers.get(RANDOM.nextInt(servers.size()))); } return assignments; }
LoadBalancer { public static Map<HRegionInfo,HServerInfo> immediateAssignment( List<HRegionInfo> regions, List<HServerInfo> servers) { Map<HRegionInfo,HServerInfo> assignments = new TreeMap<HRegionInfo,HServerInfo>(); for(HRegionInfo region : regions) { assignments.put(region, servers.get(RANDOM.nextInt(servers.size()))); } return assignments; } }
LoadBalancer { public static Map<HRegionInfo,HServerInfo> immediateAssignment( List<HRegionInfo> regions, List<HServerInfo> servers) { Map<HRegionInfo,HServerInfo> assignments = new TreeMap<HRegionInfo,HServerInfo>(); for(HRegionInfo region : regions) { assignments.put(region, servers.get(RANDOM.nextInt(servers.size()))); } return assignments; } LoadBalancer(Configuration conf); }
LoadBalancer { public static Map<HRegionInfo,HServerInfo> immediateAssignment( List<HRegionInfo> regions, List<HServerInfo> servers) { Map<HRegionInfo,HServerInfo> assignments = new TreeMap<HRegionInfo,HServerInfo>(); for(HRegionInfo region : regions) { assignments.put(region, servers.get(RANDOM.nextInt(servers.size()))); } return assignments; } LoadBalancer(Configuration conf); List<RegionPlan> balanceCluster(
      Map<HServerInfo,List<HRegionInfo>> clusterState); static Map<HServerInfo,List<HRegionInfo>> roundRobinAssignment(
      List<HRegionInfo> regions, List<HServerInfo> servers); static Map<HServerInfo, List<HRegionInfo>> retainAssignment(
      Map<HRegionInfo, HServerAddress> regions, List<HServerInfo> servers); static Map<HRegionInfo,HServerInfo> immediateAssignment(
      List<HRegionInfo> regions, List<HServerInfo> servers); static HServerInfo randomAssignment(List<HServerInfo> servers); }
LoadBalancer { public static Map<HRegionInfo,HServerInfo> immediateAssignment( List<HRegionInfo> regions, List<HServerInfo> servers) { Map<HRegionInfo,HServerInfo> assignments = new TreeMap<HRegionInfo,HServerInfo>(); for(HRegionInfo region : regions) { assignments.put(region, servers.get(RANDOM.nextInt(servers.size()))); } return assignments; } LoadBalancer(Configuration conf); List<RegionPlan> balanceCluster(
      Map<HServerInfo,List<HRegionInfo>> clusterState); static Map<HServerInfo,List<HRegionInfo>> roundRobinAssignment(
      List<HRegionInfo> regions, List<HServerInfo> servers); static Map<HServerInfo, List<HRegionInfo>> retainAssignment(
      Map<HRegionInfo, HServerAddress> regions, List<HServerInfo> servers); static Map<HRegionInfo,HServerInfo> immediateAssignment(
      List<HRegionInfo> regions, List<HServerInfo> servers); static HServerInfo randomAssignment(List<HServerInfo> servers);  }