Search in sources :

Example 16 with IPartitionLostEvent

use of com.hazelcast.spi.partition.IPartitionLostEvent 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);
    assertRegistrationsSizeEventually(instance, 1);
    final InternalPartitionServiceImpl partitionService = getNode(instance).getNodeEngine().getService(SERVICE_NAME);
    final int partitionId = 5;
    partitionService.onPartitionLost(new IPartitionLostEvent(partitionId, 0, null));
    assertPartitionLostEventEventually(listener, partitionId);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) EventCollectingPartitionLostListener(com.hazelcast.partition.PartitionLostListenerStressTest.EventCollectingPartitionLostListener) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) IPartitionLostEvent(com.hazelcast.spi.partition.IPartitionLostEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 17 with IPartitionLostEvent

use of com.hazelcast.spi.partition.IPartitionLostEvent in project hazelcast by hazelcast.

the class PartitionEventManager method sendPartitionLostEvent.

public void sendPartitionLostEvent(int partitionId, int lostReplicaIndex) {
    final IPartitionLostEvent event = new IPartitionLostEvent(partitionId, lostReplicaIndex, nodeEngine.getThisAddress());
    final InternalPartitionLostEventPublisher publisher = new InternalPartitionLostEventPublisher(nodeEngine, event);
    nodeEngine.getExecutionService().execute(SYSTEM_EXECUTOR, publisher);
}
Also used : IPartitionLostEvent(com.hazelcast.spi.partition.IPartitionLostEvent)

Aggregations

IPartitionLostEvent (com.hazelcast.spi.partition.IPartitionLostEvent)17 ParallelTest (com.hazelcast.test.annotation.ParallelTest)15 QuickTest (com.hazelcast.test.annotation.QuickTest)15 Test (org.junit.Test)15 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)5 MapService (com.hazelcast.map.impl.MapService)5 AbstractPartitionLostListenerTest (com.hazelcast.partition.AbstractPartitionLostListenerTest)4 EventCollectingPartitionLostListener (com.hazelcast.partition.PartitionLostListenerStressTest.EventCollectingPartitionLostListener)4 CacheService (com.hazelcast.cache.impl.CacheService)3 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)3 ClientConfig (com.hazelcast.client.config.ClientConfig)3 CacheConfig (com.hazelcast.config.CacheConfig)3 Address (com.hazelcast.nio.Address)3 CacheManager (javax.cache.CacheManager)3 ICache (com.hazelcast.cache.ICache)2 HazelcastServerCachingProvider.createCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider.createCachingProvider)2 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)2 ClientTestUtil.getHazelcastClientInstanceImpl (com.hazelcast.client.impl.ClientTestUtil.getHazelcastClientInstanceImpl)2 HazelcastClientInstanceImpl (com.hazelcast.client.impl.HazelcastClientInstanceImpl)2