Created
November 13, 2013 15:25
-
-
Save gurbuzali/7450859 to your computer and use it in GitHub Desktop.
ClientReconnnecteTest
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
| new Thread(){ | |
| public void run() { | |
| try { | |
| Thread.sleep(5000); | |
| System.err.println("starting cluster"); | |
| HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(); | |
| HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(); | |
| Thread.sleep(10000); | |
| System.err.println("shutting down cluster"); | |
| instance1.shutdown(); | |
| instance2.shutdown(); | |
| Thread.sleep(10000); | |
| System.err.println("re-establishing cluster"); | |
| instance1 = Hazelcast.newHazelcastInstance(); | |
| instance2 = Hazelcast.newHazelcastInstance(); | |
| } catch (InterruptedException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| }.start(); | |
| final ClientConfig clientConfig = new ClientConfig(); | |
| clientConfig.setConnectionAttemptLimit(Integer.MAX_VALUE); | |
| clientConfig.setConnectionTimeout(Integer.MAX_VALUE - 1000); | |
| final HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig); | |
| final IMap<Object,Object> m = client.getMap("m"); | |
| final Random random = new Random(System.currentTimeMillis()); | |
| while (true){ | |
| final int key = random.nextInt(1000); | |
| final long value = random.nextLong(); | |
| try { | |
| Thread.sleep(100); | |
| m.put(key, value); | |
| } catch (Exception e) { | |
| System.err.println("exception during put: " + e ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment