use of com.hazelcast.internal.partition.PartitionLostEventImpl in project hazelcast by hazelcast.
the class ClientMapPartitionLostListenerTest method test_mapPartitionLostListener_invoked.
@Test
public void test_mapPartitionLostListener_invoked() {
String mapName = randomMapName();
Config config = getConfig();
config.getMapConfig(mapName).setBackupCount(0);
ClientConfig clientConfig = getClientConfig();
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
warmUpPartitions(instance, client);
TestEventCollectingMapPartitionLostListener listener = new TestEventCollectingMapPartitionLostListener(0);
client.getMap(mapName).addPartitionLostListener(listener);
MapService mapService = getNode(instance).getNodeEngine().getService(MapService.SERVICE_NAME);
int partitionId = 5;
mapService.onPartitionLost(new PartitionLostEventImpl(partitionId, 0, null));
assertMapPartitionLostEventEventually(listener, partitionId);
}
use of com.hazelcast.internal.partition.PartitionLostEventImpl 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.internal.partition.PartitionLostEventImpl 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