|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbcds.phison.ra.TED<V,E>
public class TED<V,E>
Implements a minimal "traffic engineering database" for path-oriented networks/routing.
Essentially, a TED instance puts together in a single object a topology (a SimGraph), a map of link costs and a map of link capacities. Besides, it registers the acceptance and release of connections, and updates the residual capacities on each link based on the capacity requested by connections.
When a connection is registered (that is, accepted),
the object describing it must specify several pieces of
information such as the working path (optionally,
the backup path), the requested capacity, a reference
to the algorithm that was used to find the paths, and a
unique id for the connection. The class
ConnectionInfo
serves a
connection descriptor for TED objects.
Other functions offered are:
In general, the information associated to each link (cost, residual capacity, connection passing through it, etc) is kept (and expected) considering separate entries for each link direction. When a method operates simultaneously on both link directions, "bidi" appears in its name, as in getConnPerBidiLink(E).
Note that a TED object only registers the fact that a failure has happened; it does not automatically remove connections, adjusst residual capacity or trigger path switching (from working to backup path), or perform reversion when a link is restored. These are the duties of the entity that uses the TED object.
There may be any number of instances of this class, but given that the information kept here is global for a given topology, quite usually a single instance is shared among several entities. For example, if two routing algorithms are used concurrently over the same topology (one per demand/service type, for example), one TED instance would be created and passed to the constructors of the two routing algorithm
Field Summary | |
---|---|
SimGraph<V,E> |
g
The graph associated to this TED. |
Constructor Summary | |
---|---|
TED(SimGraph<V,E> g,
java.util.Map<E,java.lang.Integer> link_cap,
java.util.Map<E,? extends java.lang.Number> cost)
Creates a new TED instance for the topology g with
the link capacities and costs in link_cap and
cost respectively. |
|
TED(TED<V,E> r)
A shallow copy constructor. |
Method Summary | |
---|---|
boolean |
bidiLinkIsFailed(E e)
Returns true if link e (either itself or its reverse) is
registered as failed. |
SimGraph<V,E> |
filterByCap(int min_cap)
Returns a subgraph where links with residual capacity less than min_cap are (virtually) removed. |
int |
getConnCount()
Returns the number of connections. |
ConnectionInfo<V,E> |
getConnection(int id)
Returns the connection descriptor object for the given connection id, or null if a connection with that id does not exist. |
java.util.Collection<ConnectionInfo<V,E>> |
getConnections()
Returns an unmodifiable view of the connection descriptor objects. |
java.util.Set<java.lang.Integer> |
getConnIDs()
Returns an unmodifiable view (as a set) of the connection ids. |
java.util.List<ConnectionInfo<V,E>> |
getConnPerBidiLink(E e)
Returns a copy of the list of connections passing thourgh a link e in its both directions. |
java.util.List<ConnectionInfo<V,E>> |
getConnPerLink(E e)
Returns a copy of the list of connections passing thourgh a link e . |
double |
getCost(E e)
Returns the cost of link e . |
java.util.Set<E> |
getFailedLinks()
Returns an unmodifiable view of the set of links registered as failed. |
E |
getFirstFailedBidiLink(Path<V,E> path)
Returns the first link of path
that is currently registered as failed, or null if all links
are operative. |
int |
getLinkCap(E e)
Returns the capacity of link e . |
int |
getResidualCap(E e)
Returns the residual capacity of link e . |
void |
initLinkInstallationTime()
Resets the link installation time of each link to zero. |
void |
initResidualCap()
Sets the residual capacity of each link to its link (full) capacity. |
void |
recoverBidiLink(E e,
int clock)
Registers that both e and reverse(e )
are not in the failed state anymore. |
void |
registerBidiLinkFailure(E e)
Registers the failure of links e and
reverse(e ). |
void |
registerConnection(ConnectionInfo<V,E> cnx)
Register the acceptance of a connection, updates the internal information and informs the corresponding routing algorithm that a connection has been accepted. |
void |
registerConnPerLink(ConnectionInfo<V,E> cnx,
Path<V,E> path)
Updates the list of connections using the links of a given path. |
void |
reinstallBidiLinks(java.util.Collection<E> links,
int clock)
Calls recoverBidiLink(E, int) for each element in links
and sets the residual capacity of both link directions to
the valure returned by getLinkCap(E) . |
void |
releaseConnection(int id)
Release the connection identified by id . |
void |
retireBidiLinks(java.util.Collection<E> failed)
Calls registerBidiLinkFailure(E) for each link in
failed and sets the residual capacity of both link directions
to zero. |
void |
setCost(E e,
java.lang.Number n)
Sets the cost of link e to n . |
void |
setCostMap(java.util.Map<E,? extends java.lang.Number> cost)
Replaces the current cost map with the parameter cost . |
void |
setLinkCap(E e,
int cap)
Sets the total capacity of link e to cap . |
void |
setResidualCap(E e,
int cap)
Sets the residual capacity of link e to cap . |
void |
unregisterConnPerLink(ConnectionInfo<V,E> cnx,
Path<V,E> path)
Removes connection cnx from the list of
connections passing through the links in path . |
void |
updateResidualCap(ConnectionInfo<V,E> cnx,
Path<V,E> path,
int delta)
Updates the residual capacity of links on a given path. |
void |
updateResidualCap(ConnectionInfo<V,E> cnx,
Path<V,E> path,
int delta,
boolean bidir)
Updates the residual capacity of links on a given path. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final SimGraph<V,E> g
Constructor Detail |
---|
public TED(SimGraph<V,E> g, java.util.Map<E,java.lang.Integer> link_cap, java.util.Map<E,? extends java.lang.Number> cost)
g
with
the link capacities and costs in link_cap
and
cost
respectively. If these maps are null,
empty (non-null) maps are created for them.
Residual capacity is set to link capacity, that is, each link is considered fully available.
The installation time of each link is set to 0 and all links are marked as operational.
The cost map can hold values of any Number-derived class (for example Integer). Nevertheless, take into account that
getCost(E)
always returns a double value.
setCost(E, java.lang.Number)
for details.
public TED(TED<V,E> r)
setCostMap(Map)
.
Method Detail |
---|
public void initResidualCap()
public void initLinkInstallationTime()
public void setResidualCap(E e, int cap)
e
to cap
.
The previous value, if any, is replaced.
No checking is performed to make sure that the given
link is in the set of links of the topology. The new capacity
can be any integer (positive, negative, zero).
public int getResidualCap(E e)
e
. If the given
link does not exist, a NullPointerException is
thrown (by the JVM).
public void setCostMap(java.util.Map<E,? extends java.lang.Number> cost)
cost
.
public void setLinkCap(E e, int cap)
e
to cap
.
The previous value, if any, is replaced. The new capacity
can be any integer (positive, negative, zero).
public int getLinkCap(E e)
e
. If the given
link does not exist, a NullPointerException is
thrown (by the JVM).
public void setCost(E e, java.lang.Number n)
e
to n
.
The previous value, if any, is replaced. The new cost
can be any value.
Note that the values in the cost map can be of any Number derived type, for example Integer, but formal parameter of this method is Number. This opens the possibility to type system violations:
Map cost = new HashMap(); ... cost.put(a, 100); cost.put(b, 200); ... ted.setCostMap(cost); // There would be a type violation here (map holds Integer, // cost passed is double). ted.setCost(b, 200.5); ...This situation is impossible to avoid completely in the today's Java (due to type erasure). To mitigate the possibility of error, this method performs the following before updating the cost map:
n
must be
assignment-compatible to one of the existing values
(one element chosen arbitrarily).
If not, a runtime exception is thrown.
In any case, updating the values of the cost map through a TED instance is rare, since the caller usually already holds a type-safe reference that is easier to use.
java.lang.ClassCastException
- if the new value (n
)
is not assignment-compatible with some other value
already present in the map.public double getCost(E e)
e
. If the given
link does not exist, a NullPointerException is
thrown (by the JVM).
The value returned is always a double, irrespective of
the element's actual type.
public ConnectionInfo<V,E> getConnection(int id)
public java.util.Collection<ConnectionInfo<V,E>> getConnections()
public java.util.Set<java.lang.Integer> getConnIDs()
public int getConnCount()
public void registerConnPerLink(ConnectionInfo<V,E> cnx, Path<V,E> path)
public void unregisterConnPerLink(ConnectionInfo<V,E> cnx, Path<V,E> path)
cnx
from the list of
connections passing through the links in path
.
It does nothing if cnx
is null.
public void registerConnection(ConnectionInfo<V,E> cnx)
registerConnPerLink(ConnectionInfo, Path)
is called for
cnx.wrk_path and cnx.bkp_path.
If cnx.ra is not null,
the methods RoutingAlg.commitWorkingPath(ConnectionInfo)
and
RoutingAlg.commitBackupPath(ConnectionInfo)
are called.
Note that these methods are ultimately responsible for
assigning capacity, typically by calling
arranging a call to updateResidualCap()
.
Thus, with cnx.ra, residual capacity is not maintained.
After registerconnection, the connection descriptor should be treated by the caller as a constant.
public void releaseConnection(int id)
id
. If
the given connection is not registered, it just returns. If it
does exist, performs the actions so as to reverse what is
performed in registerConnection(bcds.phison.ra.ConnectionInfo)
.
public void updateResidualCap(ConnectionInfo<V,E> cnx, Path<V,E> path, int delta, boolean bidir)
path
with current_value + delta
where delta can be positive or negative.
A link is skipped (its residual capacity is not updated) if:
cnx
had been created.
cnx
- the field cnx.clock will be used as
the time reference (this is the only field of
cnx used in this method. In the future,
it might be replaced by a "clock" parameter directly).path
- the residual capacities of the links included in
this path are the ones to be updated.delta
- the increment (positive or negative).bidir
- update each link e as well as reverse(e).public void updateResidualCap(ConnectionInfo<V,E> cnx, Path<V,E> path, int delta)
public SimGraph<V,E> filterByCap(int min_cap)
min_cap
are (virtually) removed.
public java.util.List<ConnectionInfo<V,E>> getConnPerLink(E e)
e
.
public java.util.List<ConnectionInfo<V,E>> getConnPerBidiLink(E e)
e
in its both directions.
public void registerBidiLinkFailure(E e)
e
and
reverse(e
).
The capacities (both residual and link capacity)
are left unchanged. Likewise, the list of connections
passing through e
(in both directions) remains intact.
public boolean bidiLinkIsFailed(E e)
e
(either itself or its reverse) is
registered as failed.
public void recoverBidiLink(E e, int clock)
e
and reverse(e
)
are not in the failed state anymore. The link installation
time is set to clock
. It does nothing if neither
e
nor reverse(e
) are
registered as failed.
public void retireBidiLinks(java.util.Collection<E> failed)
registerBidiLinkFailure(E)
for each link in
failed
and sets the residual capacity of both link directions
to zero.
public void reinstallBidiLinks(java.util.Collection<E> links, int clock)
recoverBidiLink(E, int)
for each element in links
and sets the residual capacity of both link directions to
the valure returned by getLinkCap(E)
. The link recovery
time is set to clock
.
For a link e in links
to be reinstalled,
bidiLinkIsFailed(e) must return true. Otherwise,
the link is just skipped.
public E getFirstFailedBidiLink(Path<V,E> path)
path
that is currently registered as failed, or null if all links
are operative. This method returns the first link of
path
for which bidiLinkIsFailed(E)
returns
true, or null if all such calls return false.
It also returns null if path
is null.
public java.util.Set<E> getFailedLinks()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |