Commit a8b0744a authored by Matija Obreza's avatar Matija Obreza

Hazelcast configuration: interfaces and public address

parent 5815417d
......@@ -34,8 +34,19 @@ import com.hazelcast.spring.context.SpringManagedContext;
@EnableCaching
@Import({ HazelcastConfigDev.class, HazelcastConfigAWS.class })
public abstract class HazelcastConfig {
/// Interfaces on which HZ should bind
@Value("${hazelcast.interfaces}")
protected String hazelInterfaces;
/// TCP port to listen on
@Value("${hazelcast.port}")
protected int hazelPort;
/// The public address (in case of NAT)
@Value("${hazelcast.publicAddress}")
protected String hazelPublicAddress;
@Value("${hazelcast.instanceName}")
protected String instanceName;
@Value("${hazelcast.password}")
......
......@@ -16,6 +16,7 @@
package org.genesys2.spring.config;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -67,6 +68,18 @@ public class HazelcastConfigAWS extends HazelcastConfig {
network.setPort(hazelPort);
network.setPortAutoIncrement(false);
if (StringUtils.isNotBlank(hazelPublicAddress)) {
System.out.println("Hazelcast: Using public address " + hazelPublicAddress);
network.setPublicAddress(hazelPublicAddress);
}
if (StringUtils.isNotBlank(hazelInterfaces)) {
for (String hazelInterface : hazelInterfaces.split(",")) {
System.out.println("Hazelcast: Adding single interface " + hazelInterface);
network.getInterfaces().addInterface(hazelInterface);
}
}
JoinConfig join = network.getJoin();
join.getMulticastConfig().setEnabled(false);
......@@ -80,15 +93,15 @@ public class HazelcastConfigAWS extends HazelcastConfig {
MapConfig defaultMapConfig = new MapConfig();
defaultMapConfig.setName("default");
// defaultMapConfig.setTimeToLiveSeconds(0);
// defaultMapConfig.setTimeToLiveSeconds(0);
defaultMapConfig.setEvictionPolicy(EvictionPolicy.LFU);
// defaultMapConfig.setMaxIdleSeconds();
// defaultMapConfig.setMaxIdleSeconds();
MaxSizeConfig defaultMaxSizeConfig = new MaxSizeConfig();
defaultMaxSizeConfig.setSize(defaultCacheSize);
defaultMaxSizeConfig.setMaxSizePolicy(MaxSizePolicy.PER_NODE);
defaultMapConfig.setMaxSizeConfig(defaultMaxSizeConfig);
cfg.addMapConfig(defaultMapConfig);
MapConfig tileserverMapConfig = new MapConfig();
tileserverMapConfig.setName("tileserver");
tileserverMapConfig.setTimeToLiveSeconds(tileserverTTL);
......
......@@ -111,6 +111,9 @@ hazelcast.instanceName=hz-genesys-instance1
# Hazelcast cluster configuration
hazelcast.name=hz-genesys-development
hazelcast.password=hazelcastdevelopment
# Binding and public address
hazelcast.publicAddress=
hazelcast.interfaces=
hazelcast.port=5701
# AWS Autodetection
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment