private void assertLockedBy(Address initiator) { assertEquals(IN_TRANSITION, clusterStateManager.getState()); ClusterStateLock stateLock = clusterStateManager.getStateLock(); assertTrue(stateLock.isLocked()); assertEquals(TXN, stateLock.getTransactionId()); assertEquals(initiator, stateLock.getLockOwner()); }
@Test public void test_lockClusterState_getLockExpiryTime() throws Exception { final Address initiator = newAddress(); clusterStateManager.lockClusterState(FROZEN, initiator, TXN, TimeUnit.DAYS.toMillis(1), 0); final ClusterStateLock stateLock = clusterStateManager.getStateLock(); assertTrue( Clock.currentTimeMillis() + TimeUnit.HOURS.toMillis(12) < stateLock.getLockExpiryTime()); }
@Test public void test_changeLocalClusterState_success() throws Exception { final ClusterState newState = FROZEN; final Address initiator = newAddress(); clusterStateManager.lockClusterState(newState, initiator, TXN, 10000, 0); clusterStateManager.commitClusterState(newState, initiator, TXN); assertEquals(newState, clusterStateManager.getState()); final ClusterStateLock stateLock = clusterStateManager.getStateLock(); assertFalse(stateLock.isLocked()); }