Class LocalFederationManagement
- java.lang.Object
-
- org.eclipse.mosaic.rti.federation.LocalFederationManagement
-
- All Implemented Interfaces:
FederationManagement
- Direct Known Subclasses:
DistributedFederationManagement
public class LocalFederationManagement extends Object implements FederationManagement
This implementation ofFederationManagement
allows local administration only.- See Also:
FederationManagement
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,FederateAmbassador>
federateAmbassadors
Mapping between federation id and federation ambassador instances.protected Map<String,FederateDescriptor>
federateDescriptors
Mapping between federation id and federation descriptors.protected ComponentProvider
federation
The simulation components of this federation.protected static String
LOCALHOST
Constant representing the local host address.protected org.slf4j.Logger
log
protected com.google.common.collect.Multimap<String,ProcessLoggingThread>
loggingThreads
protected WatchDog
watchDog
-
Constructor Summary
Constructors Constructor Description LocalFederationManagement(ComponentProvider federation)
Constructor with string identifying a federation as parameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFederate(FederateDescriptor descriptor)
Adds a federate to the federation.void
createFederation()
Creates an empty federation.protected void
deployFederate(FederateDescriptor descriptor)
Deploys a federate represented by its descriptor on the local machine.FederateAmbassador
getAmbassador(String federateId)
Returns a reference to the ambassador associated with the given federate id.Collection<FederateAmbassador>
getAmbassadors()
Returns a collection of all ambassadors associated with joined federates.String
getFederationId()
Returns the id of the simulated federation.boolean
isFederateJoined(String federateId)
Checks whether a federate is joined or not.void
setWatchdog(WatchDog watchdog)
Sets theWatchDog
which detects broken federates.protected void
startFederate(FederateDescriptor handle)
Starts a federate represented by its handle on the local machine.protected void
stopFederate(FederateDescriptor handle, boolean forceStop)
Stops a federate represented by its handle on the local machine.void
stopFederation()
Stops the federation.protected void
undeployFederate(FederateDescriptor handle)
Undeploys a federate represented by its handle on the local machine.
-
-
-
Field Detail
-
LOCALHOST
protected static final String LOCALHOST
Constant representing the local host address.- See Also:
- Constant Field Values
-
log
protected final org.slf4j.Logger log
-
federation
protected final ComponentProvider federation
The simulation components of this federation.
-
federateDescriptors
protected final Map<String,FederateDescriptor> federateDescriptors
Mapping between federation id and federation descriptors.
-
federateAmbassadors
protected final Map<String,FederateAmbassador> federateAmbassadors
Mapping between federation id and federation ambassador instances.
-
loggingThreads
protected final com.google.common.collect.Multimap<String,ProcessLoggingThread> loggingThreads
-
watchDog
protected WatchDog watchDog
-
-
Constructor Detail
-
LocalFederationManagement
public LocalFederationManagement(ComponentProvider federation)
Constructor with string identifying a federation as parameter.- Parameters:
federation
- federation
-
-
Method Detail
-
createFederation
public void createFederation()
Description copied from interface:FederationManagement
Creates an empty federation. After calling this method it is possible for federates to join the federation.- Specified by:
createFederation
in interfaceFederationManagement
-
addFederate
public void addFederate(FederateDescriptor descriptor) throws Exception
Description copied from interface:FederationManagement
Adds a federate to the federation. This method can be called either before or during runtime of the simulation of the federation.- Specified by:
addFederate
in interfaceFederationManagement
- Parameters:
descriptor
- object containing all data that are necessary to manage the lifecycle of a federate- Throws:
Exception
-
isFederateJoined
public boolean isFederateJoined(String federateId)
Description copied from interface:FederationManagement
Checks whether a federate is joined or not.- Specified by:
isFederateJoined
in interfaceFederationManagement
- Parameters:
federateId
- unique string identifying the federate- Returns:
- a boolean, whether a federate is joined or not
-
getAmbassador
public FederateAmbassador getAmbassador(String federateId)
Description copied from interface:FederationManagement
Returns a reference to the ambassador associated with the given federate id.- Specified by:
getAmbassador
in interfaceFederationManagement
- Parameters:
federateId
- unique string identifying the federate- Returns:
- ambassador associated with the given federate id
-
getAmbassadors
public Collection<FederateAmbassador> getAmbassadors()
Description copied from interface:FederationManagement
Returns a collection of all ambassadors associated with joined federates.- Specified by:
getAmbassadors
in interfaceFederationManagement
- Returns:
- collection of all ambassadors
-
stopFederation
public void stopFederation() throws Exception
Description copied from interface:FederationManagement
Stops the federation. All resources of federates are freed. Afterwards, no new federates are allowed to join.- Specified by:
stopFederation
in interfaceFederationManagement
- Throws:
Exception
-
deployFederate
protected void deployFederate(FederateDescriptor descriptor) throws Exception
Deploys a federate represented by its descriptor on the local machine.- Parameters:
descriptor
- federate descriptor consisting all necessary data to deploy a federate- Throws:
Exception
- if the federate could not be deployed
-
startFederate
protected void startFederate(FederateDescriptor handle) throws Exception
Starts a federate represented by its handle on the local machine.- Parameters:
handle
- federate handle consisting all necessary data to start a federate- Throws:
Exception
- if the federate could not be started
-
stopFederate
protected void stopFederate(FederateDescriptor handle, boolean forceStop) throws Exception
Stops a federate represented by its handle on the local machine.- Parameters:
handle
- federate handle consisting all necessary data to stop a federate- Throws:
Exception
- if the federate could not be stopped
-
undeployFederate
protected void undeployFederate(FederateDescriptor handle) throws Exception
Undeploys a federate represented by its handle on the local machine.- Parameters:
handle
- federate handle consisting all necessary data to undeploy a federate- Throws:
Exception
- if the federate could not be undeployed
-
getFederationId
public String getFederationId()
Description copied from interface:FederationManagement
Returns the id of the simulated federation.- Specified by:
getFederationId
in interfaceFederationManagement
- Returns:
- the id of the simulated federation.
-
setWatchdog
public void setWatchdog(WatchDog watchdog)
Description copied from interface:FederationManagement
Sets theWatchDog
which detects broken federates.- Specified by:
setWatchdog
in interfaceFederationManagement
-
-