Skip to content

Commit

Permalink
[sre] Add warning if the "hazelcast.local.localAddress" environment v…
Browse files Browse the repository at this point in the history
…ariable is manually set.

close #882

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Oct 31, 2018
1 parent 3270e4c commit dc917eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Expand Up @@ -25,6 +25,7 @@
import java.net.URI;
import java.text.MessageFormat;

import com.google.common.base.Strings;
import com.google.common.util.concurrent.Service;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
Expand Down Expand Up @@ -56,12 +57,15 @@
* {@link StandardJanusPlatformModule}.
*
* @author $Author: srodriguez$
* @author $Author: sgalland$
* @version $FullVersion$
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
*/
public class HazelcastModule extends AbstractModule {

private static final String HAZELCAST_LOCAL_ADDRESS = "hazelcast.local.localAddress"; //$NON-NLS-1$

@Override
protected void configure() {
final SerializerConfig sc = new SerializerConfig();
Expand Down Expand Up @@ -123,7 +127,15 @@ private static HazelcastInstance createHazelcastInstance(Config config, LogServi

assert adr != null;
final String hostname = adr.getHostAddress();
config.setProperty("hazelcast.local.localAddress", hostname); //$NON-NLS-1$

final String hazelcastConfigVariable = JanusConfig.getSystemProperty(HAZELCAST_LOCAL_ADDRESS, null);
if (!Strings.isNullOrEmpty(hazelcastConfigVariable) && !hazelcastConfigVariable.equals(hostname)) {
logService.getKernelLogger().warning(MessageFormat.format("UNSUPPORTED_HAZELCAST_ADDRESS", //$NON-NLS-1$
HAZELCAST_LOCAL_ADDRESS, hazelcastConfigVariable,
JanusConfig.PUB_URI, uri.toString()));
}

config.setProperty(HAZELCAST_LOCAL_ADDRESS, hostname);

final NetworkConfig networkConfig = config.getNetworkConfig();
final MulticastConfig multicastConfig = networkConfig.getJoin().getMulticastConfig();
Expand Down
@@ -1 +1,2 @@
INVALID_PUB_URI = The hostname given in the PUB_URI is unknown: {0}
UNSUPPORTED_HAZELCAST_ADDRESS = Unsupported environment variable {0}. It is set to {1}. Janus kernel uses the environment variable {2} for selecting the networking interface. It is set to {3}.

0 comments on commit dc917eb

Please sign in to comment.