use of com.hazelcast.client.impl.spi.impl.listener.ClientConnectionRegistration in project hazelcast by hazelcast.
the class AbstractListenersOnReconnectTest method validateRegistrations.
private void validateRegistrations(final int clusterSize, final UUID registrationId, final HazelcastClientInstanceImpl clientInstanceImpl) {
final boolean smartRouting = clientInstanceImpl.getClientConfig().getNetworkConfig().isSmartRouting();
assertTrueEventually(() -> {
int size = smartRouting ? clusterSize : 1;
Map<Connection, ClientConnectionRegistration> registrations = getClientEventRegistrations(client, registrationId);
assertEquals(size, registrations.size());
if (smartRouting) {
Collection<Member> members = clientInstanceImpl.getClientClusterService().getMemberList();
for (Connection registeredSubscriber : registrations.keySet()) {
boolean contains = false;
for (Member member : members) {
contains |= registeredSubscriber.getRemoteAddress().equals(member.getAddress());
}
assertTrue("Registered member " + registeredSubscriber + " is not in the cluster member list " + members, contains);
}
} else {
Iterator<Connection> expectedIterator = registrations.keySet().iterator();
assertTrue(expectedIterator.hasNext());
Iterator<Connection> iterator = clientInstanceImpl.getConnectionManager().getActiveConnections().iterator();
assertTrue(iterator.hasNext());
assertEquals(iterator.next(), expectedIterator.next());
}
});
}
use of com.hazelcast.client.impl.spi.impl.listener.ClientConnectionRegistration in project hazelcast by hazelcast.
the class ListenerLeakTest method testMapEntryListeners.
@Test
public void testMapEntryListeners() {
Collection<Node> nodes = createNodes();
HazelcastInstance client = newHazelcastClient();
IMap map = client.getMap(randomString());
UUID id = map.addEntryListener(mock(MapListener.class), false);
Collection<ClientConnectionRegistration> registrations = getClientEventRegistrations(client, id);
assertTrue(map.removeEntryListener(id));
assertNoLeftOver(nodes, client, id, registrations);
}
use of com.hazelcast.client.impl.spi.impl.listener.ClientConnectionRegistration 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);
}
use of com.hazelcast.client.impl.spi.impl.listener.ClientConnectionRegistration 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);
}
use of com.hazelcast.client.impl.spi.impl.listener.ClientConnectionRegistration 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);
}
Aggregations