ist.palcom.contingency.manager
Class ContingencyMonitor

java.lang.Object
  extended by ist.palcom.services.AbstractService
      extended by ist.palcom.contingency.manager.ContingencyMonitor
All Implemented Interfaces:
IContingencyMonitor, Service, IHgraphNode

public class ContingencyMonitor
extends AbstractService
implements IContingencyMonitor

Contingency monitor receives requests from the contingency manager to monitor the occurence of a particular contingency event. Upon receiving of the request, the contingency monitor interprets the contingency event and checks whether it did not occur already (e.g. device is missing). In case the event occurred, the contingency manager is informed, otherwise the contingency monitor further monitors its occurrence accordingly.


Field Summary
 
Fields inherited from class ist.palcom.services.AbstractService
_node, connectionsMonitor, context, info, siid
 
Fields inherited from interface ist.palcom.contingency.manager.IContingencyMonitor
SERVICE_NAME, URN_SUFFIX
 
Fields inherited from interface ist.palcom.hgraph.IHgraphNode
CHILD_NAME_CLASH, CIRCULARITY_CLASH, COMMAND_OR_NODE_MISSING, ERROR, HANDLER_MISSING, INVOKATOR_MISSING, LISTENER_MISSING, NODE_NOT_CHILD, PATH_MISSING, SIBLING_ALREADY_EXISTS, SIBLING_NONEXISTENT, SIBLING_REFERENCE_ALREADY_EXISTS, SIBLING_REFERENCE_NONEXISTENT, STATUS_OK, VALUE_ALREADY_EXISTS, VALUE_NOT_PRESENT
 
Constructor Summary
ContingencyMonitor(DeviceContext context, java.lang.String serviceName)
           
 
Method Summary
 PalcomThread getContingencyMonitorThread()
          Return a thread responsible for dealing requests to monitor contingencies.
 ServiceID getServiceID()
           
 void handleResourceQuery(ResourceQuery query)
          Handles ResourceDirectory's answer to the resource query.
 void queryResource(ResourceQuery query)
          Query for an available resource.
 void registerResourceDirectoryThread(PalcomThread t)
          Registers the resource directory's thread to query for resources.
 void start()
          Start the service.
 void stop()
           
 void unregisterResourceDirectoryThread()
          Unregisters the resource directory's thread to query for resources.
 
Methods inherited from class ist.palcom.services.AbstractService
addNodeChild, addServiceProxyListener, connectionClosed, connectionCreated, connectTo, disconnectFrom, getChildIterator, getConnections, getFuncFunc, getNodeName, getNodeParent, getPath, getRemoteServiceProxy, getSelector, getServiceInfo, getServiceInstanceID, getServiceProxy, getSiblingFunc, getValueFunc, hasChildNamed, isAncestorOf, remoteServiceProxyIterator, removeNodeChild, removeServiceProxyListener, sendToAll, setGroupID, setLocalSID, setName, setNodeName, setNodeParent, setServiceInstanceID, setServiceProxy, setStatus, setTopic, toXML, toXMLFull, toXMLFullRecursively, toXMLRecursively, updatePath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContingencyMonitor

public ContingencyMonitor(DeviceContext context,
                          java.lang.String serviceName)
                   throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getServiceID

public ServiceID getServiceID()
Specified by:
getServiceID in class AbstractService
Returns:
the ServiceID of the service.

registerResourceDirectoryThread

public void registerResourceDirectoryThread(PalcomThread t)
Description copied from interface: IContingencyMonitor
Registers the resource directory's thread to query for resources.

Specified by:
registerResourceDirectoryThread in interface IContingencyMonitor

unregisterResourceDirectoryThread

public void unregisterResourceDirectoryThread()
Description copied from interface: IContingencyMonitor
Unregisters the resource directory's thread to query for resources.

Specified by:
unregisterResourceDirectoryThread in interface IContingencyMonitor

getContingencyMonitorThread

public PalcomThread getContingencyMonitorThread()
Description copied from interface: IContingencyMonitor
Return a thread responsible for dealing requests to monitor contingencies.

Specified by:
getContingencyMonitorThread in interface IContingencyMonitor
Returns:
The contingency monitor thread.

start

public void start()
           throws java.io.IOException
Description copied from class: AbstractService
Start the service. The LocalSID must be set before calling this method (through a constructor, or through a call to the setLocalSID method). If the service is started already, nothing happens. The DiscoveryManager will be updated with info about the service.

Specified by:
start in interface IContingencyMonitor
Overrides:
start in class AbstractService
Throws:
java.io.IOException

stop

public void stop()
          throws java.io.IOException
Specified by:
stop in interface IContingencyMonitor
Overrides:
stop in class AbstractService
Throws:
java.io.IOException

handleResourceQuery

public void handleResourceQuery(ResourceQuery query)
Description copied from interface: IContingencyMonitor
Handles ResourceDirectory's answer to the resource query. In case the resource is not available, the corresponding contingency event will be fired to ContingencyManager, otherwise it is informed that the contingency is ok and the contingency monitor further registers listeners in order to monitor the event's occurence in the future.

Specified by:
handleResourceQuery in interface IContingencyMonitor

queryResource

public void queryResource(ResourceQuery query)
Description copied from interface: IContingencyMonitor
Query for an available resource.

Specified by:
queryResource in interface IContingencyMonitor