I am using Hazelcast native java client to connect remote Hazelcast cluster.
Below is the code, I want to configure TTL, Max Size , Eviction policy for below IMap tranMap
from the java client.
Can anyone suggest how to set this parameters from the hazelcast client for each IMap. I know how to configure it at cluster level in hazelcast.xml. But for my application use case, I have to configure it programmatically in ClientConfig object used in creating HazelcastClient instance.
ClientConfig config = new ClientConfig();
String[] addresses = { "192.178.11.01:5701", "192.178.30.18:5702" };
config.getNetworkConfig().addAddress(addresses);
HazelcastInstance hazelcastInstance = HazelcastClient.newHazelcastClient(config);
IMap<Integer, Transaction> map = hazelcastInstance.getMap("tranMap");
if you don't want to re-configure an existing map but just add a new configuration for a map which you'll going to use, it is doable
HazelcastInstance client = HazelcastClient.newHazelcastClient();
Config config = client.getConfig();
config.addMapConfig(new MapConfig()
.setName("foo")
.setTimeToLiveSeconds(10));
Remember to not create the map before configuring, so getMap
call should be after you add the config.