Search in sources :

Example 6 with CachePartitionLostListenerConfig

use of com.hazelcast.config.CachePartitionLostListenerConfig in project hazelcast by hazelcast.

the class CachePartitionLostListenerConfigTest method cacheConfigXmlTest.

@Test
public void cacheConfigXmlTest() throws IOException {
    String cacheName = "cacheWithPartitionLostListener";
    Config config = new XmlConfigBuilder(configUrl).build();
    CacheSimpleConfig cacheConfig = config.getCacheConfig(cacheName);
    List<CachePartitionLostListenerConfig> configs = cacheConfig.getPartitionLostListenerConfigs();
    assertEquals(1, configs.size());
    assertEquals("DummyCachePartitionLostListenerImpl", configs.get(0).getClassName());
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) Config(com.hazelcast.config.Config) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with CachePartitionLostListenerConfig

use of com.hazelcast.config.CachePartitionLostListenerConfig in project hazelcast by hazelcast.

the class CachePartitionLostListenerConfigTest method testCachePartitionLostListenerReadOnlyConfig_withEventListenerImplementation.

@Test(expected = UnsupportedOperationException.class)
public void testCachePartitionLostListenerReadOnlyConfig_withEventListenerImplementation() {
    CachePartitionLostListenerConfigReadOnly readOnly = new CachePartitionLostListenerConfigReadOnly(new CachePartitionLostListenerConfig());
    readOnly.setImplementation(mock(EventListener.class));
}
Also used : CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) CachePartitionLostListenerConfigReadOnly(com.hazelcast.internal.config.CachePartitionLostListenerConfigReadOnly) EventListener(java.util.EventListener) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with CachePartitionLostListenerConfig

use of com.hazelcast.config.CachePartitionLostListenerConfig in project hazelcast by hazelcast.

the class CachePartitionLostListenerConfigTest method testCachePartitionLostListenerReadOnlyConfig_withImplementation.

@Test(expected = UnsupportedOperationException.class)
public void testCachePartitionLostListenerReadOnlyConfig_withImplementation() {
    CachePartitionLostListener listener = mock(CachePartitionLostListener.class);
    CachePartitionLostListenerConfig listenerConfig = new CachePartitionLostListenerConfig(listener);
    CachePartitionLostListenerConfigReadOnly readOnly = new CachePartitionLostListenerConfigReadOnly(listenerConfig);
    assertEquals(listener, readOnly.getImplementation());
    readOnly.setImplementation(mock(CachePartitionLostListener.class));
}
Also used : EventCollectingCachePartitionLostListener(com.hazelcast.cache.CachePartitionLostListenerTest.EventCollectingCachePartitionLostListener) CachePartitionLostListener(com.hazelcast.cache.impl.event.CachePartitionLostListener) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) CachePartitionLostListenerConfigReadOnly(com.hazelcast.internal.config.CachePartitionLostListenerConfigReadOnly) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with CachePartitionLostListenerConfig

use of com.hazelcast.config.CachePartitionLostListenerConfig in project hazelcast by hazelcast.

the class DynamicConfigXmlGenerator method cachePartitionLostListenerConfigXmlGenerator.

private static void cachePartitionLostListenerConfigXmlGenerator(ConfigXmlGenerator.XmlGenerator gen, List<CachePartitionLostListenerConfig> configs) {
    if (configs.isEmpty()) {
        return;
    }
    gen.open("partition-lost-listeners");
    for (CachePartitionLostListenerConfig c : configs) {
        gen.node("partition-lost-listener", classNameOrImplClass(c.getClassName(), c.getImplementation()));
    }
    gen.close();
}
Also used : CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig)

Example 10 with CachePartitionLostListenerConfig

use of com.hazelcast.config.CachePartitionLostListenerConfig in project hazelcast by hazelcast.

the class ListenerConfigHolder method asListenerConfig.

public <T extends ListenerConfig> T asListenerConfig(SerializationService serializationService) {
    validate();
    ListenerConfig listenerConfig = null;
    if (className != null) {
        switch(listenerType) {
            case GENERIC:
                listenerConfig = new ListenerConfig(className);
                break;
            case ITEM:
                listenerConfig = new ItemListenerConfig(className, includeValue);
                break;
            case ENTRY:
                listenerConfig = new EntryListenerConfig(className, local, includeValue);
                break;
            case SPLIT_BRAIN_PROTECTION:
                listenerConfig = new SplitBrainProtectionListenerConfig(className);
                break;
            case CACHE_PARTITION_LOST:
                listenerConfig = new CachePartitionLostListenerConfig(className);
                break;
            case MAP_PARTITION_LOST:
                listenerConfig = new MapPartitionLostListenerConfig(className);
                break;
            default:
        }
    } else {
        EventListener eventListener = serializationService.toObject(listenerImplementation);
        switch(listenerType) {
            case GENERIC:
                listenerConfig = new ListenerConfig(eventListener);
                break;
            case ITEM:
                listenerConfig = new ItemListenerConfig((ItemListener) eventListener, includeValue);
                break;
            case ENTRY:
                listenerConfig = new EntryListenerConfig((MapListener) eventListener, local, includeValue);
                break;
            case SPLIT_BRAIN_PROTECTION:
                listenerConfig = new SplitBrainProtectionListenerConfig((SplitBrainProtectionListener) eventListener);
                break;
            case CACHE_PARTITION_LOST:
                listenerConfig = new CachePartitionLostListenerConfig((CachePartitionLostListener) eventListener);
                break;
            case MAP_PARTITION_LOST:
                listenerConfig = new MapPartitionLostListenerConfig((MapPartitionLostListener) eventListener);
                break;
            default:
        }
    }
    return (T) listenerConfig;
}
Also used : SplitBrainProtectionListener(com.hazelcast.splitbrainprotection.SplitBrainProtectionListener) CachePartitionLostListener(com.hazelcast.cache.impl.event.CachePartitionLostListener) MapPartitionLostListenerConfig(com.hazelcast.config.MapPartitionLostListenerConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) SplitBrainProtectionListenerConfig(com.hazelcast.config.SplitBrainProtectionListenerConfig) MapPartitionLostListenerConfig(com.hazelcast.config.MapPartitionLostListenerConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) SplitBrainProtectionListenerConfig(com.hazelcast.config.SplitBrainProtectionListenerConfig) MapPartitionLostListener(com.hazelcast.map.listener.MapPartitionLostListener) MapListener(com.hazelcast.map.listener.MapListener) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) ItemListener(com.hazelcast.collection.ItemListener) EventListener(java.util.EventListener)

Aggregations

CachePartitionLostListenerConfig (com.hazelcast.config.CachePartitionLostListenerConfig)20 Test (org.junit.Test)14 QuickTest (com.hazelcast.test.annotation.QuickTest)12 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)9 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)9 CachePartitionLostListener (com.hazelcast.cache.impl.event.CachePartitionLostListener)6 EventCollectingCachePartitionLostListener (com.hazelcast.cache.CachePartitionLostListenerTest.EventCollectingCachePartitionLostListener)5 Config (com.hazelcast.config.Config)5 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)4 EvictionConfig (com.hazelcast.config.EvictionConfig)4 ItemListenerConfig (com.hazelcast.config.ItemListenerConfig)4 ListenerConfig (com.hazelcast.config.ListenerConfig)4 MapPartitionLostListenerConfig (com.hazelcast.config.MapPartitionLostListenerConfig)4 MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)4 AttributeConfig (com.hazelcast.config.AttributeConfig)3 AwsConfig (com.hazelcast.config.AwsConfig)3 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)3 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)3 DataPersistenceConfig (com.hazelcast.config.DataPersistenceConfig)3 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)3