use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testUnlock_whenLockedByOther.
@Test(expected = IllegalMonitorStateException.class)
public void testUnlock_whenLockedByOther() throws Exception {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "key";
mm.lock(key);
UnLockThread t = new UnLockThread(mm, key);
t.start();
assertJoinable(t);
throw t.exception;
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testForceUnlock_whenKeyLockedByOther.
@Test
public void testForceUnlock_whenKeyLockedByOther() throws Exception {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "key";
mm.lock(key);
final CountDownLatch forceUnlock = new CountDownLatch(1);
new Thread() {
public void run() {
mm.forceUnlock(key);
forceUnlock.countDown();
}
}.start();
assertOpenEventually(forceUnlock);
assertFalse(mm.isLocked(key));
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testTryLockLeaseTime_whenLockAcquiredByOther.
@Test(timeout = 60000)
public void testTryLockLeaseTime_whenLockAcquiredByOther() throws InterruptedException {
final MultiMap multiMap = getMultiMapForLock();
final String key = randomString();
Thread thread = new Thread() {
public void run() {
multiMap.lock(key);
}
};
thread.start();
thread.join();
boolean isLocked = multiMap.tryLock(key, 1000, TimeUnit.MILLISECONDS, 1000, TimeUnit.MILLISECONDS);
Assert.assertFalse(isLocked);
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testUnlock_whenNotLocked.
@Test(expected = IllegalMonitorStateException.class)
public void testUnlock_whenNotLocked() throws Exception {
final MultiMap mm = client.getMultiMap(randomString());
mm.unlock("NOT_LOCKED");
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testUnlock_whenRentrantlyLockedBySelf.
@Test
public void testUnlock_whenRentrantlyLockedBySelf() throws Exception {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "key";
mm.lock(key);
mm.lock(key);
mm.unlock(key);
assertTrue(mm.isLocked(key));
}
Aggregations