Skip to content

Instantly share code, notes, and snippets.

@ekirastogi
Created November 1, 2015 17:16
Show Gist options
  • Save ekirastogi/eca85c09837ff002371c to your computer and use it in GitHub Desktop.
Save ekirastogi/eca85c09837ff002371c to your computer and use it in GitHub Desktop.
package com.ekiras.demo;
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.core.HazelcastInstance;
/**
* Created by ekansh on 1/11/15.
*/
public class HazelCastConfig{
public static HazelcastInstance hazelcastInstance;
public static String address;
public static HazelcastInstance getHazelcastInstance(){
if(!(hazelcastInstance!=null && hazelcastInstance.getLifecycleService().isRunning())){
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setConnectionAttemptLimit(10);
clientConfig.getNetworkConfig().setConnectionAttemptPeriod(24 * 60);
clientConfig.getNetworkConfig().setConnectionTimeout(1000);
clientConfig.getNetworkConfig().addAddress(address);
hazelcastInstance = HazelcastClient.newHazelcastClient(clientConfig);
}
return hazelcastInstance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment