Search in sources :

Example 11 with MapStoreConfig

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

the class MapStoreContextFactory method createMapStoreContext.

public static MapStoreContext createMapStoreContext(MapContainer mapContainer) {
    final MapConfig mapConfig = mapContainer.getMapConfig();
    final MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
    if (mapStoreConfig == null || !mapStoreConfig.isEnabled()) {
        return EMPTY_MAP_STORE_CONTEXT;
    }
    return BasicMapStoreContext.create(mapContainer);
}
Also used : MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig)

Example 12 with MapStoreConfig

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

the class BasicMapStoreContext method setStoreImplToWritableMapStoreConfig.

private static void setStoreImplToWritableMapStoreConfig(NodeEngine nodeEngine, String mapName, Object store) {
    final Config config = nodeEngine.getConfig();
    // get writable config (not read-only one) from node engine.
    final MapConfig mapConfig = config.getMapConfig(mapName);
    final MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
    mapStoreConfig.setImplementation(store);
}
Also used : Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig)

Example 13 with MapStoreConfig

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

the class MapIndexBackupTest method createNode.

private HazelcastInstance createNode(TestHazelcastInstanceFactory instanceFactory) {
    Config config = getConfig();
    MapConfig mapConfig = config.getMapConfig("book");
    mapConfig.addMapIndexConfig(new MapIndexConfig("author", false));
    mapConfig.addMapIndexConfig(new MapIndexConfig("year", true));
    mapConfig.setMapStoreConfig(new MapStoreConfig().setImplementation(new BookMapLoader()));
    mapConfig.setBackupCount(1);
    return instanceFactory.newHazelcastInstance(config);
}
Also used : MapIndexConfig(com.hazelcast.config.MapIndexConfig) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig)

Example 14 with MapStoreConfig

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

the class NearCacheTestSupport method createNearCachedMapConfigWithMapStoreConfig.

protected Config createNearCachedMapConfigWithMapStoreConfig(String mapName) {
    SimpleMapStore store = new SimpleMapStore();
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(store);
    Config config = createNearCachedMapConfig(mapName);
    config.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
    return config;
}
Also used : MapConfig(com.hazelcast.config.MapConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig)

Example 15 with MapStoreConfig

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

the class QueryAdvancedTest method testQueryAfterInitialLoad.

// issue 1404 "to be fixed by issue 1404"
@Test
public void testQueryAfterInitialLoad() {
    final int size = 100;
    String name = "default";
    Config config = getConfig();
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(new MapStoreAdapter<Integer, Employee>() {

        @Override
        public Map<Integer, Employee> loadAll(Collection<Integer> keys) {
            Map<Integer, Employee> map = new HashMap<Integer, Employee>();
            for (Integer key : keys) {
                Employee emp = new Employee();
                emp.setActive(true);
                map.put(key, emp);
            }
            return map;
        }

        @Override
        public Set<Integer> loadAllKeys() {
            Set<Integer> set = new HashSet<Integer>();
            for (int i = 0; i < size; i++) {
                set.add(i);
            }
            return set;
        }
    });
    config.getMapConfig(name).setMapStoreConfig(mapStoreConfig);
    HazelcastInstance instance = createHazelcastInstance(config);
    final IMap map = instance.getMap(name);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            Collection values = map.values(new SqlPredicate("active = true"));
            assertEquals(size, values.size());
        }
    });
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) SqlPredicate(com.hazelcast.query.SqlPredicate) MapStoreConfig(com.hazelcast.config.MapStoreConfig) IOException(java.io.IOException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IMap(com.hazelcast.core.IMap) Employee(com.hazelcast.query.SampleObjects.Employee) PortableEmployee(com.hazelcast.query.SampleObjects.PortableEmployee) HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) Collection(java.util.Collection) HashMap(java.util.HashMap) Map(java.util.Map) IMap(com.hazelcast.core.IMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

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