bcds.phison.ra
Interface RoutingAlg<V,E>

Type Parameters:
V - the type of the nodes in the topology to be used with this routing algorithm.
E - the type of the links.
All Superinterfaces:
WithEnvParams
All Known Implementing Classes:
DijkstraAll, DijkstraMaxWidth, LIOA, LMIR, MinHop, Null, ProtDPP_MinCost, SWP, WSP

public interface RoutingAlg<V,E>
extends WithEnvParams

Defines the methods that all routing algorithms must implement. Routing algorithms are required to support finding one working path and, optionally, one backup path. Whether backup paths are shareable, end-to-end backups (or just a segment), etc. is not mandated here. Nonetheless, both paths must be computed in the same step, that is, with a single invocation of run().

The initialization of a RoutingAlg must be performed in the method setup(TED, Environ), and a default (nullary) constructor should be explicitly provided. This is to facilitate dynamic instantiation, via DynLoader for example. Additionally it is advisable to provide the convenience constructor T(TED<V, E>ted, Environ env). However, care must be taken to make sure that such a constructor is equivalent to new T().setup(ted, env). Thus, the typical body of that constructor is:

    public class T<V, E>
      implements RoutingAlg<V, E>
      extends SomeOtherRA<V, E> // for example, RoutingAlgBase
    {
       ...
       public T(TED<V, E> ted, Environ env)
       {
          setup(ted, env)
       }

       @Override
       public void setup(TED<V, E> ted, Environ env)
       {
          super.setup(ted, env);
          ...
       }
       ...
 
Note that the two-parameter constructor must not call the corresponding parent constructor, but the default constructor (in the example above, the call is implicit). The reason is that the parent constructor presumably invokes setup, which might be overriden (or call overriden methods), thus creating an erroneous initialization condition in Java (data members might not be fully initialized yet in the derived class).

Author:
Juan Segovia S.

Method Summary
 void commitBackupPath(ConnectionInfo<V,E> cnx)
          See commitWorkingPath(ConnectionInfo).
 void commitWorkingPath(ConnectionInfo<V,E> cnx)
          Performs resource allocation for a given connection.
 void dumpState()
          Shows a detailed information about the internal state of the routing algorithm (intended for debugging).
 Path<V,E> getBackupPath()
          Returns the back up computed during the latest invocation of run(), and null to indicate that no backup path could be found.
 double getCost(E e)
          Returns the cost of link e.
 java.lang.String getName()
          Returns the "short" name of the routing algorithm, typically the unqualified class name.
 Path<V,E> getWorkingPath()
          Returns the path produced by the latest invocation of run().
 boolean offersProtection()
          Returns true/false to indicate whether it supports protection.
 Path<V,E> run(V src, V dest, int rq_cap)
          Returns a path between src and dest, or null if such path cannot be found.
 void setup(TED<V,E> ted, Environ env)
          Performs initialization of a new instance.
 void topologyHasChanged()
          Informs the routing algorithm that the topology it refers to has changed (for example, due to link failure).
 void uncommitBackupPath(ConnectionInfo<V,E> cnx)
          See uncommitWorkingPath(ConnectionInfo).
 void uncommitWorkingPath(ConnectionInfo<V,E> cnx)
          Reverts the allocation of resources.
 
Methods inherited from interface bcds.phison.WithEnvParams
getEnviron, getEnvParams
 

Method Detail

setup

void setup(TED<V,E> ted,
           Environ env)
Performs initialization of a new instance. See WithEnvParams.getEnvParams() for details about the expected format of the names in env.


run

Path<V,E> run(V src,
              V dest,
              int rq_cap)
Returns a path between src and dest, or null if such path cannot be found. Null can be returned because there is not enough capacity or for any other reason or constraint, including topology disconnection.

The path retuned by this method is automatically the working path, that is, run() followed by getWorkingPath() must return the same path.


getCost

double getCost(E e)
Returns the cost of link e.


getWorkingPath

Path<V,E> getWorkingPath()
Returns the path produced by the latest invocation of run().


getBackupPath

Path<V,E> getBackupPath()
Returns the back up computed during the latest invocation of run(), and null to indicate that no backup path could be found.

Note: As future enhancement, a specific exception should be used to indicate that protection is not supported, instead of the very general UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException - if protection is not supported.

getName

java.lang.String getName()
Returns the "short" name of the routing algorithm, typically the unqualified class name.

Specified by:
getName in interface WithEnvParams

commitWorkingPath

void commitWorkingPath(ConnectionInfo<V,E> cnx)
Performs resource allocation for a given connection. Note that run() finds path(s) but does not perform any allocation.


commitBackupPath

void commitBackupPath(ConnectionInfo<V,E> cnx)
See commitWorkingPath(ConnectionInfo).


uncommitWorkingPath

void uncommitWorkingPath(ConnectionInfo<V,E> cnx)
Reverts the allocation of resources. Whereas commitWorkingPath() is called upon accepting a connection, this method should be called as part of the connection release process.


uncommitBackupPath

void uncommitBackupPath(ConnectionInfo<V,E> cnx)
See uncommitWorkingPath(ConnectionInfo).


offersProtection

boolean offersProtection()
Returns true/false to indicate whether it supports protection.


topologyHasChanged

void topologyHasChanged()
Informs the routing algorithm that the topology it refers to has changed (for example, due to link failure).


dumpState

void dumpState()
Shows a detailed information about the internal state of the routing algorithm (intended for debugging). Each implementation decides where (and how) to display the information, although a text based output to System.out or System.err can be practical for developers.