cgl.narada.protocol
Class RoutingCache

java.lang.Object
  extended by cgl.narada.protocol.RoutingCache
All Implemented Interfaces:
ProtocolDebugFlags

public class RoutingCache
extends Object
implements ProtocolDebugFlags

For a given node, this class maintains a cache of the links (from this node) that are the best links to send an event over to reach its destinations as computed by the profile info, and contained within the routing information that the event contains. The cache needs to be updated during link/node failures, since some if not all the entries could be invalidated by such an event. The cache would once again be updated during the node organization protocol. This class is implemented as a thread which waits on any updates on the gatewayInfo class, and upon receiving a notification recomputes the routing cache.


Field Summary
 
Fields inherited from interface cgl.narada.protocol.ProtocolDebugFlags
BrokerLocatorCommunicator_Debug, ClientConnectionHandler_Debug, Connection_Debug, ConnectionPropagation_Debug, Destinations_Debug, DuplicateDetection_Debug, EventBuffer_Debug, EventRoutingProtocol_Debug, Gateway_Debug, GatewayInfo_Debug, GatewayPropagation_Debug, JmsProfilePropagation_Debug, LinkCostMatrix_Debug, NodeAdditionProtocol_Debug, NodeAddress_Debug, Path_Debug, PersistentEventRouting_Debug, ProfilePropagationProtocol_Debug, ProtocolException_Debug, ProtocolHandler_Debug, ProtocolID_Debug, ProtocolIDFactory_Debug, RoutingCache_Debug, RtpEventRoutingProtocol_Debug, RtpProfilePropagation_Debug, SecureMessageRouting_Debug, TagValueEventRoutingProtocol_Debug, TagValueProfilePropagation_Debug, XmlEventRoutingProtocol_Debug, XPathProfilePropagation_Debug
 
Constructor Summary
RoutingCache(GatewayInfo gateway, int systemLevel)
          The routing cache constructor.
 
Method Summary
 void addHop(Gateway hop)
          This method adds a hop to the destination directory
 Gateway[] computeHopsToReachDestination(Destinations destinationToReach, Destinations traversedSoFar)
           
 Destinations destinationsReachedFromHop(Gateway gateway)
          Provides the destinations that can be reached from a hop.
 Gateway getBestHopToReachNode(Gateway nodeToReach)
          This method returns the best hop that needs to be taken to reach a given node
 Destinations getFastestDestinationsFromHop(Gateway hop)
          Returns the destinations that can be reached fastest from the specified hop.
 Gateway[] hopsToReachDestination(Destinations destinationToReach, Destinations traversedSoFar)
          This method returns a list of hops that can be employed to reach our destinations.
 void invalidateDestinationDirectoryListings(int gatewayLevel)
          If a new connection at level gatewayLevel is added, destination listings need to be computed for nodes at level  >=   gatewayLevel in the connectivity graph.
static void main(String[] args)
           
 void performDestinationDirectoryListing()
          A utility method which traverses the destinationDirectory and provides a listing of the destinations at each level (within the connectivity graph) that can be reached by evry hop that originates from the vertex node
 void removeHop(Gateway hop)
          This method removes a hop from the destination directory
 void updateRoutingInformation(Gateway nodeToReach, Gateway bestHop)
          This updates the routing cache with the best hop that needs to be taken to reach the node in question.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoutingCache

public RoutingCache(GatewayInfo gateway,
                    int systemLevel)
The routing cache constructor. The system level is needed for the creation of destinations associated with a hop, besides other reasons.

Parameters:
gateway - - The gatewayInfo for the server node.
systemLevel - - The system level
Method Detail

updateRoutingInformation

public void updateRoutingInformation(Gateway nodeToReach,
                                     Gateway bestHop)
This updates the routing cache with the best hop that needs to be taken to reach the node in question. These nodes which we refer to, are the nodes in the connectivity graph

Parameters:
nodeToReach - - The node that needs to be reached
bestHop - - The best hop that can be taken from the server node in question to reach nodeToReach

getBestHopToReachNode

public Gateway getBestHopToReachNode(Gateway nodeToReach)
This method returns the best hop that needs to be taken to reach a given node

Parameters:
nodeToReach - - Is the (node+level) gateway node that needs to be reached in the connectivity graph.

getFastestDestinationsFromHop

public Destinations getFastestDestinationsFromHop(Gateway hop)
Returns the destinations that can be reached fastest from the specified hop.

Parameters:
hop -
Returns:

computeHopsToReachDestination

public Gateway[] computeHopsToReachDestination(Destinations destinationToReach,
                                               Destinations traversedSoFar)

hopsToReachDestination

public Gateway[] hopsToReachDestination(Destinations destinationToReach,
                                        Destinations traversedSoFar)
This method returns a list of hops that can be employed to reach our destinations. This method performs several checks. The hops that are considered in the preliminary list of hops that can used for reaching destinations are the list of hops that have not already been traversed.

Parameters:
destinationToReach - The destinations that need to be reached.
traversedSoFar - The destinations that have been reached so far.
Returns:
The hops that can be taken to reach the destinations. This return value could be null if there are no hops that can be employed to reach any of the destinations that are contained in destinationToReach

destinationsReachedFromHop

public Destinations destinationsReachedFromHop(Gateway gateway)
Provides the destinations that can be reached from a hop. The destinations are returned as a node address.

Parameters:
gateway - - The hop from the server node hosting the connectivity graph.
Returns:
The destinations that can be reached from this hop, if it is a valid hop. Otherwise return null.

addHop

public void addHop(Gateway hop)
This method adds a hop to the destination directory


removeHop

public void removeHop(Gateway hop)
This method removes a hop from the destination directory


invalidateDestinationDirectoryListings

public void invalidateDestinationDirectoryListings(int gatewayLevel)
If a new connection at level gatewayLevel is added, destination listings need to be computed for nodes at level  >=   gatewayLevel in the connectivity graph. Thus for each hop we need to invalidate the destinations that could be reached from a given hop. This invalidation affects destinations  >=   gatewayLevel for every hops destination list.

Parameters:
gatewayLevel - - The destination level which needs to be invalidated.

performDestinationDirectoryListing

public void performDestinationDirectoryListing()
A utility method which traverses the destinationDirectory and provides a listing of the destinations at each level (within the connectivity graph) that can be reached by evry hop that originates from the vertex node


main

public static void main(String[] args)


For comments and suggestions please send e-mail to The NaradaBrokering Project