Search in sources :

Example 91 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class ListenerLeakTestSmartRouting method testMapEntryListeners.

@Test
public void testMapEntryListeners() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = hazelcastFactory.newHazelcastClient();
    IMap map = client.getMap(randomString());
    String id = map.addEntryListener(mock(MapListener.class), false);
    Collection<ClientEventRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(map.removeEntryListener(id));
    assertNoLeftOver(nodes, client, id, registrations);
}
Also used : IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapListener(com.hazelcast.map.listener.MapListener) ClientEventRegistration(com.hazelcast.client.spi.impl.listener.ClientEventRegistration) Node(com.hazelcast.instance.Node) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 92 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class ListenerLeakTestSmartRouting method testReplicatedMapListeners.

@Test
public void testReplicatedMapListeners() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = hazelcastFactory.newHazelcastClient();
    ReplicatedMap<Object, Object> replicatedMap = client.getReplicatedMap(randomString());
    String id = replicatedMap.addEntryListener(mock(EntryListener.class));
    Collection<ClientEventRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(replicatedMap.removeEntryListener(id));
    assertNoLeftOver(nodes, client, id, registrations);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientEventRegistration(com.hazelcast.client.spi.impl.listener.ClientEventRegistration) Node(com.hazelcast.instance.Node) EntryListener(com.hazelcast.core.EntryListener) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 93 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class ListenerLeakTestSmartRouting method testMultiMapEntryListeners.

@Test
public void testMultiMapEntryListeners() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = hazelcastFactory.newHazelcastClient();
    MultiMap multiMap = client.getMultiMap(randomString());
    String id = multiMap.addEntryListener(mock(EntryListener.class), false);
    Collection<ClientEventRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(multiMap.removeEntryListener(id));
    assertNoLeftOver(nodes, client, id, registrations);
}
Also used : MultiMap(com.hazelcast.core.MultiMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientEventRegistration(com.hazelcast.client.spi.impl.listener.ClientEventRegistration) Node(com.hazelcast.instance.Node) EntryListener(com.hazelcast.core.EntryListener) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 94 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class ListenerLeakTestSupport method createNodes.

protected Collection<Node> createNodes() {
    int NODE_COUNT = 3;
    Collection<Node> nodes = new ArrayList<Node>(3);
    for (int i = 0; i < NODE_COUNT; i++) {
        HazelcastInstance hazelcast = hazelcastFactory.newHazelcastInstance();
        nodes.add(getNode(hazelcast));
    }
    return nodes;
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Node(com.hazelcast.instance.Node) ArrayList(java.util.ArrayList) ClientEndpoint(com.hazelcast.client.ClientEndpoint)

Example 95 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class ListenerLeakTestNonSmartRouting method testMapEntryListeners.

@Test
public void testMapEntryListeners() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = newHazelcastClient();
    IMap map = client.getMap(randomString());
    String id = map.addEntryListener(mock(MapListener.class), false);
    Collection<ClientEventRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(map.removeEntryListener(id));
    assertNoLeftOver(nodes, client, id, registrations);
}
Also used : IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapListener(com.hazelcast.map.listener.MapListener) ClientEventRegistration(com.hazelcast.client.spi.impl.listener.ClientEventRegistration) Node(com.hazelcast.instance.Node) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Node (com.hazelcast.instance.Node)131 HazelcastInstance (com.hazelcast.core.HazelcastInstance)60 Test (org.junit.Test)50 QuickTest (com.hazelcast.test.annotation.QuickTest)45 ParallelTest (com.hazelcast.test.annotation.ParallelTest)42 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)21 ClientEventRegistration (com.hazelcast.client.spi.impl.listener.ClientEventRegistration)18 Address (com.hazelcast.nio.Address)17 Config (com.hazelcast.config.Config)14 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)13 ILogger (com.hazelcast.logging.ILogger)10 Data (com.hazelcast.nio.serialization.Data)10 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)10 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)9 StringUtil.bytesToString (com.hazelcast.util.StringUtil.bytesToString)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 ClusterService (com.hazelcast.internal.cluster.ClusterService)7 SerializationService (com.hazelcast.spi.serialization.SerializationService)7 ItemListener (com.hazelcast.core.ItemListener)6 Operation (com.hazelcast.spi.Operation)6