Search in sources :

Example 41 with MultiMap

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);
}
Also used : MultiMap(com.hazelcast.multimap.MultiMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 42 with MultiMap

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));
}
Also used : MultiMap(com.hazelcast.multimap.MultiMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 43 with MultiMap

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);
}
Also used : MultiMap(com.hazelcast.multimap.MultiMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 44 with MultiMap

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));
}
Also used : MultiMap(com.hazelcast.multimap.MultiMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 45 with MultiMap

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));
}
Also used : MultiMap(com.hazelcast.multimap.MultiMap) CountDownLatch(java.util.concurrent.CountDownLatch) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MultiMap (com.hazelcast.multimap.MultiMap)93 Test (org.junit.Test)93 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)92 QuickTest (com.hazelcast.test.annotation.QuickTest)92 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)11 TransactionContext (com.hazelcast.transaction.TransactionContext)8 TransactionalMultiMap (com.hazelcast.transaction.TransactionalMultiMap)8 CountDownLatch (java.util.concurrent.CountDownLatch)7 Collection (java.util.Collection)6 Set (java.util.Set)5 TreeSet (java.util.TreeSet)5 AssertTask (com.hazelcast.test.AssertTask)4 UUID (java.util.UUID)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 EntryAdapter (com.hazelcast.core.EntryAdapter)2 EntryEvent (com.hazelcast.core.EntryEvent)2 EntryListener (com.hazelcast.core.EntryListener)2 ArrayList (java.util.ArrayList)2 ClientConnectionRegistration (com.hazelcast.client.impl.spi.impl.listener.ClientConnectionRegistration)1 TestHazelcastFactory (com.hazelcast.client.test.TestHazelcastFactory)1