Last active
August 29, 2015 14:03
-
-
Save gurbuzali/ac05b8fcd31c4fe62efe to your computer and use it in GitHub Desktop.
max-idle test
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("default"); | |
| mapConfig.setBackupCount(0).setAsyncBackupCount(1).setMaxIdleSeconds(10); | |
| final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config); | |
| final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config); | |
| final IMap<Object, Object> map = instance1.getMap("default"); | |
| String val = "val"; | |
| for (int i = 0; i < 1000; i++) { | |
| map.put(i, val); | |
| } | |
| int i = 1; | |
| while (true) { | |
| printStats(instance1, instance2, i++); | |
| Thread.sleep(5000); | |
| } | |
| } | |
| static void printStats(HazelcastInstance instance1, HazelcastInstance instance2, int counter) { | |
| final LocalMapStats stats1 = instance1.getMap("default").getLocalMapStats(); | |
| System.err.println("---------------------------------------- counter: " + counter); | |
| System.err.println("instance1 backup: " + stats1.getBackupEntryCount()); | |
| System.err.println("instance1 own: " + stats1.getOwnedEntryCount()); | |
| final LocalMapStats stats2 = instance2.getMap("default").getLocalMapStats(); | |
| System.err.println("instance2 backup: " + stats2.getBackupEntryCount()); | |
| System.err.println("instance2 own: " + stats2.getOwnedEntryCount()); | |
| System.err.println(""); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment