|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
V
- the type of the nodes in the topology to be used with
this routing algorithm.E
- the type of the links.public interface RoutingAlg<V,E>
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).
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 |
---|
void setup(TED<V,E> ted, Environ env)
WithEnvParams.getEnvParams()
for details about the
expected format of the names in env
.
Path<V,E> run(V src, V dest, int rq_cap)
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.
double getCost(E e)
Path<V,E> getWorkingPath()
run()
.
Path<V,E> getBackupPath()
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
.
java.lang.UnsupportedOperationException
- if protection is not supported.java.lang.String getName()
getName
in interface WithEnvParams
void commitWorkingPath(ConnectionInfo<V,E> cnx)
run()
finds path(s) but does not perform
any allocation.
void commitBackupPath(ConnectionInfo<V,E> cnx)
commitWorkingPath(ConnectionInfo)
.
void uncommitWorkingPath(ConnectionInfo<V,E> cnx)
commitWorkingPath()
is called upon
accepting a connection, this method should be called
as part of the connection release process.
void uncommitBackupPath(ConnectionInfo<V,E> cnx)
uncommitWorkingPath(ConnectionInfo)
.
boolean offersProtection()
void topologyHasChanged()
void dumpState()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |