use of com.hazelcast.internal.partition.PartitionLostEventImpl 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.internal.partition.PartitionLostEventImpl in project hazelcast by hazelcast.
the class PartitionLostListenerTest method test_internalPartitionLostEvent_serialization.
@Test
public void test_internalPartitionLostEvent_serialization() throws IOException {
Address address = new Address();
PartitionLostEventImpl internalEvent = new PartitionLostEventImpl(1, 2, address);
ObjectDataOutput output = mock(ObjectDataOutput.class);
internalEvent.writeData(output);
verify(output).writeInt(1);
verify(output).writeInt(2);
}
use of com.hazelcast.internal.partition.PartitionLostEventImpl 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.internal.partition.PartitionLostEventImpl in project hazelcast by hazelcast.
the class PartitionEventManager method sendPartitionLostEvent.
public void sendPartitionLostEvent(int partitionId, int lostReplicaIndex) {
IPartitionLostEvent event = new PartitionLostEventImpl(partitionId, lostReplicaIndex, nodeEngine.getThisAddress());
InternalPartitionLostEventPublisher publisher = new InternalPartitionLostEventPublisher(nodeEngine, event);
nodeEngine.getExecutionService().execute(SYSTEM_EXECUTOR, publisher);
}
use of com.hazelcast.internal.partition.PartitionLostEventImpl 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 PartitionLostEventImpl(1, 0, null);
MapService mapService = getNode(instance1).getNodeEngine().getService(MapService.SERVICE_NAME);
mapService.onPartitionLost(internalEvent);
assertEventEventually(listener1, internalEvent);
assertEventEventually(listener2, internalEvent);
}
Aggregations