Last active
August 29, 2015 14:00
-
-
Save gurbuzali/11212950 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public static void main(String[] args) throws Exception { | |
| final Config config = new Config(); | |
| final MapConfig mapConfig = config.getMapConfig("map"); | |
| final MapStoreConfig mapStoreConfig = new MapStoreConfig(); | |
| mapStoreConfig.setEnabled(true); | |
| mapStoreConfig.setWriteDelaySeconds(3); | |
| final MyMapStore myMapStore = new MyMapStore(); | |
| mapStoreConfig.setImplementation(myMapStore); | |
| mapConfig.setMapStoreConfig(mapStoreConfig); | |
| final HazelcastInstance instance = Hazelcast.newHazelcastInstance(config); | |
| final IMap<String, String> map = instance.getMap("map"); | |
| final int count = 10000; | |
| for (int i = 0; i < count; i++) { | |
| final String s = String.valueOf(i); | |
| map.putAsync(s, s); | |
| } | |
| System.err.println("asdf put done"); | |
| assertTrueEventually(new AssertTask() { | |
| @Override | |
| public void run() throws Exception { | |
| assertEquals(count, myMapStore.counter.get()); | |
| } | |
| }); | |
| } | |
| public static class MyMapStore implements MapStore<String, String> { | |
| public final AtomicInteger counter = new AtomicInteger(); | |
| @Override | |
| public void store(final String key, final String value) { | |
| counter.incrementAndGet(); | |
| } | |
| @Override | |
| public void storeAll(final Map<String, String> map) { | |
| for (Map.Entry<String, String> entry : map.entrySet()) { | |
| store(entry.getKey(), entry.getValue()); | |
| } | |
| } | |
| @Override | |
| public void delete(final String key) { | |
| } | |
| @Override | |
| public void deleteAll(final Collection<String> keys) { | |
| } | |
| @Override | |
| public String load(final String key) { | |
| return null; | |
| } | |
| @Override | |
| public Map<String, String> loadAll(final Collection<String> keys) { | |
| return null; | |
| } | |
| @Override | |
| public Set<String> loadAllKeys() { | |
| return null; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment