use of com.hazelcast.map.TestEventCollectingMapPartitionLostListener in project hazelcast by hazelcast.
the class ClientMapPartitionLostListenerTest method test_mapPartitionLostListener_invoked_fromOtherNode.
@Test
public void test_mapPartitionLostListener_invoked_fromOtherNode() {
final String mapName = randomMapName();
final Config config = new Config();
config.getMapConfig(mapName).setBackupCount(0);
final HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance(config);
final HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance(config);
final ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setSmartRouting(false);
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
final HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
final Address clientOwnerAddress = clientInstanceImpl.getClientClusterService().getOwnerConnectionAddress();
final HazelcastInstance other = getAddress(instance1).equals(clientOwnerAddress) ? instance2 : instance1;
final TestEventCollectingMapPartitionLostListener listener = new TestEventCollectingMapPartitionLostListener(0);
client.getMap(mapName).addPartitionLostListener(listener);
assertRegistrationEventually(instance1, mapName, true);
assertRegistrationEventually(instance2, mapName, true);
assertProxyExistsEventually(instance1, mapName);
assertProxyExistsEventually(instance2, mapName);
final MapService mapService = getNode(other).getNodeEngine().getService(SERVICE_NAME);
final int partitionId = 5;
mapService.onPartitionLost(new IPartitionLostEvent(partitionId, 0, null));
assertMapPartitionLostEventEventually(listener, partitionId);
}
use of com.hazelcast.map.TestEventCollectingMapPartitionLostListener in project hazelcast by hazelcast.
the class ClientMapPartitionLostListenerTest method test_mapPartitionLostListener_invoked.
@Test
public void test_mapPartitionLostListener_invoked() {
final String mapName = randomMapName();
final Config config = new Config();
config.getMapConfig(mapName).setBackupCount(0);
final HazelcastInstance instance = hazelcastFactory.newHazelcastInstance(config);
final HazelcastInstance client = hazelcastFactory.newHazelcastClient();
warmUpPartitions(instance, client);
final TestEventCollectingMapPartitionLostListener listener = new TestEventCollectingMapPartitionLostListener(0);
client.getMap(mapName).addPartitionLostListener(listener);
final MapService mapService = getNode(instance).getNodeEngine().getService(MapService.SERVICE_NAME);
final int partitionId = 5;
mapService.onPartitionLost(new IPartitionLostEvent(partitionId, 0, null));
assertMapPartitionLostEventEventually(listener, partitionId);
}
Aggregations