Search in sources :

Example 76 with Node

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

the class ListenerLeakTest method testListenerLeakOnMember_whenClientDestroyed.

@Test
public void testListenerLeakOnMember_whenClientDestroyed() {
    Collection<Node> nodes = createNodes();
    for (int i = 0; i < 100; i++) {
        newHazelcastClient().shutdown();
    }
    assertTrueEventually(() -> {
        for (Node node : nodes) {
            assertEquals(0, node.getClientEngine().getClusterListenerService().getClusterListeningEndpoints().size());
        }
    });
}
Also used : Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) ClientEndpoint(com.hazelcast.client.impl.ClientEndpoint) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 77 with Node

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

the class ListenerLeakTest method testReplicatedMapListeners.

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

Example 78 with Node

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

the class ListenerLeakTest method testQueueListeners.

@Test
public void testQueueListeners() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = newHazelcastClient();
    IQueue<Object> queue = client.getQueue(randomString());
    UUID id = queue.addItemListener(mock(ItemListener.class), false);
    Collection<ClientConnectionRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(queue.removeItemListener(id));
    assertNoLeftOver(nodes, client, id, registrations);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) ItemListener(com.hazelcast.collection.ItemListener) UUID(java.util.UUID) ClientConnectionRegistration(com.hazelcast.client.impl.spi.impl.listener.ClientConnectionRegistration) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 79 with Node

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

the class ListenerLeakTest method testSetListeners.

@Test
public void testSetListeners() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = newHazelcastClient();
    ISet<Object> set = client.getSet(randomString());
    UUID id = set.addItemListener(mock(ItemListener.class), false);
    Collection<ClientConnectionRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(set.removeItemListener(id));
    assertNoLeftOver(nodes, client, id, registrations);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) ItemListener(com.hazelcast.collection.ItemListener) UUID(java.util.UUID) ClientConnectionRegistration(com.hazelcast.client.impl.spi.impl.listener.ClientConnectionRegistration) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 80 with Node

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

the class MapInfoCollector method initMapConfigs.

private void initMapConfigs(Node node) {
    Collection<DistributedObject> objects = node.hazelcastInstance.getDistributedObjects();
    mapConfigs = new HashMap<>();
    objects.stream().filter(obj -> obj.getServiceName().equals(MapService.SERVICE_NAME)).forEach(obj -> {
        MapConfig config = node.getConfig().findMapConfig(obj.getName());
        if (config != null) {
            mapConfigs.put(obj.getName(), config);
        }
    });
}
Also used : EvictionPolicy(com.hazelcast.config.EvictionPolicy) Predicate(java.util.function.Predicate) Collection(java.util.Collection) InMemoryFormat(com.hazelcast.config.InMemoryFormat) HotRestartConfig(com.hazelcast.config.HotRestartConfig) HashMap(java.util.HashMap) MapService(com.hazelcast.map.impl.MapService) Node(com.hazelcast.instance.impl.Node) MapConfig(com.hazelcast.config.MapConfig) Objects(java.util.Objects) DistributedObject(com.hazelcast.core.DistributedObject) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) MapStoreConfig(com.hazelcast.config.MapStoreConfig) ToLongFunction(java.util.function.ToLongFunction) LocalMapStats(com.hazelcast.map.LocalMapStats) DistributedObject(com.hazelcast.core.DistributedObject) MapConfig(com.hazelcast.config.MapConfig)

Aggregations

Node (com.hazelcast.instance.impl.Node)144 Accessors.getNode (com.hazelcast.test.Accessors.getNode)84 HazelcastInstance (com.hazelcast.core.HazelcastInstance)68 Test (org.junit.Test)60 QuickTest (com.hazelcast.test.annotation.QuickTest)57 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)44 Config (com.hazelcast.config.Config)22 Address (com.hazelcast.cluster.Address)20 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)19 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)13 UUID (java.util.UUID)13 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)12 SerializationService (com.hazelcast.internal.serialization.SerializationService)12 ILogger (com.hazelcast.logging.ILogger)10 MapService (com.hazelcast.map.impl.MapService)10 ClientConnectionRegistration (com.hazelcast.client.impl.spi.impl.listener.ClientConnectionRegistration)9 Operation (com.hazelcast.spi.impl.operationservice.Operation)9 HashMap (java.util.HashMap)9 Data (com.hazelcast.internal.serialization.Data)8 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)8