Пример #1
0
  public void testCreate() throws Exception {
    ZkRing ring = ZkRing.create(getZk(), coordinator, ring_group_root, 1, null, 1);

    assertEquals("ring number", 1, ring.getRingNumber());
    assertNull("version number", ring.getCurrentVersionNumber());
    assertEquals("updating to version", Integer.valueOf(1), ring.getUpdatingToVersionNumber());
    assertEquals("number of hosts", 0, ring.getHosts().size());
    assertEquals("initial state", RingState.CLOSED, ring.getState());
    ring.close();
  }
Пример #2
0
  public void testUpdatingSemantics() throws Exception {
    ZkRing ring = ZkRing.create(getZk(), coordinator, ring_group_root, 1, null, 1);

    assertTrue("should be updating", Rings.isUpdatePending(ring));
    assertNull("current version", ring.getCurrentVersionNumber());
    assertEquals(
        "updating_to_version number", Integer.valueOf(1), ring.getUpdatingToVersionNumber());

    ring.markUpdateComplete();

    assertFalse("updating", Rings.isUpdatePending(ring));
    assertEquals("current version", Integer.valueOf(1), ring.getCurrentVersionNumber());
    assertNull("updating to version", ring.getUpdatingToVersionNumber());

    ring.setUpdatingToVersion(7);
    assertTrue("should be updating", Rings.isUpdatePending(ring));
    assertEquals("current version", Integer.valueOf(1), ring.getCurrentVersionNumber());
    assertEquals(
        "updating_to_version number", Integer.valueOf(7), ring.getUpdatingToVersionNumber());

    ring.close();
  }