コード例 #1
0
 public void testSameValues2() {
   Random rnd = new Random();
   for (int i = 0; i < 10000; i++) {
     byte[] key = new byte[i + 1];
     rnd.nextBytes(key);
     assertEquals(vOld.getServer(key), vNew.getServer(key), "int value is " + i);
   }
 }
コード例 #2
0
  @BeforeTest
  public void init() {

    int hashSpace = Integer.MAX_VALUE;
    int share = hashSpace / PHISYCAL_NODES;
    int virtualNodesSpan = share / VIRTUAL_NODES - 1;

    ch = new LinkedHashMap<SocketAddress, Set<Integer>>();
    for (int i = 0; i < PHISYCAL_NODES; i++) {
      Set<Integer> virtualNodes = new HashSet<Integer>();
      for (int j = 0; j < VIRTUAL_NODES; j++) {
        virtualNodes.add(share * i + virtualNodesSpan * j);
      }
      ch.put(new InetSocketAddress(i), virtualNodes);
    }
    vOld.init(ch, 2, Integer.MAX_VALUE);
    vNew.init(ch, 2, Integer.MAX_VALUE);
  }
コード例 #3
0
 public void testIsolatedValue2() {
   byte[] key = String.valueOf(7).getBytes();
   SocketAddress newOne = vNew.getServer(key);
   SocketAddress oldOne = vOld.getServer(key);
   assertEquals(oldOne, newOne);
 }
コード例 #4
0
 public void testSameValues() {
   for (int i = 0; i < 1000; i++) {
     byte[] key = String.valueOf(i).getBytes();
     assertEquals(vOld.getServer(key), vNew.getServer(key), "int value is " + i);
   }
 }