Search in sources :

Example 1 with MapStoreWithCounter

use of com.hazelcast.map.impl.mapstore.writebehind.MapStoreWithCounter 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 MapStoreWithCounter

use of com.hazelcast.map.impl.mapstore.writebehind.MapStoreWithCounter in project hazelcast by hazelcast.

the class MapStoreTest method testEntryProcessor_calls_load_only_one_time_per_key.

@Test
public void testEntryProcessor_calls_load_only_one_time_per_key() throws Exception {
    Config config = getConfig();
    // configure map with one backup and dummy map store
    MapConfig mapConfig = config.getMapConfig("default");
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    MapStoreWithCounter mapStore = new MapStoreWithCounter();
    mapStoreConfig.setImplementation(mapStore);
    mapConfig.setMapStoreConfig(mapStoreConfig);
    HazelcastInstance member = createHazelcastInstance(config);
    IMap<Integer, Integer> map = member.getMap("default");
    map.executeOnKey(1, new AbstractEntryProcessor<Integer, Integer>(false) {

        @Override
        public Object process(Map.Entry<Integer, Integer> entry) {
            entry.setValue(2);
            return null;
        }
    });
    assertEquals(1, mapStore.getLoadCount());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) GroupConfig(com.hazelcast.config.GroupConfig) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapStoreWithCounter(com.hazelcast.map.impl.mapstore.writebehind.MapStoreWithCounter) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) IMap(com.hazelcast.core.IMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Config (com.hazelcast.config.Config)2 MapConfig (com.hazelcast.config.MapConfig)2 MapStoreConfig (com.hazelcast.config.MapStoreConfig)2 MapStoreWithCounter (com.hazelcast.map.impl.mapstore.writebehind.MapStoreWithCounter)2 TestHazelcastFactory (com.hazelcast.client.test.TestHazelcastFactory)1 GroupConfig (com.hazelcast.config.GroupConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 IMap (com.hazelcast.core.IMap)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Before (org.junit.Before)1 Test (org.junit.Test)1