use of com.hazelcast.partition.PartitionLostListenerStressTest.EventCollectingPartitionLostListener in project hazelcast by hazelcast.
the class PartitionLostListenerTest method test_partitionLostListenerInvoked_whenAllPartitionReplicasCrashed.
@Test
public void test_partitionLostListenerInvoked_whenAllPartitionReplicasCrashed() {
HazelcastInstance lite = factory.newHazelcastInstance(new Config().setLiteMember(true));
warmUpPartitions(instances);
warmUpPartitions(lite);
waitAllForSafeState(instances);
waitInstanceForSafeState(lite);
final EventCollectingPartitionLostListener listener = new EventCollectingPartitionLostListener();
lite.getPartitionService().addPartitionLostListener(listener);
instances[0].getLifecycleService().terminate();
instances[1].getLifecycleService().terminate();
assertTrueEventually(new AssertTask() {
@Override
public void run() {
List<PartitionLostEvent> events = listener.getEvents();
assertFalse(events.isEmpty());
assertTrue(getLast(events).allReplicasInPartitionLost());
}
});
}
use of com.hazelcast.partition.PartitionLostListenerStressTest.EventCollectingPartitionLostListener in project hazelcast by hazelcast.
the class PartitionLostListenerTest method test_partitionLostListenerInvoked.
@Test
public void test_partitionLostListenerInvoked() {
HazelcastInstance instance = instances[0];
EventCollectingPartitionLostListener listener = new EventCollectingPartitionLostListener();
instance.getPartitionService().addPartitionLostListener(listener);
IPartitionLostEvent internalEvent = new PartitionLostEventImpl(1, 0, null);
NodeEngineImpl nodeEngine = getNode(instance).getNodeEngine();
InternalPartitionServiceImpl partitionService = (InternalPartitionServiceImpl) nodeEngine.getPartitionService();
partitionService.onPartitionLost(internalEvent);
assertEventEventually(listener, internalEvent);
}
use of com.hazelcast.partition.PartitionLostListenerStressTest.EventCollectingPartitionLostListener in project hazelcast by hazelcast.
the class ClientPartitionLostListenerTest method test_partitionLostListener_invoked_fromOtherNode.
@Test
public void test_partitionLostListener_invoked_fromOtherNode() {
final HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance();
final ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setSmartRouting(false);
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
final HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance();
warmUpPartitions(instance1, instance2, client);
final EventCollectingPartitionLostListener listener = new EventCollectingPartitionLostListener();
client.getPartitionService().addPartitionLostListener(listener);
// Expected = 2 -> 1 added & 1 from {@link com.hazelcast.scheduledexecutor.impl.DistributedScheduledExecutorService}
// + 2 from map and cache ExpirationManagers * instances
assertRegistrationsSizeEventually(instance1, 7);
assertRegistrationsSizeEventually(instance2, 7);
final InternalPartitionServiceImpl partitionService = getNode(instance2).getNodeEngine().getService(SERVICE_NAME);
final int partitionId = 5;
Address address = instance1.getCluster().getLocalMember().getAddress();
partitionService.onPartitionLost(new PartitionLostEventImpl(partitionId, 0, address));
assertPartitionLostEventEventually(listener, partitionId);
}
use of com.hazelcast.partition.PartitionLostListenerStressTest.EventCollectingPartitionLostListener in project hazelcast by hazelcast.
the class ClientPartitionLostListenerTest method test_partitionLostListener_registeredByConfig_invoked.
@Test
public void test_partitionLostListener_registeredByConfig_invoked() {
final HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
final EventCollectingPartitionLostListener listener = new EventCollectingPartitionLostListener();
final ClientConfig clientConfig = new ClientConfig().addListenerConfig(new ListenerConfig(listener));
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
warmUpPartitions(instance, client);
// Expected = 4 -> 1 added & 1 from {@link com.hazelcast.scheduledexecutor.impl.DistributedScheduledExecutorService}
// + 2 from map and cache ExpirationManagers
assertRegistrationsSizeEventually(instance, 4);
final InternalPartitionServiceImpl partitionService = getNode(instance).getNodeEngine().getService(SERVICE_NAME);
final int partitionId = 5;
Address address = instance.getCluster().getLocalMember().getAddress();
partitionService.onPartitionLost(new PartitionLostEventImpl(partitionId, 0, address));
assertPartitionLostEventEventually(listener, partitionId);
}
use of com.hazelcast.partition.PartitionLostListenerStressTest.EventCollectingPartitionLostListener in project hazelcast by hazelcast.
the class ClientPartitionLostListenerTest method test_partitionLostListener_invoked.
@Test
public void test_partitionLostListener_invoked() {
final HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
final HazelcastInstance client = hazelcastFactory.newHazelcastClient();
warmUpPartitions(instance, client);
final EventCollectingPartitionLostListener listener = new EventCollectingPartitionLostListener();
client.getPartitionService().addPartitionLostListener(listener);
// Expected = 4 -> 1 added & 1 from {@link com.hazelcast.scheduledexecutor.impl.DistributedScheduledExecutorService}
// + 2 from map and cache ExpirationManagers
assertRegistrationsSizeEventually(instance, 4);
final InternalPartitionServiceImpl partitionService = getNode(instance).getNodeEngine().getService(SERVICE_NAME);
final int partitionId = 5;
Address address = instance.getCluster().getLocalMember().getAddress();
partitionService.onPartitionLost(new PartitionLostEventImpl(partitionId, 0, address));
assertPartitionLostEventEventually(listener, partitionId);
}
Aggregations