cgl.narada.transport
Class TransportHandlerImpl

java.lang.Object
  extended by cgl.narada.transport.TransportHandlerImpl
All Implemented Interfaces:
TransportDebugFlags, TransportHandler

public class TransportHandlerImpl
extends Object
implements TransportHandler, TransportDebugFlags

This class provides an implementation of the transport handler interface. The transport handler interface serves as an intermediary between the protocol layers & the underlying transport implementations. The transport handler implementation pre-loads several link factory implementations. The implementation provides all the functionalities that needs to be addressed while implementing the transport handler interface. Among the operations supported by the transport handler interface are the ability to

For the purposes of clarity in our dicussions let us assume that the connection is being initiated by a node A to another node B. There are two independent factors that need to borne in mind while using LinkFactory. The first is of course setting the link factory properties. The second is specifying the properties to create a link to some other node B.

To initialize the TCPLinkFactory one needs to specify the TCPServerPort . When the value of this variable is set to 0 it implies that the node A initiating a connection to node B will not accept link creation requests from any other node.
To create a TCP link to node B. The following properties needs to be specified.

  • hostname: This is the hostname on which the node B's process is running.
  • portnum: This is the port number on which node B accepts link creation requests from other nodes. In other words, the TCPServerPort specified to the TCPChannelFactory at node B is equal to portnum.

    To initialize the UDPLinkFactory one needs to specify UDPListenerPort , this is the port on which the process running this factory would listen to for datagram packet communications.
    To create a UDP link to node B. The following properties needs to be specified.

  • hostname - The host on which node B's process is running
  • portnum - The portnum on which node B is listening to, for datagram packets.

    No properties need to be setup during the initialization of the MulticastLinkFactory. To enable receipt and sending of data to a given multicast group the user needs to specify the MulticastHost (which must be a valid multicast address) and MulticastPort information.


    Field Summary
     
    Fields inherited from interface cgl.narada.transport.TransportDebugFlags
    IPSecLink_Debug, IPSecLinkFactory_Debug, IPSecReceiverThread_Debug, IPSecSenderThread_Debug, IPSecServerThread_Debug, MulticastLink_Debug, MulticastLinkFactory_Debug, MulticastReceiverThread_Debug, MulticastSenderThread_Debug, NIOTCPLink_Debug, NIOTCPLinkFactory_Debug, NIOTCPReceiverThread_Debug, NIOTCPSenderThread_Debug, NIOTCPServerThread_Debug, PoolTCPLink_Debug, PoolTCPLinkFactory_Debug, PoolTCPLinkReceiver_Debug, PoolTCPLinkSender_Debug, PoolTCPServerThread_Debug, PTCPLink_Debug, PTCPLinkFactory_Debug, PTCPReceiverThread_Debug, PTCPSenderThread_Debug, PTCPServerThread_Debug, ReceiveTask_Debug, RTPLink_Debug, RTPLinkFactory_Debug, RTPReceiverThread_Debug, RTPSenderThread_Debug, SendTask_Debug, TCPLink_Debug, TCPLinkFactory_Debug, TCPReceiverThread_Debug, TCPSenderThread_Debug, TCPServerThread_Debug, TransmissionManager_Debug, TransportHandlerImpl_Debug, UDPLink_Debug, UDPLinkFactory_Debug, UDPReceiverThread_Debug, UDPSenderThread_Debug
     
    Constructor Summary
    TransportHandlerImpl(Handler handler)
               
     
    Method Summary
     boolean alternateLinksAvailableTo(String linkId)
               
     void closeAllLinks()
              Close all links that have been initiated by the hosting node
     void closeLinks(Object naradaBrokeringId)
              Eliminate all links associated with communicating with the specified naradaBrokering id
     void closeLinks(String linkId)
              Close all links associated with the specified Id.
     void dataReceived(byte[] data, Object linkIdentifier)
              Upon receipt of data at a link that has an assigned NaradaBrokering identifier, this is the method that is used.
     void dataReceived(byte[] data, String linkIdentifier)
              byte[] signifies the data received over a communication link.
     void disposeAllCommunicationResources()
               
     String[] enumerateLinks()
              Enumerate the list of links available.
     String[] getListOfCommunicationProtocolsSupported()
              Provides a list of transport services that are supported by the node
     PerformanceMeasurement getMeasurementService()
              Retrieves the management service
     MonitoringService getMonitoringService()
               
     Hashtable getRegisteredLinks()
               
     Hashtable getSupportedTransportProtocols()
              Gets the list of registered transport protocols along with the property list associated with these protocols.
     TransmissionManager getTransmissionManager()
              Retrieve the TransmissionManager, which keeps track of ongoing transmissions.
     void loadCommunicationsOfType(Properties props, String commType)
              Used to load a specific communications handler
    static void main(String[] args)
               
     void manageLinkLoss(Link link)
              This method is to be invoked by link factories to report communication failure in one of the links (reported in argument) that it manages
     boolean manageLinkMigrationRequest(Link link, String migrateTo)
              This method is to be invoked by link factory to request migration of transport protocols for one of its managed links
     void mapLinkToBrokerNode(String linkId, Object naradaBrokeringId, Object brokerConnectionIdentifier)
              This method is invoked from the protocol layers, after assigning a NaradaBrokering id
     void mapLinkToClientNode(String linkId, Object naradaBrokeringId, Object clientIdentifier)
              This method is invoked from the protocol layers, after assigning a NaradaBrokering id
     void registerLink(LinkFactory linkFactory, Link link)
              This method is invoked by a link factory when it has successfully set up a connection based on the specific transport protocol.
     void sendData(byte[] data, Object naradaBrokeringId)
              Used to send a stream of bytes to a NaradaBrokering node
     void sendData(byte[] data, Object naradaBrokeringId, String dataType)
              Used to send a stream of bytes to a NaradaBrokering node.
     void sendData(byte[] data, Object naradaBrokeringId, String linkType, String dataType)
              Used to send a stream of bytes to a NaradaBrokering node, using a specified communication type.
     void sendData(byte[] data, String uninitializedNode)
              Send data to an unitialized node (or a node to which connection is initiated for the first time).
     void sendData(byte[] data, String uninitializedNode, String dataType)
              Send data to an unitialized node (or a node to which connection is initiated for the first time).
     void setLinkStatusIntervals(LinkFactory linkFactory, long pingIntervals)
              Sets the interval size for a connection status checks for links managed by a specific link factory.
     void setLinkStatusIntervals(long pingIntervals)
              This is used to set the interval size at which tests on connection status need to be performed.
     void setupAlternateLink(Properties linkProperties, Object naradaBrokeringId, String linkType, long keepAliveTime)
              Used by the protocol layers to setup alternate links for communication based on the type of data that is being routed.
     String setupLink(Properties linkProperties, String linkType)
              This is used to setup a communication link between 2 NaradaBrokering end points.
     void shutdown()
               
     void startMonitoringService()
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    TransportHandlerImpl

    public TransportHandlerImpl(Handler handler)
    Method Detail

    setLinkStatusIntervals

    public void setLinkStatusIntervals(long pingIntervals)
    This is used to set the interval size at which tests on connection status need to be performed.

    Specified by:
    setLinkStatusIntervals in interface TransportHandler

    setLinkStatusIntervals

    public void setLinkStatusIntervals(LinkFactory linkFactory,
                                       long pingIntervals)
    Sets the interval size for a connection status checks for links managed by a specific link factory.

    Specified by:
    setLinkStatusIntervals in interface TransportHandler

    getListOfCommunicationProtocolsSupported

    public String[] getListOfCommunicationProtocolsSupported()
    Provides a list of transport services that are supported by the node

    Specified by:
    getListOfCommunicationProtocolsSupported in interface TransportHandler

    loadCommunicationsOfType

    public void loadCommunicationsOfType(Properties props,
                                         String commType)
                                  throws TransportException
    Description copied from interface: TransportHandler
    Used to load a specific communications handler

    Specified by:
    loadCommunicationsOfType in interface TransportHandler
    Throws:
    TransportException

    registerLink

    public void registerLink(LinkFactory linkFactory,
                             Link link)
    This method is invoked by a link factory when it has successfully set up a connection based on the specific transport protocol.

    Specified by:
    registerLink in interface TransportHandler

    manageLinkLoss

    public void manageLinkLoss(Link link)
    This method is to be invoked by link factories to report communication failure in one of the links (reported in argument) that it manages

    Specified by:
    manageLinkLoss in interface TransportHandler

    manageLinkMigrationRequest

    public boolean manageLinkMigrationRequest(Link link,
                                              String migrateTo)
    This method is to be invoked by link factory to request migration of transport protocols for one of its managed links

    Specified by:
    manageLinkMigrationRequest in interface TransportHandler

    dataReceived

    public void dataReceived(byte[] data,
                             String linkIdentifier)
    byte[] signifies the data received over a communication link. When this particular method is invoked it signifies a handshake. When a link has been assigned a NaradaBrokering identifier this method will not be invoked by the link. Certain data pertaining to the initialization of the link, checking for the status of the link etc. are not routed up to the transport handler.

    Specified by:
    dataReceived in interface TransportHandler

    dataReceived

    public void dataReceived(byte[] data,
                             Object linkIdentifier)
    Upon receipt of data at a link that has an assigned NaradaBrokering identifier, this is the method that is used.

    Specified by:
    dataReceived in interface TransportHandler

    setupLink

    public String setupLink(Properties linkProperties,
                            String linkType)
                     throws TransportException
    This is used to setup a communication link between 2 NaradaBrokering end points. The communication link type is specified in the arguments

    Specified by:
    setupLink in interface TransportHandler
    Throws:
    TransportException

    setupAlternateLink

    public void setupAlternateLink(Properties linkProperties,
                                   Object naradaBrokeringId,
                                   String linkType,
                                   long keepAliveTime)
                            throws TransportException
    Used by the protocol layers to setup alternate links for communication based on the type of data that is being routed. Such alternate links also have a keepAlive timer associated with them, which ensure the garbage collection of the link after the time has expired

    Specified by:
    setupAlternateLink in interface TransportHandler
    Throws:
    TransportException

    sendData

    public void sendData(byte[] data,
                         String uninitializedNode)
                  throws TransportException
    Send data to an unitialized node (or a node to which connection is initiated for the first time).

    Specified by:
    sendData in interface TransportHandler
    Throws:
    TransportException

    sendData

    public void sendData(byte[] data,
                         Object naradaBrokeringId)
                  throws TransportException
    Used to send a stream of bytes to a NaradaBrokering node

    Specified by:
    sendData in interface TransportHandler
    Throws:
    TransportException

    sendData

    public void sendData(byte[] data,
                         String uninitializedNode,
                         String dataType)
                  throws TransportException
    Send data to an unitialized node (or a node to which connection is initiated for the first time). This method also includes information regarding the type (audio/video/xml-attachments etc.) of the data encapsulated within the data stream.

    Specified by:
    sendData in interface TransportHandler
    Throws:
    TransportException

    sendData

    public void sendData(byte[] data,
                         Object naradaBrokeringId,
                         String dataType)
                  throws TransportException
    Used to send a stream of bytes to a NaradaBrokering node. This method also includes information regarding the type (audio/video/xml-attachments etc.) of the data encapsulated within the data stream.

    Specified by:
    sendData in interface TransportHandler
    Throws:
    TransportException

    sendData

    public void sendData(byte[] data,
                         Object naradaBrokeringId,
                         String linkType,
                         String dataType)
                  throws TransportException
    Used to send a stream of bytes to a NaradaBrokering node, using a specified communication type. The alternate link should have already been set up prior to the invocation of this method. This method also includes information regarding the type (audio/video/xml-attachments etc.) of the data encapsulated within the data stream.

    Specified by:
    sendData in interface TransportHandler
    Throws:
    TransportException

    enumerateLinks

    public String[] enumerateLinks()
    Enumerate the list of links available. What is returned is the linkID of all the links originating from this node. Returns NULL if no links are available.

    Specified by:
    enumerateLinks in interface TransportHandler

    closeLinks

    public void closeLinks(Object naradaBrokeringId)
    Eliminate all links associated with communicating with the specified naradaBrokering id

    Specified by:
    closeLinks in interface TransportHandler

    closeLinks

    public void closeLinks(String linkId)
    Close all links associated with the specified Id.

    Specified by:
    closeLinks in interface TransportHandler

    closeAllLinks

    public void closeAllLinks()
    Description copied from interface: TransportHandler
    Close all links that have been initiated by the hosting node

    Specified by:
    closeAllLinks in interface TransportHandler

    disposeAllCommunicationResources

    public void disposeAllCommunicationResources()
    Specified by:
    disposeAllCommunicationResources in interface TransportHandler

    mapLinkToClientNode

    public void mapLinkToClientNode(String linkId,
                                    Object naradaBrokeringId,
                                    Object clientIdentifier)
    This method is invoked from the protocol layers, after assigning a NaradaBrokering id

    Specified by:
    mapLinkToClientNode in interface TransportHandler

    mapLinkToBrokerNode

    public void mapLinkToBrokerNode(String linkId,
                                    Object naradaBrokeringId,
                                    Object brokerConnectionIdentifier)
    This method is invoked from the protocol layers, after assigning a NaradaBrokering id

    Specified by:
    mapLinkToBrokerNode in interface TransportHandler

    alternateLinksAvailableTo

    public boolean alternateLinksAvailableTo(String linkId)

    getMeasurementService

    public PerformanceMeasurement getMeasurementService()
    Description copied from interface: TransportHandler
    Retrieves the management service

    Specified by:
    getMeasurementService in interface TransportHandler

    getRegisteredLinks

    public Hashtable getRegisteredLinks()
    Specified by:
    getRegisteredLinks in interface TransportHandler

    shutdown

    public void shutdown()
    Specified by:
    shutdown in interface TransportHandler

    startMonitoringService

    public void startMonitoringService()
                                throws TransportException
    Throws:
    TransportException

    getMonitoringService

    public MonitoringService getMonitoringService()

    getSupportedTransportProtocols

    public Hashtable getSupportedTransportProtocols()
    Gets the list of registered transport protocols along with the property list associated with these protocols.

    Specified by:
    getSupportedTransportProtocols in interface TransportHandler

    main

    public static void main(String[] args)

    getTransmissionManager

    public TransmissionManager getTransmissionManager()
    Description copied from interface: TransportHandler
    Retrieve the TransmissionManager, which keeps track of ongoing transmissions.

    Specified by:
    getTransmissionManager in interface TransportHandler
    See Also:
    TransportHandler.getTransmissionManager()


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