Search in sources :

Example 1 with MapStoreConfig

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

the class ClientWriteBehindFlushTest method setUp.

@Before
public void setUp() throws Exception {
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    MapStoreWithCounter mapStore = new MapStoreWithCounter<Integer, String>();
    mapStoreConfig.setImplementation(mapStore).setWriteDelaySeconds(3000);
    Config config = getConfig();
    config.getMapConfig(MAP_NAME).setMapStoreConfig(mapStoreConfig);
    TestHazelcastFactory hazelcastFactory = new TestHazelcastFactory();
    member1 = hazelcastFactory.newHazelcastInstance(config);
    member2 = hazelcastFactory.newHazelcastInstance(config);
    member3 = hazelcastFactory.newHazelcastInstance(config);
    client = hazelcastFactory.newHazelcastClient();
}
Also used : Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapStoreWithCounter(com.hazelcast.map.impl.mapstore.writebehind.MapStoreWithCounter) Before(org.junit.Before)

Example 2 with MapStoreConfig

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

the class ClientWriteBehindFlushTest method newMapStoredConfig.

protected 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(MAP_NAME);
    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 3 with MapStoreConfig

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

the class ClientMapLoadAllTest method givenSpecificKeysWereReloaded_whenLoadAllIsCalled_thenAllEntriesAreLoadedFromTheStore.

@Test
public void givenSpecificKeysWereReloaded_whenLoadAllIsCalled_thenAllEntriesAreLoadedFromTheStore() {
    String name = randomString();
    int keysInMapStore = 10000;
    Config config = new Config();
    MapConfig mapConfig = config.getMapConfig(name);
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(new MapLoaderTest.DummyMapLoader(keysInMapStore));
    mapStoreConfig.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER);
    mapConfig.setMapStoreConfig(mapStoreConfig);
    hazelcastFactory.newHazelcastInstance(config);
    HazelcastInstance client = hazelcastFactory.newHazelcastClient();
    IMap<Integer, Integer> map = client.getMap(name);
    //load specific keys
    map.loadAll(setOfValuesBetween(0, keysInMapStore), true);
    //remove everything
    map.clear();
    //assert loadAll with load all entries provided by the mapLoader
    map.loadAll(true);
    assertEquals(keysInMapStore, map.size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapLoaderTest(com.hazelcast.map.impl.mapstore.MapLoaderTest) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) MapLoaderTest(com.hazelcast.map.impl.mapstore.MapLoaderTest) AbstractMapStoreTest(com.hazelcast.map.impl.mapstore.AbstractMapStoreTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with MapStoreConfig

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

the class ClientMapStoreTest method mapStore_OperationQueue_AtMaxCapacity.

@Test
public void mapStore_OperationQueue_AtMaxCapacity() {
    int maxCapacity = 1000;
    Config config = new Config();
    config.setProperty(GroupProperty.MAP_WRITE_BEHIND_QUEUE_CAPACITY.getName(), String.valueOf(maxCapacity));
    MapConfig mapConfig = new MapConfig();
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    MapStoreBackup store = new MapStoreBackup();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(store);
    mapStoreConfig.setWriteDelaySeconds(60);
    mapStoreConfig.setWriteCoalescing(false);
    mapConfig.setName(MAP_NAME);
    mapConfig.setMapStoreConfig(mapStoreConfig);
    config.addMapConfig(mapConfig);
    HazelcastInstance server = hazelcastFactory.newHazelcastInstance(config);
    HazelcastInstance client = hazelcastFactory.newHazelcastClient();
    IMap<Integer, Integer> map = client.getMap(MAP_NAME);
    for (int i = 0; i < maxCapacity; i++) {
        map.put(i, i);
    }
    assertEquals(maxCapacity, map.size());
    try {
        map.put(maxCapacity, maxCapacity);
        fail("Should not exceed max capacity");
    } catch (ReachedMaxSizeException expected) {
        ignore(expected);
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) ReachedMaxSizeException(com.hazelcast.map.ReachedMaxSizeException) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 5 with MapStoreConfig

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

the class ClientMapStoreTest method setup.

@Before
public void setup() {
    nodeConfig = new Config();
    MapConfig mapConfig = new MapConfig();
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(new SimpleMapStore());
    mapStoreConfig.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER);
    mapConfig.setName(MAP_NAME);
    mapConfig.setMapStoreConfig(mapStoreConfig);
    nodeConfig.addMapConfig(mapConfig);
}
Also used : MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Before(org.junit.Before)

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