public class Registry extends java.lang.Thread implements StopableObject
Modifier and Type | Field and Description |
---|---|
private java.util.Random |
rand
A central random object.
|
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber |
registryTopic
Listener for register messages.
|
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPPublisher |
requestRegistryTopic
Publisher for register requests.
|
private boolean |
shutDown
Determines whether the method
shutDown() has been called or not. |
private ReachabilityWorker |
systemAgent
The worker which called this property service.
|
Constructor and Description |
---|
Registry()
Initializes a new
Registry object. |
Registry(ReachabilityWorker worker)
Initializes a new
Registry object with an ReachabilityWorker . |
Modifier and Type | Method and Description |
---|---|
private void |
end()
Gracefully ends the system by disconnecting all open ActiveMQ connections.
|
private java.lang.String |
getID()
Returns an service ID.
|
private java.lang.String |
getVersion()
Returns the agents version.
|
private void |
handleRegistryMessage()
Handle incoming
JsonRARegistryMessage messages which indicates that an agent would like to register or
unregister itself to/from the system. |
private void |
init()
Open all required ActiveMQ connections.
|
boolean |
isActive()
Determines whether the method
StopableObject.shutDown() has been called on this object or not. |
void |
run()
Starts the
Registry service. |
private void |
sendInitialRegistryRequest()
Sends an initial
JsonRARegistryRequest message to invite all active agents. |
void |
shutDown()
Shuts the object down.
|
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 shutDown
shutDown()
has been called or not.private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPPublisher requestRegistryTopic
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber registryTopic
private java.util.Random rand
private ReachabilityWorker systemAgent
public Registry()
Registry
object.public Registry(ReachabilityWorker worker)
Registry
object with an ReachabilityWorker
.worker
- The ReachabilityWorker
which started this registry service.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 true
.StopableObject.isActive()
public final void shutDown()
StopableObject
shutDown
in interface StopableObject
StopableObject.isActive()
public final void run()
Registry
service. Initially it sends a registry request and handles registry messages
afterwards, until the shutDown()
method has been called.run
in interface java.lang.Runnable
run
in class java.lang.Thread
private void init()
private void sendInitialRegistryRequest()
JsonRARegistryRequest
message to invite all active agents.private void handleRegistryMessage()
JsonRARegistryMessage
messages which indicates that an agent would like to register or
unregister itself to/from the system.private void end()
private java.lang.String getID()
ProjectInfo.REACHABILITY_AGENT_WORKER_NAME
, the
services name and a pseudo random number.private java.lang.String getVersion()
ProjectInfo.REACHABILITY_AGENT_VERSION
.