Search in sources :

Example 6 with IPartitionLostEvent

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);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) 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 7 with IPartitionLostEvent

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapService(com.hazelcast.map.impl.MapService) EntryAddedListener(com.hazelcast.map.listener.EntryAddedListener) IPartitionLostEvent(com.hazelcast.spi.partition.IPartitionLostEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) AbstractPartitionLostListenerTest(com.hazelcast.partition.AbstractPartitionLostListenerTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 8 with IPartitionLostEvent

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapService(com.hazelcast.map.impl.MapService) IPartitionLostEvent(com.hazelcast.spi.partition.IPartitionLostEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) AbstractPartitionLostListenerTest(com.hazelcast.partition.AbstractPartitionLostListenerTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with IPartitionLostEvent

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapService(com.hazelcast.map.impl.MapService) IPartitionLostEvent(com.hazelcast.spi.partition.IPartitionLostEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) AbstractPartitionLostListenerTest(com.hazelcast.partition.AbstractPartitionLostListenerTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 10 with IPartitionLostEvent

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);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) 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)

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