use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testLockTTLExpired_whenLockedBySelf.
@Test
public void testLockTTLExpired_whenLockedBySelf() throws Exception {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "Key";
mm.lock(key);
mm.lock(key, 1, TimeUnit.SECONDS);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertFalse(mm.isLocked(key));
}
});
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testTryLockWaitingOnLockedKey_thenKeyUnlockedByOtherThread.
@Test
public void testTryLockWaitingOnLockedKey_thenKeyUnlockedByOtherThread() throws Exception {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "keyZ";
mm.lock(key);
final CountDownLatch tryLockReturnsTrue = new CountDownLatch(1);
new Thread() {
public void run() {
try {
if (mm.tryLock(key, 10, TimeUnit.SECONDS)) {
tryLockReturnsTrue.countDown();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start();
mm.unlock(key);
assertOpenEventually(tryLockReturnsTrue);
assertTrue(mm.isLocked(key));
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapListenerStressTest method listenerAddStressTest.
@Test
public void listenerAddStressTest() throws InterruptedException {
final PutItemsThread[] putThreads = new PutItemsThread[NUMBER_OF_CLIENTS * THREADS_PER_CLIENT];
int idx = 0;
for (int i = 0; i < NUMBER_OF_CLIENTS; i++) {
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
for (int j = 0; j < THREADS_PER_CLIENT; j++) {
PutItemsThread t = new PutItemsThread(client);
putThreads[idx++] = t;
}
}
for (int i = 0; i < putThreads.length; i++) {
putThreads[i].start();
}
MultiMap multiMap = server.getMultiMap(MAP_NAME);
assertJoinable(MAX_SECONDS, putThreads);
final int expectedSize = PutItemsThread.MAX_ITEMS * putThreads.length;
assertEquals(expectedSize, multiMap.size());
assertReceivedEventsSize(expectedSize, putThreads);
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testLock.
@Test
public void testLock() throws Exception {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "Key";
mm.lock(key);
assertTrue(mm.isLocked(key));
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapTest method testRemove_whenKeyNotExist.
@Test
public void testRemove_whenKeyNotExist() {
final MultiMap mm = client.getMultiMap(randomString());
Collection coll = mm.remove("NOT_THERE");
assertTrue(coll.isEmpty());
}
Aggregations