Search in sources :

Example 11 with LockGuard

use of com.hazelcast.internal.util.LockGuard in project hazelcast by hazelcast.

the class ClusterStateManagerTest method test_lockClusterState_extendLease.

@Test
public void test_lockClusterState_extendLease() throws Exception {
    Address initiator = newAddress();
    clusterStateManager.lockClusterState(ClusterStateChange.from(FROZEN), initiator, TXN, 10000, MEMBERLIST_VERSION, PARTITION_STAMP);
    clusterStateManager.lockClusterState(ClusterStateChange.from(FROZEN), initiator, TXN, TimeUnit.DAYS.toMillis(1), MEMBERLIST_VERSION, PARTITION_STAMP);
    LockGuard stateLock = clusterStateManager.getStateLock();
    assertTrue(Clock.currentTimeMillis() + TimeUnit.HOURS.toMillis(12) < stateLock.getLockExpiryTime());
}
Also used : Address(com.hazelcast.cluster.Address) InetAddress(java.net.InetAddress) LockGuard(com.hazelcast.internal.util.LockGuard) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 12 with LockGuard

use of com.hazelcast.internal.util.LockGuard in project hazelcast by hazelcast.

the class ClusterStateManagerTest method test_changeLocalClusterState_success.

@Test
public void test_changeLocalClusterState_success() throws Exception {
    ClusterStateChange newState = ClusterStateChange.from(FROZEN);
    Address initiator = newAddress();
    clusterStateManager.lockClusterState(newState, initiator, TXN, 10000, MEMBERLIST_VERSION, PARTITION_STAMP);
    clusterStateManager.commitClusterState(newState, initiator, TXN);
    assertEquals(newState.getNewState(), clusterStateManager.getState());
    LockGuard stateLock = clusterStateManager.getStateLock();
    assertFalse(stateLock.isLocked());
}
Also used : Address(com.hazelcast.cluster.Address) InetAddress(java.net.InetAddress) LockGuard(com.hazelcast.internal.util.LockGuard) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

LockGuard (com.hazelcast.internal.util.LockGuard)12 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 TransactionException (com.hazelcast.transaction.TransactionException)4 Test (org.junit.Test)4 Address (com.hazelcast.cluster.Address)3 InetAddress (java.net.InetAddress)3 ClusterState (com.hazelcast.cluster.ClusterState)2 Version (com.hazelcast.version.Version)2