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());
}
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));
}
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));
}
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();
}
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;
}
Aggregations