public class ReachabilityWorker extends java.lang.Thread implements StopableObject, PropertyServiceNotifiable
Modifier and Type | Field and Description |
---|---|
private boolean |
active
Holds the activity state of this object.
|
private boolean |
ended
Holds the information, if
run() statement has ended or not. |
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPPublisher |
globalControlTopic
The
LPPublisher which sends control messages to other components via the ActiveMQ. |
private PropertyService |
propertyService
The property service thread
PropertyService . |
private java.util.List<java.lang.String> |
registeredReasoners
A
List of registered reasoners. |
private java.util.Map<ReasonerDimension,java.util.List<java.lang.String>> |
registeredSensors
|
private Registry |
registryService
The registry service thread
Registry . |
private java.lang.String |
runningReasoner
The actual running reasoner.
|
private java.util.Map<ReasonerDimension,java.lang.String> |
runningSensors
A
Map of context dimensions (ReasonerDimension ) to sensor agents, which contains all actual
running sensor agents and their specific context dimension. |
private boolean |
shutDown
Determines if the method
shutDown() has been called. |
Constructor and Description |
---|
ReachabilityWorker()
Constructs a new ReachabilityWorker object.
|
Modifier and Type | Method and Description |
---|---|
void |
activ(boolean pred)
Method to set the active status
active . |
private void |
end()
The method will be called at the end of the method
run() and will notify all connected sensor adapters
and the reasoners. |
boolean |
ended()
Determines if the thread has ended its
run() method. |
java.util.Map<java.lang.String,java.lang.String> |
getValuesForProperty(java.lang.String property)
It may occur that a property is defined as
DisplayType.AGENT_DEFINED , which means that the value range is
dynamically defined at runtime. |
private java.lang.String |
getVersion()
Returns the agents version.
|
private void |
init()
This method opens the required ActiveMQ connections.
|
boolean |
isActive()
Determines whether the method
StopableObject.shutDown() has been called on this object or not. |
boolean |
isSilent()
Determines if the thread is running in silent mode.
|
java.util.Properties |
loadCurrentProperties(ConfigType propertiesType)
The
PropertyService requests the actual properties of a certain ConfigType from its creator. |
void |
register(RegistryAgentType type,
java.lang.String name,
ReasonerDimension dimension)
Registers a new component.
|
void |
run()
General run method which calls the initialize and end methods and coordinates the different components.
|
private void |
sendControlMessage(ConfigOrder order,
java.lang.String id)
Sends a new control message.
|
void |
shutDown()
Shuts the object down.
|
private void |
shutDownAllSensorAdapters()
Stops all active sensor agents.
|
private void |
shutDownReasoningEngine()
Stops the active reasoning engine.
|
private void |
startReasoningEngine(java.lang.String reasoner)
Starts a certain reasoner agent by sending a start control message.
|
private void |
startSensor(ReasonerDimension dimension,
java.lang.String sensor)
Starts a certain sensor agent by sending a start control message.
|
private void |
stopReasoningEngine(java.lang.String reasoner)
Stops a certain reasoner agent by sending a sleep control message.
|
private void |
stopSensor(ReasonerDimension dimension,
java.lang.String sensor)
Stops a certain sensor agent by sending a sleep control message.
|
private void |
suspendReasoningEngine(java.lang.String reasoner)
Suspends a certain reasoner agent by sending a sleep control message.
|
private void |
suspendSensor(ReasonerDimension dimension,
java.lang.String sensor)
Suspends a certain sensor agent by sending a sleep control message.
|
void |
unregister(RegistryAgentType type,
java.lang.String name,
ReasonerDimension dimension)
Unregisters a component (sensor or reasoner agent) and handles its consequences.
|
void |
updateProperties(java.util.Properties newProps,
java.util.Properties changedProps,
ConfigType type)
Updates the local properties by new ones.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
private boolean active
false
, the worker won't publish its results on
the result topic.private boolean shutDown
shutDown()
has been called.private boolean ended
run()
statement has ended or not.private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPPublisher globalControlTopic
LPPublisher
which sends control messages to other components via the ActiveMQ.private java.util.List<java.lang.String> registeredReasoners
List
of registered reasoners.private java.lang.String runningReasoner
private java.util.Map<ReasonerDimension,java.util.List<java.lang.String>> registeredSensors
Map
of context dimensions (ReasonerDimension
) to a List
of sensors. This map holds
all registered sensor agents and their specific context dimensions.private java.util.Map<ReasonerDimension,java.lang.String> runningSensors
Map
of context dimensions (ReasonerDimension
) to sensor agents, which contains all actual
running sensor agents and their specific context dimension.private PropertyService propertyService
PropertyService
.public ReachabilityWorker()
public final void activ(boolean pred)
active
. If the method is called with its parameter set to
false
, the worker will stop publishing its results on the result topic.pred
- If false
the worker will stop publishing results on the result topic.public final boolean isSilent()
isSilent
in interface PropertyServiceNotifiable
true
if the worker is running in silent mode, otherwise
false
.public final void shutDown()
StopableObject
shutDown
in interface StopableObject
StopableObject.shutDown()
public final boolean isActive()
StopableObject
StopableObject.shutDown()
has been called on this object or not.isActive
in interface StopableObject
true
if shutDown()
wasn't called, otherwise
false
.StopableObject.isActive()
public final boolean ended()
run()
method.true
if the thread has ended, otherwise false
.public final void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
Thread.run()
private void init()
private void startReasoningEngine(java.lang.String reasoner)
reasoner
- The reasoner agents name as String
.private void suspendReasoningEngine(java.lang.String reasoner)
reasoner
- The reasoner agents name as String
.private void stopReasoningEngine(java.lang.String reasoner)
reasoner
- The reasoner agents name as String
.private void startSensor(ReasonerDimension dimension, java.lang.String sensor)
dimension
- The sensor agents supported context dimension as ReasonerDimension
.sensor
- The sensor agents name as String
.private void suspendSensor(ReasonerDimension dimension, java.lang.String sensor)
dimension
- The sensor agents supported context dimension as ReasonerDimension
.sensor
- The sensor agents name as String
.private void stopSensor(ReasonerDimension dimension, java.lang.String sensor)
dimension
- The sensor agents supported context dimension as ReasonerDimension
.sensor
- The sensor agents name as String
.private void sendControlMessage(ConfigOrder order, java.lang.String id)
order
- The ConfigOrder
for control message.id
- The recipients ID which shall receive the control message.private void end()
run()
and will notify all connected sensor adapters
and the reasoners. Furthermore it disconnects all open ActiveMQ topics and shut down all started services.private void shutDownAllSensorAdapters()
private void shutDownReasoningEngine()
public final void updateProperties(java.util.Properties newProps, java.util.Properties changedProps, ConfigType type)
PropertyService
if a new
configuration arises on the ActiveMQ.updateProperties
in interface PropertyServiceNotifiable
newProps
- The new Properties
set.changedProps
- Only the changed Properties
.type
- The type of properties as ConfigType
.public final java.util.Properties loadCurrentProperties(ConfigType propertiesType)
PropertyServiceNotifiable
PropertyService
requests the actual properties of a certain ConfigType
from its creator. The
creator should reload its local property set and return them to the PropertyService
.loadCurrentProperties
in interface PropertyServiceNotifiable
propertiesType
- The ConfigType
for which the local properties shall be loaded an returned.PropertyServiceNotifiable.loadCurrentProperties(ConfigType)
public final java.util.Map<java.lang.String,java.lang.String> getValuesForProperty(java.lang.String property)
PropertyServiceNotifiable
DisplayType.AGENT_DEFINED
, which means that the value range is
dynamically defined at runtime. In this case, the PropertyService
asks its creator about the current
value range of this property by using this method.getValuesForProperty
in interface PropertyServiceNotifiable
property
- The name of the requested property.PropertyServiceNotifiable.getValuesForProperty(String)
public final void register(RegistryAgentType type, java.lang.String name, ReasonerDimension dimension)
type
- The component type as value of RegistryAgentType
.name
- The name of the new component (the ID on which it reacts on control messages).dimension
- The supported context dimension (required for RegistryAgentType.SENSOR
.public final void unregister(RegistryAgentType type, java.lang.String name, ReasonerDimension dimension)
type
- The component type as value of RegistryAgentType
.name
- The name of the leaving component (the ID on which it reacts on control messages).dimension
- The supported context dimension (required for RegistryAgentType.SENSOR
.private java.lang.String getVersion()
ProjectInfo.REACHABILITY_AGENT_VERSION
.