use of com.hazelcast.cp.CPMembershipListenerTest.CountingDownCPMembershipListener in project hazelcast by hazelcast.
the class ClientCPMembershipListenerTest method whenMemberTerminated_thenReceiveMemberRemovedEvent.
@Test
public void whenMemberTerminated_thenReceiveMemberRemovedEvent() {
Config config = createConfig(3, 3);
config.getCPSubsystemConfig().setSessionTimeToLiveSeconds(2).setSessionHeartbeatIntervalSeconds(1).setMissingCPMemberAutoRemovalSeconds(3);
HazelcastInstance[] instances = factory.newInstances(config, 3);
waitUntilCPDiscoveryCompleted(instances);
HazelcastInstance client = factory.newHazelcastClient();
CountingDownCPMembershipListener listener = new CountingDownCPMembershipListener(0, 1);
client.getCPSubsystem().addMembershipListener(listener);
HazelcastInstance instance = instances[instances.length - 1];
CPMember member = instance.getCPSubsystem().getLocalCPMember();
instance.getLifecycleService().terminate();
assertOpenEventually(listener.removedLatch);
assertEquals(member, listener.removedMembers.get(0));
}
Aggregations