Last active
July 5, 2016 13:51
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testGithubIssue8196() throws InterruptedException { | |
MapLoader mapLoader = new MapLoader() { | |
@Override | |
public Object load(Object key) { | |
if(key.equals(1)) { | |
sleepAtLeastMillis(100); | |
return "Porsche"; | |
} | |
if(key.equals(2)) { | |
sleepAtLeastMillis(100); | |
return "BMW"; | |
} | |
return null; | |
} | |
@Override | |
public Map loadAll(Collection keys) { | |
Map<Integer, String> entries = new HashMap<Integer, String>(); | |
if(keys.contains(1)) { | |
sleepAtLeastMillis(100); | |
entries.put(1, "Porsche"); | |
} | |
if(keys.contains(2)) { | |
sleepAtLeastMillis(100); | |
entries.put(2, "BMW"); | |
} | |
return entries; | |
} | |
@Override | |
public Set loadAllKeys() { | |
Set<Integer> keys = new HashSet<Integer>(); | |
keys.add(1); | |
keys.add(2); | |
return keys; | |
} | |
}; | |
Config config = getConfig(); | |
MapConfig mapConfig = config.getMapConfig("foo"); | |
MapStoreConfig mapStoreConfig = new MapStoreConfig(); | |
mapStoreConfig.setInitialLoadMode(MapStoreConfig.InitialLoadMode.LAZY); | |
mapStoreConfig.setEnabled(true); | |
mapStoreConfig.setWriteDelaySeconds(5); | |
mapStoreConfig.setWriteBatchSize(10); | |
mapStoreConfig.setImplementation(mapLoader); | |
mapConfig.setMapStoreConfig(mapStoreConfig); | |
TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2); | |
HazelcastInstance[] hz = nodeFactory.newInstances(config, 2); | |
Map map = hz[0].getMap(mapConfig.getName()); | |
System.err.println("Waiting for the cluster to be operational - started"); | |
Thread.sleep(5000); | |
System.err.println("Waiting for the cluster to be operational - finished"); | |
Collection result = map.values(); | |
System.err.println(result); | |
assertEquals(2, result.size()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment