예제 #1
0
 public void testSetUpdatingToVersion() throws Exception {
   Ring ring = ZkRing.create(getZk(), coordinator, getRoot(), 1, null, 1);
   ring.markUpdateComplete();
   assertNull(ring.getUpdatingToVersionNumber());
   ring.setUpdatingToVersion(7);
   assertEquals(Integer.valueOf(7), ring.getUpdatingToVersionNumber());
 }
예제 #2
0
 public void testSetUpdatingToVersion() throws Exception {
   Ring rc = ZkRing.create(getZk(), getRoot(), 1, null, 1);
   rc.updateComplete();
   assertNull(rc.getUpdatingToVersionNumber());
   rc.setUpdatingToVersion(7);
   assertEquals(Integer.valueOf(7), rc.getUpdatingToVersionNumber());
 }
예제 #3
0
 public void testGetRingState() throws Exception {
   Ring ring = ZkRing.create(getZk(), coordinator, getRoot(), 1, null, 1);
   assertEquals(RingState.CLOSED, ring.getState());
   ring.setState(RingState.OPEN);
   assertEquals(RingState.OPEN, ring.getState());
   ring = new ZkRing(getZk(), ZkPath.append(getRoot(), "ring-1"), null, coordinator);
   assertEquals(RingState.OPEN, ring.getState());
 }
예제 #4
0
 public void testGetRingState() throws Exception {
   Ring rc = ZkRing.create(getZk(), getRoot(), 1, null, 1);
   assertEquals(RingState.DOWN, rc.getState());
   rc.setState(RingState.UP);
   assertEquals(RingState.UP, rc.getState());
   rc = new ZkRing(getZk(), getRoot() + "/ring-1", null);
   assertEquals(RingState.UP, rc.getState());
 }
예제 #5
0
 public void testRingStateListener() throws Exception {
   Ring ring = ZkRing.create(getZk(), coordinator, getRoot(), 1, null, 1);
   MockListener mockListener = new MockListener();
   ring.setStateChangeListener(mockListener);
   synchronized (mockListener) {
     mockListener.wait(1000);
   }
   assertNull(mockListener.calledWith);
   ring.setState(RingState.CLOSED);
   synchronized (mockListener) {
     mockListener.wait(1000);
   }
   assertEquals(ring, mockListener.calledWith);
 }
예제 #6
0
 public void testRingStateListener() throws Exception {
   Ring rc = ZkRing.create(getZk(), getRoot(), 1, null, 1);
   MockListener mockListener = new MockListener();
   rc.setStateChangeListener(mockListener);
   synchronized (mockListener) {
     mockListener.wait(1000);
   }
   assertNull(mockListener.calledWith);
   rc.setState(RingState.DOWN);
   synchronized (mockListener) {
     mockListener.wait(1000);
   }
   assertEquals(rc, mockListener.calledWith);
 }