Example #1
0
 public void testConsistentHash_probabilities() {
   AtomicLongMap<Integer> map = AtomicLongMap.create();
   Random r = new Random(9);
   for (int i = 0; i < ITERS; i++) {
     countRemaps(r.nextLong(), map);
   }
   for (int shard = 2; shard <= MAX_SHARDS; shard++) {
     // Rough: don't exceed 1.2x the expected number of remaps by more than 20
     assertTrue(map.get(shard) <= 1.2 * ITERS / shard + 20);
   }
 }