public abstract class Reasoner extends java.lang.Thread implements StopableObject, ReasoningEngine, PropertyServiceNotifiable
Modifier and Type | Field and Description |
---|---|
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber |
feedbackTopic
The
LPSubscriber , which will get user feedback from user interfaces. |
private java.lang.String |
feedbackTopicName
The name of the ActiveMQ topic on which user feedback will be propagated.
|
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber |
internalSensorDataTopic
The
LPPublisher , which will get the generalized result set from internalSensorDataTopicName . |
private java.lang.String |
internalSensorDataTopicName
The name of the ActiveMQ topic on which the sensor publishes its generalized data set.
|
private PropertyService |
propertyService
The
PropertyService of this Reasoner , which manages property requests and changes from user
interfaces. |
private java.util.Random |
rand
Local random number generator.
|
private java.lang.String |
registryRequestTopicName
The name of the ActiveMQ topic on which the systems registry service invites other components to join him.
|
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPPublisher |
registryTopic
The
LPPublisher , which sends register messages to the systems registry service via the ActiveMQ. |
private java.lang.String |
registryTopicName
The name of the ActiveMQ topic on which this
Reasoner sends its register messages to the systems registry
service. |
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber |
requestRegistryTopic
The
LPSubscriber , which listens for register requests from the systems registry service via the ActiveMQ. |
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPPublisher |
resultTopic
The
LPPublisher , which will write the results to the agents result. |
private java.lang.String |
resultTopicName
The name of the ActiveMQ topic on which the sensor delivers its measuring results.
|
private boolean |
shutDown
Determines if the method
shutDown() has been called. |
private boolean |
silent
Holds the activity state of this object.
|
private boolean |
stopped
Determines if the
Reasoner has stopped. |
PROPERTY_FILE_SOURCE_KEY
Modifier | Constructor and Description |
---|---|
protected |
Reasoner()
Protected constructor ensures, that there will be no direct instance of this class.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
cleanUp()
Cleans up by freeing all resources.
|
private void |
end()
Unregisters from systems registry service, disconnects all ActiveMQ topic connections and sets
stopped
to true . |
protected java.lang.String |
getID()
Returns the ID of this
Reasoner . |
private JsonReachabilityInformation |
getJsonReachabilityInformation()
Returns a single
JsonReachabilityInformation object which contains the
ReachabilityStatus to all
ReachabilityGroup s and different identification informations. |
protected java.lang.String |
getVersion()
Returns the version of this
Reasoner . |
private void |
handleActiveUserFeedback()
Handles active user feedback, if some new arises via the ActiveMQ.
|
private void |
handleInternalSensorData()
Forward internal sensor data to the reasoning engine, if some new arises via the ActiveMQ.
|
private void |
handleRegisterRequestMessage()
Checks for new registry invitations from the systems registry service and sends register message if there's
some by using
sendRegistryMessage(RegistryMessageType) with RegistryMessageType.REGISTER . |
private void |
init()
Initialize all required ActiveMQ connections and starts the property service of this
Reasoner . |
boolean |
isActive()
Determines whether the method
StopableObject.shutDown() has been called on this object or not. |
boolean |
isSilent()
Checks if the current workers running mode is silent or not.
|
private void |
publishReachabilityStatus()
The method will publish the current reachability status using the publisher
resultTopic and
getJsonReachabilityInformation() . |
protected void |
pushProperties()
Push current properties to other components via the ActiveMQ.
|
void |
run()
Frequently check for sensor data updates.
|
private void |
sendInitialRegisterMessage()
Sends an initial register message by using
sendRegistryMessage(RegistryMessageType) with
RegistryMessageType.REGISTER . |
private void |
sendRegistryMessage(RegistryMessageType type)
Creates and sends a new
JsonRARegistryMessage onto the registryTopic . |
protected abstract void |
setSensorData(JsonReachabilitySensorData data)
Extracts dimension and sensor data from a received
JsonReachabilitySensorData and adds them to the
working memory. |
void |
setSilent(boolean state)
Set the silent state.
|
void |
shutDown()
Shuts the object down.
|
boolean |
stopped()
Determines if the
Reasoner has stopped. |
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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dump, getEstimatedReachability, getEstimatedReachability, handleFeedback, start
getValuesForProperty, loadCurrentProperties, updateProperties
private boolean silent
true
, the worker won't publish its results on
the result topic.private java.lang.String feedbackTopicName
private java.lang.String resultTopicName
private java.lang.String internalSensorDataTopicName
private java.lang.String registryRequestTopicName
private java.lang.String registryTopicName
Reasoner
sends its register messages to the systems registry
service.private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber feedbackTopic
LPSubscriber
, which will get user feedback from user interfaces.private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPPublisher resultTopic
LPPublisher
, which will write the results to the agents result.private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber internalSensorDataTopic
LPPublisher
, which will get the generalized result set from internalSensorDataTopicName
.private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber requestRegistryTopic
LPSubscriber
, which listens for register requests from the systems registry service via the ActiveMQ.private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPPublisher registryTopic
LPPublisher
, which sends register messages to the systems registry service via the ActiveMQ.private boolean shutDown
shutDown()
has been called.private boolean stopped
Reasoner
has stopped.private java.util.Random rand
private PropertyService propertyService
PropertyService
of this Reasoner
, which manages property requests and changes from user
interfaces.protected Reasoner()
public final void setSilent(boolean state)
true
, the worker won't publish his informations on the
general result topic.state
- The current state of silence as Boolean
.public final boolean isSilent()
isSilent
in interface PropertyServiceNotifiable
Boolean
.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 stopped()
Reasoner
has stopped.true
if Reasoner
has stopped, otherwise false
.public final void shutDown()
StopableObject
shutDown
in interface StopableObject
StopableObject.shutDown()
public final void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
private void init()
Reasoner
.private void sendInitialRegisterMessage()
sendRegistryMessage(RegistryMessageType)
with
RegistryMessageType.REGISTER
.private void handleRegisterRequestMessage()
sendRegistryMessage(RegistryMessageType)
with RegistryMessageType.REGISTER
.private void handleActiveUserFeedback()
private void handleInternalSensorData()
protected abstract void setSensorData(JsonReachabilitySensorData data)
JsonReachabilitySensorData
and adds them to the
working memory.data
- The JsonReachabilitySensorData
which has been measured.private void publishReachabilityStatus()
resultTopic
and
getJsonReachabilityInformation()
.private JsonReachabilityInformation getJsonReachabilityInformation()
JsonReachabilityInformation
object which contains the
ReachabilityStatus
to all
ReachabilityGroup
s and different identification informations.
(For further informations see JsonReachabilityInformation
).JsonReachabilityInformation
.private void end()
stopped
to true
.protected abstract void cleanUp()
private void sendRegistryMessage(RegistryMessageType type)
JsonRARegistryMessage
onto the registryTopic
. This may register or
unregister this Reasoner
due to the supplied RegistryMessageType
.type
- The RegistryMessageType
which indicates if the Reasoner
shall be registered or
unregistered from the systems registry service.protected final void pushProperties()
protected final java.lang.String getID()
Reasoner
.Reasoner
as String
.