-
Notifications
You must be signed in to change notification settings - Fork 3
Federate configuration
We provide a 3-level parametrization for the Federates. This document summarizes how it should work.
Federate configuration has been implemented in a generic, extensible way so that developers can set up their own parameters/configuration for their own federates.
The configuration framework can be found in the org.cpswt.config
namespace. It defines classes to parse configuration files along with annotations that are used to represent configuration settings in the core and user codebase.
FederateParameter
is an annotation that should be used with every configuration parameter field in order to indicate the framework that it is an expected/used parameter. When a field is annotated with FederateParameter
, you can use it on all levels (see Loading order below).
FederateParameterOptional
is an extra annotation that can be used with FederateParameter
. It indicates that a parameter is not mandatory and the code will take care of setting its value (i.e.: generate name if not provided).
The FederateConfig
is the bare minimum information that a federate must get through configuration. This includes the following fields:
federateType
federationId
isLateJoiner
lookAhead
stepSize
-
name
[optional]
The config framework support that you can create your own configuration model for your custom federates.
A working example is FederateConfig
-> FederationManagerConfig
extension. To create your own custom federate config, simply inherit from FederateConfig
and define your own public fields annotated with FederateParameter
, everything else is taken care of by the config framework.
IMPORTANT: You must use flat data-structure (no embedded objects/fields) in order to keep these convenience services of the config framework.
This class is responsible for parsing
- the configuration file provided by the user/runtime
- the command-line arguments provided by the user
This parser class will automatically parse and fill those fields that are present in your configuration class. Follow these rules and you won't get any errors:
- Define your own config class that inherits from
FederateConfig
(or one of its inherited classes) - Define your extra parameters as
public
. Currently, the supported types areString
,Double
,Integer
,Long
,Boolean
- In your code, provide the configuration class type to the
federateConfigParser.parseArgs(args, YOURCONFIGCLASS.class);
- Create your
JSON
configuration file that includes all the fields that can be reached from your class (or, that are annotated asFederateParameter
) including the fields from the superclass(es) as well! - Pass the
-configFile <config.json>
parameter to the runtime - Pass optionally other config parameters to the runtime that will overwrite those defined in the config file (i.e.: -stepSize 1.0)
IMPORTANT
The names of the fields that are defined in your config class will be used automatically to inspect command line arguments.
There is a default
configuration file that contains all the default parameters. If no other configuration is provided for a federate, this should be loaded.
-
The config framework tries to load a file that resides as a resource in the project that contains the passed configuration class (see step #3 above).
-
If above attempt is unsuccessful, the framework tries to load a file from the path that is defined in the
CPSWTNG_FEDERATE_DEFAULT_CONFIG
environment variable.
If the user provides a valid configuration file that is passed with a special configFile
parameter, parameters are going to be read from this file.
On top of all other levels, if the user provides named parameters (besides configFile
), those parameters overwrite the previously loaded parameters' values.
In pom.xml
there should be a configFile
parameter such that the following command would be valid:
mvn exec:exec -DconfigFile=/path/to/file
The config framework will maintain a state while loading the configuration settings and will warn
the user if a configuration parameter was not provided as an input but it is indicated on code level that it is expected. If such situation occurs, the default value for the parameter in question will be set by the runtime environment.
In previous versions configuring the federates was through command line arguments and configuring the federation manager was done through command line arguments and a special config file called script.xml
. This has been changed with our new config framework.
To configure the federation manager, script.xml
is no longer used, but we support JSON
-based configuration files. Specifically the configuration for a federation manager includes the following fields:
federateType
federationId
isLateJoiner
lookAhead
stepSize
-
name
[optional] bindHost
port
controlEndpoint
federatesEndpoint
federationEndTime
realTimeMode
fedFile
experimentConfig
Besides the ordinary federation manager specific values, note the last parameter called experimentConfig
. This represents a path to another JSON
file that holds information about the domain, the experiment that we're running.
The experiment configuration includes the following fields (currently):
-
federateTypesAllowed
- the list of the federate types that are supported to join the federation -
expectedFederates
- the list of the type and number of federates that are considered expected in the federation -
lateJoinerFederates
- the list of the type and number of the federates that are considered late joiners in the federation -
pauseTimes
- a list of time points when the federation should pause automatically -
coaDefinition
- the path to the COA definiton file -
coaSelection
- the path to the COA selection file -
terminateOnCOAFinish
- whether the federation should terminate after COA execution is finished
« Home