eu.xtreemos.xosd.daemon
Class Daemon

java.lang.Object
  extended by eu.xtreemos.system.eventmachine.stage.AbstractStage
      extended by eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
          extended by eu.xtreemos.system.eventmachine.stage.Abstract2wayStage
              extended by eu.xtreemos.xosd.daemon.Daemon
All Implemented Interfaces:
eu.xtreemos.system.eventmachine.queue.IEventHandler, eu.xtreemos.system.eventmachine.stage.IStage
Direct Known Subclasses:
eu.xtreemos.xosd.daemon.service.DaemonHandler

public class Daemon
extends eu.xtreemos.system.eventmachine.stage.Abstract2wayStage

Author:
gregor.pipan@xlab.si

Field Summary
private  java.util.ArrayList<CommunicationAddress> list
           
private static org.apache.log4j.Logger logger
           
protected  java.util.ArrayList<eu.xtreemos.system.eventmachine.stage.AbstractStage> runningStages
          The list of stages currently running.
protected  java.util.Hashtable<java.lang.String,java.util.ArrayList<CommunicationAddress>> serviceDir
          Stage directory containing the list of addresses for each service known to be running at those addresses.
 
Fields inherited from class eu.xtreemos.system.eventmachine.stage.Abstract2wayStage
context, counter, curContext, sink
 
Fields inherited from class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
queue
 
Fields inherited from class eu.xtreemos.system.eventmachine.stage.AbstractStage
handlerChain, handlerGroup, handlerThreads, name, running, serviceListeners
 
Constructor Summary
Daemon()
           
 
Method Summary
 java.lang.Integer finishKill(java.lang.Object param)
           
 java.util.ArrayList<CommunicationAddress> getDaemons()
          "global" method (i.e. gets invoked on the root address xosd)
 java.lang.String getHandledEventType()
           
 java.util.ArrayList<CommunicationAddress> getNodesRunningService(java.lang.String serviceName)
          "global" method (i.e. gets invoked on the root address xosd) Retrieve a list of nodes that run a particular service.
 java.util.ArrayList<java.lang.String> getServiceList()
          Retrieve the list of names of the services currently running on this daemon.
 void handleEvent(java.lang.Object event)
           
 void init()
           
 java.lang.Integer kill()
           
 void registerDaemon(CommunicationAddress address)
          "global" method (i.e. gets invoked on the root address xosd)
 java.lang.Object registerDaemonCallback(java.lang.Object arg)
           
 java.lang.Integer registerMyServices()
          Send to the root the list of services running on this node.
 java.lang.Integer registerServices(CommunicationAddress address, java.util.ArrayList<java.lang.String> activeServices)
          Register the list of services running within an xosd.
protected  void removeRegisteredServices(CommunicationAddress address)
          Purge all entries of serviceDir of the given XOSD's address.
 void unregisterDaemon(CommunicationAddress address)
          "global" method (i.e. gets invoked on the root address xosd) Unregisters the xosd from the list of running daemons.
 
Methods inherited from class eu.xtreemos.system.eventmachine.stage.Abstract2wayStage
getContext, removeContext, SendException, SendException, SendException, SendReply, SendReply, SendReply, setSink
 
Methods inherited from class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
dequeue, getSource
 
Methods inherited from class eu.xtreemos.system.eventmachine.stage.AbstractStage
addHandler, addHandler, addServiceListener, getName, getShortName, getThreadCount, notifyServiceInitialised, notifyServiceStarted, notifyServiceStopped, processEvent, removeHandler, removeServiceListener, setThreadCount, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

list

private java.util.ArrayList<CommunicationAddress> list

logger

private static final org.apache.log4j.Logger logger

runningStages

protected java.util.ArrayList<eu.xtreemos.system.eventmachine.stage.AbstractStage> runningStages
The list of stages currently running.


serviceDir

protected java.util.Hashtable<java.lang.String,java.util.ArrayList<CommunicationAddress>> serviceDir
Stage directory containing the list of addresses for each service known to be running at those addresses.

Constructor Detail

Daemon

public Daemon()
Method Detail

unregisterDaemon

public void unregisterDaemon(CommunicationAddress address)
"global" method (i.e. gets invoked on the root address xosd) Unregisters the xosd from the list of running daemons. Also removes all references to the services running at the daemon.

Parameters:
address - The address of the daemon to be unregistered.

registerDaemon

public void registerDaemon(CommunicationAddress address)
"global" method (i.e. gets invoked on the root address xosd)

Parameters:
address -

init

public void init()
Specified by:
init in interface eu.xtreemos.system.eventmachine.stage.IStage
Overrides:
init in class eu.xtreemos.system.eventmachine.stage.AbstractStage

registerDaemonCallback

public java.lang.Object registerDaemonCallback(java.lang.Object arg)

getDaemons

public java.util.ArrayList<CommunicationAddress> getDaemons()
"global" method (i.e. gets invoked on the root address xosd)


getServiceList

public java.util.ArrayList<java.lang.String> getServiceList()
Retrieve the list of names of the services currently running on this daemon.

Returns:
The list of names of the currently running services.

registerMyServices

public java.lang.Integer registerMyServices()
                                     throws java.lang.Exception
Send to the root the list of services running on this node.

Returns:
0 if call was successful.
Throws:
java.lang.Exception

removeRegisteredServices

protected void removeRegisteredServices(CommunicationAddress address)
Purge all entries of serviceDir of the given XOSD's address.

Parameters:
address - The address of an XOSD to remove from service directory.

registerServices

public java.lang.Integer registerServices(CommunicationAddress address,
                                          java.util.ArrayList<java.lang.String> activeServices)
                                   throws java.lang.Exception
Register the list of services running within an xosd. The method removes all current information on the given node's services, and then adds the ones listed in the parameter.

Parameters:
address - The address of the xosd registering the services.
activeServices - The list of strings identifying the running services.
Returns:
0 if call was successful.
Throws:
java.lang.Exception

getNodesRunningService

public java.util.ArrayList<CommunicationAddress> getNodesRunningService(java.lang.String serviceName)
                                                                 throws java.lang.Exception
"global" method (i.e. gets invoked on the root address xosd) Retrieve a list of nodes that run a particular service.

Parameters:
serviceName - The name of the service being queried of.
Returns:
A list of addresses of the nodes that have registered the service.
Throws:
java.lang.Exception

kill

public java.lang.Integer kill()

finishKill

public java.lang.Integer finishKill(java.lang.Object param)

handleEvent

public void handleEvent(java.lang.Object event)
                 throws java.lang.Exception
Specified by:
handleEvent in interface eu.xtreemos.system.eventmachine.queue.IEventHandler
Specified by:
handleEvent in class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
Throws:
java.lang.Exception

getHandledEventType

public java.lang.String getHandledEventType()
Specified by:
getHandledEventType in class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage