Below is the HazelCast Programmatic Configuration given in Documentation but it is unable to add members in HazelCast Cluster.
Config cfg = new Config();
Hazelcast.newHazelcastInstance(cfg);
cfg.setProperty("hazelcast.initial.min.cluster.size","3");
cfg.getGroupConfig().setName("DEV").setPassword("DEV-pass");
NetworkConfig network = cfg.getNetworkConfig();
JoinConfig join = network.getJoin();
TcpIpConfig tcpipConfig=join.getTcpIpConfig();
tcpipConfig.addMember("172.17.153.87").addMember("10.45.67.100")
.setRequiredMember("192.168.10.100").setEnabled(true);
network.getInterfaces().setEnabled(true).addInterface("10.45.67.*");
System.out.println(tcpipConfig.isEnabled());
System.out.println(tcpipConfig.getMembers());
MapConfig mapCfg = new MapConfig();
mapCfg.setName("testMap");
mapCfg.setBackupCount(2);
mapCfg.getMaxSizeConfig().setSize(10000);
mapCfg.setTimeToLiveSeconds(300);
MapStoreConfig mapStoreCfg = new MapStoreConfig();
mapStoreCfg.setClassName("com.hazelcast.examples.DummyStore").setEnabled(true);
mapCfg.setMapStoreConfig(mapStoreCfg);
NearCacheConfig nearCacheConfig = new NearCacheConfig();
nearCacheConfig.setMaxSize(1000).setMaxIdleSeconds(120).setTimeToLiveSeconds(300);
mapCfg.setNearCacheConfig(nearCacheConfig);
cfg.addMapConfig(mapCfg);
please look at the code and let me if any thing further modification is required to add members to hazelcast cluster
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…