ist.palcom.routing
Class AbstractRoutingManager2

java.lang.Object
  extended by ist.palcom.routing.AbstractRoutingManager2
All Implemented Interfaces:
IHgraphNode, RoutingManager
Direct Known Subclasses:
BasicRoutingManager, SimpleRoutingManager

public abstract class AbstractRoutingManager2
extends java.lang.Object
implements RoutingManager

Abstract class for a routing manager, implements RoutingManager. Handles chopped and reliable messages.


Nested Class Summary
protected  class AbstractRoutingManager2.ChoppedMessageHandler
          Handles chopping and reassembling of messages
 
Field Summary
protected  HgraphNode _node
          hgraph impl
 
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
AbstractRoutingManager2()
           
 
Method Summary
abstract  void addErrorHandler(PalcomThread handler)
           
 int addNodeChild(IHgraphNode node, Path callerPath)
          Adds a child to the node's private list of children.
protected  Message adjustMessageRawData(Message message)
          This method is required, in the current implementation, when a message header node has been removed.
 java.util.Iterator getChildIterator()
           
 AbstractRoutingManager2.ChoppedMessageHandler getChoppedMessageHandler()
           
 FuncFunc getFuncFunc()
           
abstract  java.lang.String getLocalDeviceCache()
           
 java.lang.String getNodeName()
          hgraph impl below
 IHgraphNode getNodeParent()
           
 Path getPath()
           
 SiblingFunc getSiblingFunc()
           
 ValueFunc getValueFunc()
           
 boolean hasChildNamed(java.lang.String name)
          Checks whether the node has a child with a given name
 boolean isAncestorOf(IHgraphNode node)
          Checks whether this node is an ancestor of the parameter node.
abstract  void registerAsListener(PalcomThread communicationManager)
           
abstract  void registerForHeartBeats(PalcomThread resourceManager)
           
 int removeNodeChild(java.lang.String name, Path callerPath)
          Removes a child based on its name.
abstract  boolean send(Message message, java.lang.String receiverDeviceID)
           
abstract  boolean send(Message msg, URN urn1, Selector selector1, URN urn2, Selector selector2)
           
abstract  void sendBroadcast(Message message)
           
 void sendGroupJoinMessage(java.lang.String groupID)
           
 void sendGroupLeaveMessage(java.lang.String groupID)
           
abstract  void sendHeartAttack()
           
abstract  void sendHeartBeat(boolean isHeartBeatAck)
           
abstract  void setDiscoverySelector(Selector selector)
           
abstract  void setLocalDeviceCache(java.lang.String localDeviceCache)
           
abstract  void setLocalDeviceID(java.lang.String localDeviceID)
           
abstract  void setLocalDiscoveryVersion(java.lang.String discoveryVersion)
           
abstract  void setLocalStatusFlag(byte statusFlag)
           
 int setNodeName(java.lang.String name, Path callerPath)
          Sets the name of the node.
 int setNodeParent(IHgraphNode newParent, Path callerPath)
          Sets the parent of the HgraphNode.
 void stop()
          Clears the choppedMessageHandler.
abstract  void stopReceiving(PalcomThread receiver)
           
abstract  void stopReceiving(Selector selector)
           
 java.lang.String toXML()
           
 java.lang.String toXMLFull()
           
 java.lang.String toXMLFullRecursively()
           
 java.lang.String toXMLRecursively()
           
 void unregisterDevice(java.lang.String deviceID)
          Remove the device with deviceID from the list of registered devices.
 void updatePath()
          Updates the path of the H-Graph node along with its offspring recursively.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_node

protected HgraphNode _node
hgraph impl

Constructor Detail

AbstractRoutingManager2

public AbstractRoutingManager2()
Method Detail

stopReceiving

public abstract void stopReceiving(PalcomThread receiver)
Specified by:
stopReceiving in interface RoutingManager

stopReceiving

public abstract void stopReceiving(Selector selector)
Specified by:
stopReceiving in interface RoutingManager

send

public abstract boolean send(Message msg,
                             URN urn1,
                             Selector selector1,
                             URN urn2,
                             Selector selector2)
Specified by:
send in interface RoutingManager

send

public abstract boolean send(Message message,
                             java.lang.String receiverDeviceID)
Specified by:
send in interface RoutingManager

stop

public void stop()
Clears the choppedMessageHandler. Subclasses override this method to stop the media manager(s), and call super.stop from there.

Specified by:
stop in interface RoutingManager

unregisterDevice

public void unregisterDevice(java.lang.String deviceID)
Remove the device with deviceID from the list of registered devices. Subclasses override this method and call super.unregisterDevice from there.

Specified by:
unregisterDevice in interface RoutingManager

addErrorHandler

public abstract void addErrorHandler(PalcomThread handler)
Specified by:
addErrorHandler in interface RoutingManager

setLocalDeviceCache

public abstract void setLocalDeviceCache(java.lang.String localDeviceCache)
Specified by:
setLocalDeviceCache in interface RoutingManager

getLocalDeviceCache

public abstract java.lang.String getLocalDeviceCache()
Specified by:
getLocalDeviceCache in interface RoutingManager

setLocalDeviceID

public abstract void setLocalDeviceID(java.lang.String localDeviceID)
Specified by:
setLocalDeviceID in interface RoutingManager

setLocalStatusFlag

public abstract void setLocalStatusFlag(byte statusFlag)
Specified by:
setLocalStatusFlag in interface RoutingManager

setLocalDiscoveryVersion

public abstract void setLocalDiscoveryVersion(java.lang.String discoveryVersion)
Specified by:
setLocalDiscoveryVersion in interface RoutingManager

setDiscoverySelector

public abstract void setDiscoverySelector(Selector selector)
Specified by:
setDiscoverySelector in interface RoutingManager

sendBroadcast

public abstract void sendBroadcast(Message message)
Specified by:
sendBroadcast in interface RoutingManager

sendHeartAttack

public abstract void sendHeartAttack()
Specified by:
sendHeartAttack in interface RoutingManager

registerAsListener

public abstract void registerAsListener(PalcomThread communicationManager)
Specified by:
registerAsListener in interface RoutingManager

registerForHeartBeats

public abstract void registerForHeartBeats(PalcomThread resourceManager)
Specified by:
registerForHeartBeats in interface RoutingManager

sendHeartBeat

public abstract void sendHeartBeat(boolean isHeartBeatAck)
Specified by:
sendHeartBeat in interface RoutingManager

sendGroupJoinMessage

public void sendGroupJoinMessage(java.lang.String groupID)
Specified by:
sendGroupJoinMessage in interface RoutingManager

sendGroupLeaveMessage

public void sendGroupLeaveMessage(java.lang.String groupID)
Specified by:
sendGroupLeaveMessage in interface RoutingManager

getChoppedMessageHandler

public AbstractRoutingManager2.ChoppedMessageHandler getChoppedMessageHandler()

adjustMessageRawData

protected Message adjustMessageRawData(Message message)
This method is required, in the current implementation, when a message header node has been removed. It creates a new message without the raw data array.

Parameters:
message -
Returns:
New message

getNodeName

public java.lang.String getNodeName()
hgraph impl below

Specified by:
getNodeName in interface IHgraphNode
Returns:
The name of the node.

setNodeName

public int setNodeName(java.lang.String name,
                       Path callerPath)
Description copied from interface: IHgraphNode
Sets the name of the node. If a sibling already has the name, an error control message is returned

Specified by:
setNodeName in interface IHgraphNode
Parameters:
name - The new name
Returns:
IHgraphNode.STATUS_OK if the change succeeded. IHgraphNode.CHILD_NAME_CLASH if a sibling with the given name already exists.

getPath

public Path getPath()
Specified by:
getPath in interface IHgraphNode
Returns:
the Path object pertaining to the path of the node

updatePath

public void updatePath()
Description copied from interface: IHgraphNode
Updates the path of the H-Graph node along with its offspring recursively. The path is updated when the node name and the node parent is sat.

Specified by:
updatePath in interface IHgraphNode

hasChildNamed

public boolean hasChildNamed(java.lang.String name)
Description copied from interface: IHgraphNode
Checks whether the node has a child with a given name

Specified by:
hasChildNamed in interface IHgraphNode
Parameters:
name - The name to check
Returns:
True iff the node has an actual child with the given name. False if not.

isAncestorOf

public boolean isAncestorOf(IHgraphNode node)
Description copied from interface: IHgraphNode
Checks whether this node is an ancestor of the parameter node. It does so with a depth-first sharch of its offspring (children etc.)

Specified by:
isAncestorOf in interface IHgraphNode
Returns:
true if this node is an ancestor of the parameter node. false if not.

removeNodeChild

public int removeNodeChild(java.lang.String name,
                           Path callerPath)
Description copied from interface: IHgraphNode
Removes a child based on its name.

Specified by:
removeNodeChild in interface IHgraphNode
Parameters:
name - The name of the child to be removed
Returns:
IHgraphNode.STATUS_OK if the operation succeeds

toXML

public java.lang.String toXML()
Specified by:
toXML in interface IHgraphNode
Returns:
A simple xml'ified String of the node (type, name, path, children)

toXMLFull

public java.lang.String toXMLFull()
Specified by:
toXMLFull in interface IHgraphNode
Returns:
A complete xml'ified String of the node (same as simple + handlers, invokators, listeners, values)

toXMLRecursively

public java.lang.String toXMLRecursively()
Specified by:
toXMLRecursively in interface IHgraphNode
Returns:
A simple recursive xml'ified String of the node (type, name, path, children)

toXMLFullRecursively

public java.lang.String toXMLFullRecursively()
Specified by:
toXMLFullRecursively in interface IHgraphNode
Returns:
A complete recursive xml'ified String of the node (same as simple + handlers, invokators, listeners, values) HEAVY!!!

setNodeParent

public int setNodeParent(IHgraphNode newParent,
                         Path callerPath)
Description copied from interface: IHgraphNode
Sets the parent of the HgraphNode. This triggers a recalculation of the path of the node and its offspring

Specified by:
setNodeParent in interface IHgraphNode
Parameters:
newParent - the new parent
Returns:
IHgraphNode.STATUS_OK if the operation succeeds. IHgraphNode.CIRCULARITY_CLASH if the operation causes a circularity.

addNodeChild

public int addNodeChild(IHgraphNode node,
                        Path callerPath)
Description copied from interface: IHgraphNode
Adds a child to the node's private list of children. Ensures that names amongst children are unique

Specified by:
addNodeChild in interface IHgraphNode
Parameters:
node - The new child to be added
Returns:
IHgraphNode.STATUS_OK if the change succeeded. IHgraphNode.CHILD_NAME_CLASH if a sibling with the given name already exists.

getSiblingFunc

public SiblingFunc getSiblingFunc()
Specified by:
getSiblingFunc in interface IHgraphNode
Returns:
The SiblingFunc Sibling functionality object for the given node.

getValueFunc

public ValueFunc getValueFunc()
Specified by:
getValueFunc in interface IHgraphNode
Returns:
The ValueFunc Value functionality object for the given node.

getFuncFunc

public FuncFunc getFuncFunc()
Specified by:
getFuncFunc in interface IHgraphNode
Returns:
The FuncFunc functional functionality (ie. handlers, invokators and listeners) object for the given node.

getNodeParent

public IHgraphNode getNodeParent()
Specified by:
getNodeParent in interface IHgraphNode
Returns:
The parent of the node. null if the parent is root

getChildIterator

public java.util.Iterator getChildIterator()
Specified by:
getChildIterator in interface IHgraphNode
Returns:
An Iterator over the children of the node