// setting up the cluster
System.out.println( Arrays.asList(environment).toString());
JoinConfig join = config.getNetworkConfig().getJoin();
join.getMulticastConfig().setEnabled(false);
join.getAwsConfig().setEnabled(false);
join.getTcpIpConfig().setEnabled(true).setMembers(Arrays.asList(environment));
CacheSimpleConfig cacheConfig = new CacheSimpleConfig();
cacheConfig.setName("buckets");
config.addCacheConfig(cacheConfig);```
ok. in this case you need to provide details about your environment and topology. clearly setPublicAddress("0.0.0.0")
is wrong.
the question is: what should be there instead? (if anything at all)
here is what I know so far:
is :point_up: correct?
setPublicAddress()
sets an IP address others should use to talk to this member. this is usually needed when you have multiple networks and what not.0.0.0.0
which CANNOT ever be used to talk to this member. The address 0.0.0.0
has a special meaning in IP networks.
join.getTcpIpConfig().setEnabled(true).setMembers(Arrays.asList(environment));
for this joiner you have to know all IP addresses anyway.setPublicAddress("127.0.0.1")
will work only on a single box. again, remove that. most likely you dont need at all.
Config config = new Config();
config.setLiteMember(false);
JoinConfig join = config.getNetworkConfig().getJoin();
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(true)
.setProperty("tag-key", "my-ec2-instance-tag-key")
.setProperty("tag-value", "my-ec2-instance-tag-value");
CacheSimpleConfig cacheConfig = new CacheSimpleConfig();
cacheConfig.setName("buckets");
config.addCacheConfig(cacheConfig);
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
ICacheManager cacheManager = hazelcastInstance.getCacheManager();
Cache<String, GridBucketState> cache = cacheManager.getCache("buckets");
return cache;
that looks fine to me.
some notes: config.setLiteMember(false);
is redundant as that's the default.
depending on your deployment scheme you might want to store hazelcastInstance
somewhere and shut it down when your application is about to shutdown. this is mostly concern if you deploy to an app server with multiple tenants (applications). If you are using something like Spring Boot (or appserver-less deployment in general) then it's usually not a concern.
Config config = new Config();
config.setLiteMember(false);
System.out.println( Arrays.asList(environment).toString());
JoinConfig join = config.getNetworkConfig().getJoin();
join.getMulticastConfig().setEnabled(false);
join.getAwsConfig().setEnabled(false);
join.getTcpIpConfig().setEnabled(true).setMembers(Arrays.asList("172.323.24.130","896.341.438.65"));
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(true)
.setProperty("tag-key", "Name1")
.setProperty("tag-value", " api-1")
.setProperty("access-key","1")
.setProperty("secret-key","1");
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(true)
.setProperty("tag-key", "Name2")
.setProperty("tag-value", " api-2")
.setProperty("access-key","2")
.setProperty("secret-key","2");
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(true)
.setProperty("tag-key", "Name2")
.setProperty("tag-value", " api-2")
.setProperty("access-key","2")
.setProperty("secret-key","2");