@Test public void testRandomizer() { for(int [] mockCluster : clusterStateMocks) { if (mockCluster.length < 5) continue; Map<HServerInfo, List<HRegionInfo>> servers = mockClusterServers(mockCluster); for (Map.Entry<HServerInfo, List<HRegionInfo>> e: servers.entrySet()) { List<HRegionInfo> original = e.getValue(); if (original.size() < 5) continue; boolean same = true; for (int i = 0; i < 10 && same; i++) { List<HRegionInfo> copy = new ArrayList<HRegionInfo>(original); System.out.println("Randomizing before " + copy.size()); for (HRegionInfo hri: copy) { System.out.println(hri.getEncodedName()); } List<HRegionInfo> randomized = LoadBalancer.randomize(copy); System.out.println("Randomizing after " + randomized.size()); for (HRegionInfo hri: randomized) { System.out.println(hri.getEncodedName()); } if (original.equals(randomized)) continue; same = false; break; } assertFalse(same); } } }
static List<HRegionInfo> randomize(final List<HRegionInfo> regions) { Collections.shuffle(regions, RANDOM); return regions; }
LoadBalancer { static List<HRegionInfo> randomize(final List<HRegionInfo> regions) { Collections.shuffle(regions, RANDOM); return regions; } }
LoadBalancer { static List<HRegionInfo> randomize(final List<HRegionInfo> regions) { Collections.shuffle(regions, RANDOM); return regions; } LoadBalancer(Configuration conf); }
LoadBalancer { static List<HRegionInfo> randomize(final List<HRegionInfo> regions) { Collections.shuffle(regions, RANDOM); return regions; } 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 { static List<HRegionInfo> randomize(final List<HRegionInfo> regions) { Collections.shuffle(regions, RANDOM); return regions; } 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);  }