com.hazelcast.config.GroupConfig Java Examples
The following examples show how to use
com.hazelcast.config.GroupConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HazelcastSessionDao.java From dpCms with Apache License 2.0 | 5 votes |
public HazelcastSessionDao() { log.info("Initializing Hazelcast Shiro session persistence.."); // configure Hazelcast instance final Config cfg = new Config(); cfg.setInstanceName(hcInstanceName); // group configuration cfg.setGroupConfig(new GroupConfig(HC_GROUP_NAME, HC_GROUP_PASSWORD)); // network configuration initialization final NetworkConfig netCfg = new NetworkConfig(); netCfg.setPortAutoIncrement(true); netCfg.setPort(HC_PORT); // multicast final MulticastConfig mcCfg = new MulticastConfig(); mcCfg.setEnabled(false); mcCfg.setMulticastGroup(HC_MULTICAST_GROUP); mcCfg.setMulticastPort(HC_MULTICAST_PORT); // tcp final TcpIpConfig tcpCfg = new TcpIpConfig(); tcpCfg.addMember("127.0.0.1"); tcpCfg.setEnabled(false); // network join configuration final JoinConfig joinCfg = new JoinConfig(); joinCfg.setMulticastConfig(mcCfg); joinCfg.setTcpIpConfig(tcpCfg); netCfg.setJoin(joinCfg); // ssl netCfg.setSSLConfig(new SSLConfig().setEnabled(false)); // get map map = Hazelcast.newHazelcastInstance(cfg).getMap(HC_MAP); log.info("Hazelcast Shiro session persistence initialized."); }
Example #2
Source File: ClusterNode.java From modernmt with Apache License 2.0 | 5 votes |
private Config getHazelcastConfig(NodeConfig nodeConfig, long interval, TimeUnit unit) { Config hazelcastConfig = new XmlConfigBuilder().build(); hazelcastConfig.setGroupConfig( new GroupConfig().setName(this.clusterName)); NetworkConfig networkConfig = nodeConfig.getNetworkConfig(); if (unit != null && interval > 0L) { long seconds = Math.max(unit.toSeconds(interval), 1L); hazelcastConfig.setProperty("hazelcast.max.join.seconds", Long.toString(seconds)); } String host = networkConfig.getHost(); if (host != null) hazelcastConfig.getNetworkConfig().setPublicAddress(host); hazelcastConfig.getNetworkConfig().setPort(networkConfig.getPort()); String listenInterface = networkConfig.getListeningInterface(); if (listenInterface != null) { hazelcastConfig.getNetworkConfig().getInterfaces() .setEnabled(true) .addInterface(listenInterface); hazelcastConfig.setProperty("hazelcast.local.localAddress", listenInterface); hazelcastConfig.setProperty("hazelcast.local.publicAddress", listenInterface); } JoinConfig joinConfig = networkConfig.getJoinConfig(); JoinConfig.Member[] members = joinConfig.getMembers(); if (members != null && members.length > 0) { TcpIpConfig tcpIpConfig = hazelcastConfig.getNetworkConfig().getJoin().getTcpIpConfig(); tcpIpConfig.setConnectionTimeoutSeconds(joinConfig.getTimeout()); tcpIpConfig.setEnabled(true); for (JoinConfig.Member member : members) tcpIpConfig.addMember(member.getHost() + ":" + member.getPort()); } return hazelcastConfig; }
Example #3
Source File: HazelcastSessionDao.java From spring-boot-shiro-orientdb with Apache License 2.0 | 5 votes |
public HazelcastSessionDao() { log.info("Initializing Hazelcast Shiro session persistence.."); // configure Hazelcast instance final Config cfg = new Config(); cfg.setInstanceName(hcInstanceName); // group configuration cfg.setGroupConfig(new GroupConfig(HC_GROUP_NAME, HC_GROUP_PASSWORD)); // network configuration initialization final NetworkConfig netCfg = new NetworkConfig(); netCfg.setPortAutoIncrement(true); netCfg.setPort(HC_PORT); // multicast final MulticastConfig mcCfg = new MulticastConfig(); mcCfg.setEnabled(false); mcCfg.setMulticastGroup(HC_MULTICAST_GROUP); mcCfg.setMulticastPort(HC_MULTICAST_PORT); // tcp final TcpIpConfig tcpCfg = new TcpIpConfig(); tcpCfg.addMember("127.0.0.1"); tcpCfg.setEnabled(false); // network join configuration final JoinConfig joinCfg = new JoinConfig(); joinCfg.setMulticastConfig(mcCfg); joinCfg.setTcpIpConfig(tcpCfg); netCfg.setJoin(joinCfg); // ssl netCfg.setSSLConfig(new SSLConfig().setEnabled(false)); // get map map = Hazelcast.newHazelcastInstance(cfg).getMap(HC_MAP); log.info("Hazelcast Shiro session persistence initialized."); }
Example #4
Source File: NativeClient.java From tutorials with MIT License | 5 votes |
public static void main(String[] args) throws InterruptedException { ClientConfig config = new ClientConfig(); GroupConfig groupConfig = config.getGroupConfig(); groupConfig.setName("dev"); groupConfig.setPassword("dev-pass"); HazelcastInstance hazelcastInstanceClient = HazelcastClient.newHazelcastClient(config); IMap<Long, String> map = hazelcastInstanceClient.getMap("data"); for (Entry<Long, String> entry : map.entrySet()) { System.out.println(String.format("Key: %d, Value: %s", entry.getKey(), entry.getValue())); } }