Search in sources :

Example 1 with MapStoreFactory

use of com.hazelcast.map.MapStoreFactory in project hazelcast by hazelcast.

the class StoreConstructor method getStoreFromFactoryOrNull.

private static Object getStoreFromFactoryOrNull(String name, MapStoreConfig mapStoreConfig, ClassLoader classLoader) {
    MapStoreFactory factory = (MapStoreFactory) mapStoreConfig.getFactoryImplementation();
    if (factory == null) {
        final String factoryClassName = mapStoreConfig.getFactoryClassName();
        if (isNullOrEmpty(factoryClassName)) {
            return null;
        }
        try {
            factory = ClassLoaderUtil.newInstance(classLoader, factoryClassName);
        } catch (Exception e) {
            throw ExceptionUtil.rethrow(e);
        }
    }
    if (factory == null) {
        return null;
    }
    final Properties properties = mapStoreConfig.getProperties();
    return factory.newMapStore(name, properties);
}
Also used : MapStoreFactory(com.hazelcast.map.MapStoreFactory) Properties(java.util.Properties)

Example 2 with MapStoreFactory

use of com.hazelcast.map.MapStoreFactory in project hazelcast by hazelcast.

the class AbstractDynamicConfigGeneratorTest method testAttributesConfigWithStoreFactoryImplementation.

@Test
public void testAttributesConfigWithStoreFactoryImplementation() {
    MapStoreConfig mapStoreConfig = new MapStoreConfig().setEnabled(true).setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER).setWriteDelaySeconds(10).setWriteCoalescing(true).setWriteBatchSize(500).setFactoryImplementation((MapStoreFactory<Object, Object>) (mapName, properties) -> null).setProperty("key", "value");
    testMap(mapStoreConfig);
}
Also used : MapStoreFactory(com.hazelcast.map.MapStoreFactory) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Test(org.junit.Test)

Aggregations

MapStoreFactory (com.hazelcast.map.MapStoreFactory)2 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 Properties (java.util.Properties)1 Test (org.junit.Test)1