use of com.hazelcast.multimap.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.multimap.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testTryLock.
@Test
public void testTryLock() {
final MultiMap mm = client.getMultiMap(randomString());
Object key = "key";
assertTrue(mm.tryLock(key));
}
use of com.hazelcast.multimap.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testLockTTL_whenZeroTimeout.
@Test(expected = IllegalArgumentException.class)
public void testLockTTL_whenZeroTimeout() {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "Key";
mm.lock(key, 0, TimeUnit.SECONDS);
}
use of com.hazelcast.multimap.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testLock.
@Test
public void testLock() {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "Key";
mm.lock(key);
assertTrue(mm.isLocked(key));
}
use of com.hazelcast.multimap.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testForceUnlock_whenKeyLockedTwiceByOther.
@Test
public void testForceUnlock_whenKeyLockedTwiceByOther() {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "key";
mm.lock(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));
}
Aggregations