use of com.hazelcast.spi.partition.IPartitionLostEvent in project hazelcast by hazelcast.
the class PartitionLostListenerTest method test_partitionLostListenerInvoked.
@Test
public void test_partitionLostListenerInvoked() {
HazelcastInstance instance = instances[0];
final EventCollectingPartitionLostListener listener = new EventCollectingPartitionLostListener();
instance.getPartitionService().addPartitionLostListener(listener);
final IPartitionLostEvent internalEvent = new IPartitionLostEvent(1, 0, null);
NodeEngineImpl nodeEngine = getNode(instance).getNodeEngine();
InternalPartitionServiceImpl partitionService = (InternalPartitionServiceImpl) nodeEngine.getPartitionService();
partitionService.onPartitionLost(internalEvent);
assertEventEventually(listener, internalEvent);
}
use of com.hazelcast.spi.partition.IPartitionLostEvent in project hazelcast by hazelcast.
the class MapPartitionLostListenerTest method test_partitionLostListenerInvoked_whenEntryListenerIsAlsoRegistered.
@Test
public void test_partitionLostListenerInvoked_whenEntryListenerIsAlsoRegistered() {
List<HazelcastInstance> instances = getCreatedInstancesShuffledAfterWarmedUp(1);
HazelcastInstance instance = instances.get(0);
final TestEventCollectingMapPartitionLostListener listener = new TestEventCollectingMapPartitionLostListener(0);
instance.getMap(getIthMapName(0)).addPartitionLostListener(listener);
instance.getMap(getIthMapName(0)).addEntryListener(mock(EntryAddedListener.class), true);
final IPartitionLostEvent internalEvent = new IPartitionLostEvent(1, 0, null);
MapService mapService = getNode(instance).getNodeEngine().getService(MapService.SERVICE_NAME);
mapService.onPartitionLost(internalEvent);
assertEventEventually(listener, internalEvent);
}
use of com.hazelcast.spi.partition.IPartitionLostEvent in project hazelcast by hazelcast.
the class MapPartitionLostListenerTest method test_partitionLostListenerInvoked.
@Test
public void test_partitionLostListenerInvoked() {
List<HazelcastInstance> instances = getCreatedInstancesShuffledAfterWarmedUp(1);
HazelcastInstance instance = instances.get(0);
final TestEventCollectingMapPartitionLostListener listener = new TestEventCollectingMapPartitionLostListener(0);
instance.getMap(getIthMapName(0)).addPartitionLostListener(listener);
final IPartitionLostEvent internalEvent = new IPartitionLostEvent(1, 0, null);
MapService mapService = getNode(instance).getNodeEngine().getService(MapService.SERVICE_NAME);
mapService.onPartitionLost(internalEvent);
assertEventEventually(listener, internalEvent);
}
use of com.hazelcast.spi.partition.IPartitionLostEvent in project hazelcast by hazelcast.
the class MapPartitionLostListenerTest method test_allPartitionLostListenersInvoked.
@Test
public void test_allPartitionLostListenersInvoked() {
List<HazelcastInstance> instances = getCreatedInstancesShuffledAfterWarmedUp(2);
HazelcastInstance instance1 = instances.get(0);
HazelcastInstance instance2 = instances.get(0);
final TestEventCollectingMapPartitionLostListener listener1 = new TestEventCollectingMapPartitionLostListener(0);
final TestEventCollectingMapPartitionLostListener listener2 = new TestEventCollectingMapPartitionLostListener(0);
instance1.getMap(getIthMapName(0)).addPartitionLostListener(listener1);
instance2.getMap(getIthMapName(0)).addPartitionLostListener(listener2);
final IPartitionLostEvent internalEvent = new IPartitionLostEvent(1, 0, null);
MapService mapService = getNode(instance1).getNodeEngine().getService(MapService.SERVICE_NAME);
mapService.onPartitionLost(internalEvent);
assertEventEventually(listener1, internalEvent);
assertEventEventually(listener2, internalEvent);
}
use of com.hazelcast.spi.partition.IPartitionLostEvent in project hazelcast by hazelcast.
the class PartitionLostListenerTest method test_allPartitionLostListenersInvoked.
@Test
public void test_allPartitionLostListenersInvoked() {
HazelcastInstance instance1 = instances[0];
HazelcastInstance instance2 = instances[1];
final EventCollectingPartitionLostListener listener1 = new EventCollectingPartitionLostListener();
final EventCollectingPartitionLostListener listener2 = new EventCollectingPartitionLostListener();
instance1.getPartitionService().addPartitionLostListener(listener1);
instance2.getPartitionService().addPartitionLostListener(listener2);
final IPartitionLostEvent internalEvent = new IPartitionLostEvent(1, 0, null);
NodeEngineImpl nodeEngine = getNode(instance1).getNodeEngine();
InternalPartitionServiceImpl partitionService = (InternalPartitionServiceImpl) nodeEngine.getPartitionService();
partitionService.onPartitionLost(internalEvent);
assertEventEventually(listener1, internalEvent);
assertEventEventually(listener2, internalEvent);
}
Aggregations