Search in sources :

Example 71 with MapStoreConfig

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

the class WriteBehindUponMigrationTest method createConfig.

private static Config createConfig(String mapName, MapStoreTest.SimpleMapStore store) {
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setImplementation(store).setWriteDelaySeconds(100).setWriteBatchSize(1).setWriteCoalescing(false);
    Config config = new Config();
    config.getMapConfig(mapName).setBackupCount(1).setMapStoreConfig(mapStoreConfig);
    return config;
}
Also used : Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig)

Example 72 with MapStoreConfig

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

the class WriteBehindWriteDelaySecondsTest method newMapStoredConfig.

private Config newMapStoredConfig(MapStore store, int writeDelaySeconds) {
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setWriteDelaySeconds(writeDelaySeconds);
    mapStoreConfig.setImplementation(store);
    Config config = getConfig();
    MapConfig mapConfig = config.getMapConfig("default");
    mapConfig.setMapStoreConfig(mapStoreConfig);
    return config;
}
Also used : Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapConfig(com.hazelcast.config.MapConfig)

Example 73 with MapStoreConfig

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

the class EntryProcessorTest method testIssue1022.

@Test
public void testIssue1022() {
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);
    Config cfg = getConfig();
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(new MapLoader<Integer, Integer>() {

        public Integer load(Integer key) {
            return 123;
        }

        public Map<Integer, Integer> loadAll(Collection<Integer> keys) {
            return null;
        }

        public Set<Integer> loadAllKeys() {
            return null;
        }
    });
    cfg.getMapConfig(MAP_NAME).setMapStoreConfig(mapStoreConfig);
    HazelcastInstance instance = nodeFactory.newHazelcastInstance(cfg);
    EntryProcessor entryProcessor = new IncrementorEntryProcessor();
    instance.getMap(MAP_NAME).executeOnKey(1, entryProcessor);
    assertEquals(124, instance.getMap(MAP_NAME).get(1));
    instance.shutdown();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Set(java.util.Set) HashSet(java.util.HashSet) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) Map(java.util.Map) Collections.emptyMap(java.util.Collections.emptyMap) IMap(com.hazelcast.core.IMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 74 with MapStoreConfig

use of com.hazelcast.config.MapStoreConfig in project ddf by codice.

the class HazelcastNotificationStore method getHazelcastConfig.

private Config getHazelcastConfig(BundleContext context, String xmlConfigFilename) {
    Config cfg = null;
    Bundle bundle = context.getBundle();
    URL xmlConfigFileUrl = null;
    if (StringUtils.isNotBlank(xmlConfigFilename)) {
        xmlConfigFileUrl = bundle.getResource(xmlConfigFilename);
    }
    XmlConfigBuilder xmlConfigBuilder = null;
    if (xmlConfigFileUrl != null) {
        try {
            xmlConfigBuilder = new XmlConfigBuilder(xmlConfigFileUrl.openStream());
            cfg = xmlConfigBuilder.build();
            LOGGER.debug("Successfully built hazelcast config from XML config file {}", xmlConfigFilename);
        } catch (FileNotFoundException e) {
            LOGGER.info("FileNotFoundException trying to build hazelcast config from XML file " + xmlConfigFilename, e);
            cfg = null;
        } catch (IOException e) {
            LOGGER.info("IOException trying to build hazelcast config from XML file " + xmlConfigFilename, e);
            cfg = null;
        }
    }
    if (cfg == null) {
        LOGGER.info("Falling back to using generic Config for hazelcast");
        cfg = new Config();
    } else if (LOGGER.isDebugEnabled()) {
        MapConfig mapConfig = cfg.getMapConfig("persistentNotifications");
        if (mapConfig == null) {
            LOGGER.debug("mapConfig is NULL for persistentNotifications - try persistent*");
            mapConfig = cfg.getMapConfig("persistent*");
            if (mapConfig == null) {
                LOGGER.debug("mapConfig is NULL for persistent*");
            }
        } else {
            MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
            if (mapStoreConfig != null) {
                LOGGER.debug("mapStoreConfig factoryClassName = {}", mapStoreConfig.getFactoryClassName());
            } else {
                LOGGER.debug("mapStoreConfig is null");
            }
        }
    }
    return cfg;
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) NetworkConfig(com.hazelcast.config.NetworkConfig) JoinConfig(com.hazelcast.config.JoinConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Bundle(org.osgi.framework.Bundle) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) URL(java.net.URL)

Example 75 with MapStoreConfig

use of com.hazelcast.config.MapStoreConfig in project ddf by codice.

the class ResourceCacheImpl method getHazelcastConfig.

private Config getHazelcastConfig(BundleContext context, String xmlConfigFilename) {
    Config cfg = null;
    Bundle bundle = context.getBundle();
    URL xmlConfigFileUrl = null;
    if (StringUtils.isNotBlank(xmlConfigFilename)) {
        xmlConfigFileUrl = bundle.getResource(xmlConfigFilename);
    }
    XmlConfigBuilder xmlConfigBuilder = null;
    if (xmlConfigFileUrl != null) {
        try {
            xmlConfigBuilder = new XmlConfigBuilder(xmlConfigFileUrl.openStream());
            cfg = xmlConfigBuilder.build();
            LOGGER.debug("Successfully built hazelcast config from XML config file {}", xmlConfigFilename);
        } catch (FileNotFoundException e) {
            LOGGER.info("FileNotFoundException trying to build hazelcast config from XML file " + xmlConfigFilename, e);
            cfg = null;
        } catch (IOException e) {
            LOGGER.info("IOException trying to build hazelcast config from XML file " + xmlConfigFilename, e);
            cfg = null;
        }
    }
    if (cfg == null) {
        LOGGER.info("Falling back to using generic Config for hazelcast");
        cfg = new Config();
    } else if (LOGGER.isDebugEnabled()) {
        MapConfig mapConfig = cfg.getMapConfig("Product_Cache");
        if (mapConfig == null) {
            LOGGER.debug("mapConfig is NULL for persistentNotifications - try persistent*");
            mapConfig = cfg.getMapConfig("persistent*");
            if (mapConfig == null) {
                LOGGER.debug("mapConfig is NULL for persistent*");
            }
        } else {
            MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
            if (null != mapStoreConfig) {
                LOGGER.debug("mapStoreConfig factoryClassName = {}", mapStoreConfig.getFactoryClassName());
            }
        }
    }
    return cfg;
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Bundle(org.osgi.framework.Bundle) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) URL(java.net.URL)

Aggregations

MapStoreConfig (com.hazelcast.config.MapStoreConfig)76 Config (com.hazelcast.config.Config)70 MapConfig (com.hazelcast.config.MapConfig)61 HazelcastInstance (com.hazelcast.core.HazelcastInstance)51 Test (org.junit.Test)50 QuickTest (com.hazelcast.test.annotation.QuickTest)43 ParallelTest (com.hazelcast.test.annotation.ParallelTest)42 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)23 GroupConfig (com.hazelcast.config.GroupConfig)21 IMap (com.hazelcast.core.IMap)12 AssertTask (com.hazelcast.test.AssertTask)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 MapIndexConfig (com.hazelcast.config.MapIndexConfig)10 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)9 NightlyTest (com.hazelcast.test.annotation.NightlyTest)8 HashSet (java.util.HashSet)8 NearCacheConfig (com.hazelcast.config.NearCacheConfig)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 MapStoreAdapter (com.hazelcast.core.MapStoreAdapter)5