Search in sources :

Example 66 with Node

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

the class ListenerLeakTest method testDistributedObjectListeners.

@Test
public void testDistributedObjectListeners() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = newHazelcastClient();
    UUID id = client.addDistributedObjectListener(mock(DistributedObjectListener.class));
    Collection<ClientConnectionRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(client.removeDistributedObjectListener(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) DistributedObjectListener(com.hazelcast.core.DistributedObjectListener) 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 67 with Node

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

the class ListenerLeakTest method testTopicMessageListener.

@Test
public void testTopicMessageListener() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = newHazelcastClient();
    ITopic<Object> topic = client.getTopic(randomString());
    UUID id = topic.addMessageListener(mock(MessageListener.class));
    Collection<ClientConnectionRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(topic.removeMessageListener(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) MessageListener(com.hazelcast.topic.MessageListener) 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 68 with Node

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

the class ListenerLeakTest method testMapPartitionLostListeners.

@Test
public void testMapPartitionLostListeners() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = newHazelcastClient();
    IMap map = client.getMap(randomString());
    UUID id = map.addPartitionLostListener(mock(MapPartitionLostListener.class));
    Collection<ClientConnectionRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(map.removePartitionLostListener(id));
    assertNoLeftOver(nodes, client, id, registrations);
}
Also used : IMap(com.hazelcast.map.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapPartitionLostListener(com.hazelcast.map.listener.MapPartitionLostListener) Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) 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 69 with Node

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

the class ListenerLeakTest method testListListeners.

@Test
public void testListListeners() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = newHazelcastClient();
    IList<Object> list = client.getList(randomString());
    UUID id = list.addItemListener(mock(ItemListener.class), false);
    Collection<ClientConnectionRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(list.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 70 with Node

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

the class NodeQueryCacheContext method flushPublishersOnNodeShutdown.

/**
 * This is a best effort approach; there is no guarantee that events in publishers internal buffers will be fired,
 * {@link EventService} can drop them.
 */
private void flushPublishersOnNodeShutdown() {
    Node node = ((NodeEngineImpl) this.nodeEngine).getNode();
    LifecycleServiceImpl lifecycleService = node.hazelcastInstance.getLifecycleService();
    lifecycleService.addLifecycleListener(event -> {
        if (SHUTTING_DOWN == event.getState()) {
            publisherContext.flush();
        }
    });
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Node(com.hazelcast.instance.impl.Node) LifecycleServiceImpl(com.hazelcast.instance.impl.LifecycleServiceImpl)

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