Skip to content

Commit

Permalink
[sre] Fixing the networking configuration.
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Apr 11, 2021
1 parent 8b6e02b commit b35d0f8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
@@ -1,2 +1,2 @@
io.sarl.sre.network.boot.internal.NetworkModuleProvider
io.sarl.sre.network.boot.configs.SreNetworkConfigModuleProvider
io.sarl.sre.network.boot.internal.NetworkModuleProvider
Expand Up @@ -129,6 +129,20 @@ class SreNetworkConfig {
*/
public static val DEFAULT_IP_LIST_CLUSTER = "127.0.0.1"

/**
* Name of the property that enable or disable the special configuration for
* a local instance of Hazelcast. If this property is evaluated to {@code true},
* it overrides all the other hazelcast configuration.
*/
public static val LOCAL_HAZELCAST_INSTANCE_NAME = PREFIX + ".localHazelcastInstance"; // $NON-NLS-1$

/**
* Default value of the property that enable or disable the special configuration for
* a local instance of Hazelcast. If this property is evaluated to {@code true},
* it overrides all the other hazelcast configuration.
*/
public static val DEFAULT_LOCAL_HAZELCAST_INSTANCE_VALUE = false

/**
* Regexp of a quarter of an IP adress
*/
Expand All @@ -151,6 +165,8 @@ class SreNetworkConfig {

var enable : boolean = DEFAULT_ENABLE_VALUE

var localHazelcastInstance : boolean = DEFAULT_LOCAL_HAZELCAST_INSTANCE_VALUE

var clusterName : String

var joinMethod : JoinMethod
Expand All @@ -167,7 +183,7 @@ class SreNetworkConfig {

@Inject
var generalConfiguration : SreConfig

/** Replies the flag that enable or disable the networking features.
*
* @return the enabling state of the enabling state of the networking extension.
Expand All @@ -187,6 +203,29 @@ class SreNetworkConfig {
this.enable = enable
}

/** Replies the property that enable or disable the special configuration for
* a local instance of Hazelcast. If this property is evaluated to {@code true},
* it overrides all the other hazelcast configuration.
*
* @return the enabling state for local Hazelcast instance.
*/
def getLocalHazelcastInstance : boolean {
// This function is not defined with the name "isEnable" because it is not compatible with
// the Bootique API.
this.localHazelcastInstance
}

/** Change the property that enable or disable the special configuration for
* a local instance of Hazelcast. If this property is evaluated to {@code true},
* it overrides all the other hazelcast configuration.
*
* @param enable the enabling state.
*/
@BQConfigProperty("Enable or disable the local Hazelcast instance.")
def setLocalHazelcastInstance(enable : boolean) {
this.localHazelcastInstance = enable
}

/** Replies a cluster name following the standard naming convention.
*
* @param rootContextId is the identifier of the root context of the SRE.
Expand Down Expand Up @@ -401,13 +440,16 @@ class SreNetworkConfigModule extends AbstractModule {
public static val NETWORK_LONG_OPTION = "network"

override configure : void {
VariableDecls::extend(binder).declareVar(NETWORK_LONG_OPTION)
VariableDecls::extend(binder).declareVar(ENABLE_NAME)
//
val cpDescription = MessageFormat::format(Messages::SreNetworkConfigModule_1, DEFAULT_ENABLE_VALUE.toString,
VariableNames::toEnvironmentVariableName(ENABLE_NAME))
binder.extend.addOption(OptionMetadata::builder(NETWORK_LONG_OPTION, cpDescription)
.valueRequired(Messages::SreNetworkConfigModule_0)
.build)
.mapConfigPath(NETWORK_LONG_OPTION, ENABLE_NAME)
//
VariableDecls::extend(binder).declareVar(LOCAL_HAZELCAST_INSTANCE_NAME)
}

/** Replies the instance of the network configuration.
Expand Down

0 comments on commit b35d0f8

Please sign in to comment.