@Test(timeout = 120000) public void testMapStoreNotCalledFromEntryProcessorBackup() throws Exception { final String mapName = "testMapStoreNotCalledFromEntryProcessorBackup_" + randomString(); final int instanceCount = 2; Config config = getConfig(); // Configure map with one backup and dummy map store MapConfig mapConfig = config.getMapConfig(mapName); mapConfig.setBackupCount(1); MapStoreConfig mapStoreConfig = new MapStoreConfig(); MapStoreWithStoreCount mapStore = new MapStoreWithStoreCount(1, 120); mapStoreConfig.setImplementation(mapStore); mapConfig.setMapStoreConfig(mapStoreConfig); TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(instanceCount); HazelcastInstance instance1 = nodeFactory.newHazelcastInstance(config); HazelcastInstance instance2 = nodeFactory.newHazelcastInstance(config); final IMap<String, String> map = instance1.getMap(mapName); final String key = "key"; final String value = "value"; // executeOnKey map.executeOnKey(key, new ValueSetterEntryProcessor(value)); mapStore.awaitStores(); assertEquals(value, map.get(key)); assertEquals(1, mapStore.getCount()); }
/** if statistics enabled InMemoryFormat.Object does not work */ @Test public void testIssue2622() { final String mapName = randomString(); Config config = new Config(); final MapConfig mapConfig = new MapConfig(mapName); mapConfig.setInMemoryFormat(InMemoryFormat.OBJECT); mapConfig.setStatisticsEnabled(true); config.addMapConfig(mapConfig); final HazelcastInstance instance = createHazelcastInstance(config); final IMap<String, SerializationValue> map = instance.getMap(mapName); final SerializationValue serializationValue = new SerializationValue(); map.put("key", serializationValue); // EntryProcessor should not trigger de-serialization map.executeOnKey( "key", new AbstractEntryProcessor<String, SerializationValue>() { @Override public Object process(final Map.Entry<String, SerializationValue> entry) { return null; } }); assertEquals(1, SerializationValue.deSerializeCount.get()); }
static void executeEntryProcessor( IMap<String, String> map, EntryProcessor<String, String> entryProcessor) { map.executeOnKey(DEFAULT_KEY, entryProcessor); }