gov.nist.antd.merlin.util
Class ConnectionUtil

java.lang.Object
  |
  +--gov.nist.antd.merlin.util.ConnectionUtil

public final class ConnectionUtil
extends java.lang.Object

This class contains tools connection management.

 This class was developed at the National Institute of Standards and
 Technology by employees of the Federal Government in the course of
 their official duties. Pursuant to title 17 Section 105 of the United
 States Code this software is not subject to copyright protection and
 is in the public domain.
 NIST assumes no responsibility whatsoever for its use by other parties,
 and makes no guarantees, expressed or implied, about its quality,
 reliability, or any other characteristic.
 
We would appreciate acknowledgement if the software is used.
NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.

Author:
borchert
, rouil

Constructor Summary
private ConnectionUtil()
          private constructor to avoid instantiation
 
Method Summary
static boolean connectSwitches(OpticalConnection oRoute)
          Connect the switches of the given route.
static boolean connectSwitches(OpticalConnection oRoute, int[] addPort)
          Connect the switches of the given route.
static boolean connectSwitches(OpticalConnection oRoute, int[] addPort, int[] dropPort)
          Connect the switches of the given route.
static OpticalConnection createConnection(ExtRouter source, ExtRouter dest, QualityOfService qos, boolean autoConnect)
          Connection request.
static boolean deleteConnection(OpticalConnection oRoute)
          Delete a lightpath and disconnect all lambdas
static boolean disconnectSwitches(OpticalConnection oRoute)
          Disconnect the given route.
static OpticalConnection findConnection(ExtRouter source, ExtRouter dest, QualityOfService qos)
          Request a lightpath with the specific QoS.
static int[] getReceiverInformations(OpticalConnection oRoute)
          Return the port numbers for the receiver
static int[] getSenderInformations(OpticalConnection oRoute)
          Return the port numbers for the sender on the working route or the backup route if existing.
static boolean isCompatible(OpticalConnection route, ExtRouter source, ExtRouter dest, QualityOfService qos)
          Compare the characteristics of the route and the QoS
static int[] register(ProtocolSession session, OpticalConnection oRoute)
          This method register to the given route or the attached backup route if failed.
static int[] register(ProtocolSession srcSession, java.lang.String destProtocolName, OpticalConnection oRoute)
          This method register to the given route or the attached backup route if failed.
static boolean unregister(ProtocolSession session, OpticalConnection oRoute)
          Unregister a ProtocolSession to free this route.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionUtil

private ConnectionUtil()
private constructor to avoid instantiation

Method Detail

createConnection

public static OpticalConnection createConnection(ExtRouter source,
                                                 ExtRouter dest,
                                                 QualityOfService qos,
                                                 boolean autoConnect)
Connection request. This method will create a new route and connect the switches along the path if requested

Parameters:
source - The source of the connection
dest - The destination of the connection
qos - The quality of service (can be null)
autoConnect - if True, then connect the switches along the path.
Returns:
The OpticalConnection computed or null if error.

findConnection

public static OpticalConnection findConnection(ExtRouter source,
                                               ExtRouter dest,
                                               QualityOfService qos)
Request a lightpath with the specific QoS.

Parameters:
source - The source of the connection
dest - The destination of the connection
qos - The quality of service (can be null)
Returns:
The OpticalConnection computed or null if no route found.

isCompatible

public static boolean isCompatible(OpticalConnection route,
                                   ExtRouter source,
                                   ExtRouter dest,
                                   QualityOfService qos)
Compare the characteristics of the route and the QoS

Parameters:
route - The route to check.
source - The supposed source node.
dest - The supposed destination node.
qos - The Quality of Service requested.
Returns:
true if the route responds to the qos, source and destination

getSenderInformations

public static int[] getSenderInformations(OpticalConnection oRoute)
Return the port numbers for the sender on the working route or the backup route if existing.

Parameters:
oRoute - An optical route
Returns:
An array of int. The port IDs or null if the path is not computed or data missing.

getReceiverInformations

public static int[] getReceiverInformations(OpticalConnection oRoute)
Return the port numbers for the receiver

Parameters:
oRoute - An optical route
Returns:
An array of int. The port IDs or null if the path is not computed or data missing.

deleteConnection

public static boolean deleteConnection(OpticalConnection oRoute)
Delete a lightpath and disconnect all lambdas

Parameters:
oRoute - the OpticalConnection to delete
Returns:
True if the oRoute is deleted
Throws:
if - the parameter is null

connectSwitches

public static boolean connectSwitches(OpticalConnection oRoute)
Connect the switches of the given route.

Parameters:
oRoute - The OpticalConnection to connect.
Returns:
true if the connection is done.
Throws:
java.lang.NullPointerException - If the given route is null.

connectSwitches

public static boolean connectSwitches(OpticalConnection oRoute,
                                      int[] addPort)
Connect the switches of the given route.

Parameters:
oRoute - The OpticalConnection to connect.
addPort - The port number to use as addPort
Returns:
true if the connection is done.
Throws:
java.lang.NullPointerException - If the given route is null.

connectSwitches

public static boolean connectSwitches(OpticalConnection oRoute,
                                      int[] addPort,
                                      int[] dropPort)
Connect the switches of the given route.

Parameters:
oRoute - The OpticalConnection to connect.
addPort - The port number to use as addPort
dropPort - The port number to use at the destination
Returns:
true if the connection is done.
Throws:
java.lang.NullPointerException - If the given route is null.

disconnectSwitches

public static boolean disconnectSwitches(OpticalConnection oRoute)
                                  throws java.lang.NullPointerException
Disconnect the given route.

Parameters:
oRoute - The OpticalConnection to disconnect.
Returns:
False if the parameter is not the owner.
Throws:
java.lang.NullPointerException - The given session is null.

register

public static int[] register(ProtocolSession session,
                             OpticalConnection oRoute)
This method register to the given route or the attached backup route if failed. It also connect all the channels to receiver messages.

Parameters:
session - The protocol that wants to register.
oRoute - The OpticalConnection to register to.
Returns:
The list of port used by each channel of the route or null.
Throws:
java.lang.NullPointerException - If the given owner is null.

register

public static int[] register(ProtocolSession srcSession,
                             java.lang.String destProtocolName,
                             OpticalConnection oRoute)
This method register to the given route or the attached backup route if failed. It also connect all the channels to receiver messages.

Parameters:
srcSession - The ProtocolSession that wants to use the route
destProtocolName - The name of the protocol to attach the route at the destination node
oRoute - The OpticalConnection to register to.
Returns:
The list of port used by each channel of the route or null.
Throws:
java.lang.NullPointerException - If the given owner is null.

unregister

public static boolean unregister(ProtocolSession session,
                                 OpticalConnection oRoute)
                          throws java.lang.NullPointerException
Unregister a ProtocolSession to free this route. The parameter must be the owner itself. Another Protocol cannot unregister an other one.

Parameters:
session - The ProtocolSession that uses the route
oRoute - The OpticalConnection to unregister to.
Returns:
False if the parameter is not the owner.
Throws:
java.lang.NullPointerException - The given session is null.