cgl.narada.transport.tcp
Class TCPLinkFactory

java.lang.Object
  extended by cgl.narada.transport.tcp.TCPLinkFactory
All Implemented Interfaces:
LinkFactory, TransportDebugFlags

public class TCPLinkFactory
extends Object
implements LinkFactory, TransportDebugFlags

This is a TCP implementation of the LinkFactory Interface. Lets 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 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.


    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
    TCPLinkFactory()
               
     
    Method Summary
     boolean canManageLinkMigrationOfType(String linkType)
              Indicates if this factory can manage migration of links of a certain type
     Link createLink(Properties linkProperties)
              Create a communication link based on the properties that have been specified.
     void dispose()
              This method is used to garbage collect any resources associated with the link factory
     String getManagedLinksType()
              Return the type of all the links created/managed by this factory
     TransportHandler getTransportHandler()
               
     void handleInboundTCPLinkRequest(Socket socket)
               
     boolean loadLinkFactoryServices()
              Start communication services.
    static void main(String[] args)
               
     void manageLinkMigration(Link link)
              Used to migrate communications of a link to the one supported by links managed by this factory
     void reportLinkLoss(Link linkLost)
               
     void setLinkFactoryProperties(Properties factoryProperties)
               
     void setLinkStatusInterval(long interval)
              Set the interval for checking status of all links managed by this factory to the one specified in the argument
     void setTransportHandler(TransportHandler transportHandler)
              Sets the reference to the transport handler.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    TCPLinkFactory

    public TCPLinkFactory()
    Method Detail

    setLinkFactoryProperties

    public void setLinkFactoryProperties(Properties factoryProperties)
    Specified by:
    setLinkFactoryProperties in interface LinkFactory

    getManagedLinksType

    public String getManagedLinksType()
    Return the type of all the links created/managed by this factory

    Specified by:
    getManagedLinksType in interface LinkFactory

    createLink

    public Link createLink(Properties linkProperties)
                    throws TransportException
    Create a communication link based on the properties that have been specified.

    Specified by:
    createLink in interface LinkFactory
    Throws:
    TransportException

    setLinkStatusInterval

    public void setLinkStatusInterval(long interval)
    Set the interval for checking status of all links managed by this factory to the one specified in the argument

    Specified by:
    setLinkStatusInterval in interface LinkFactory

    loadLinkFactoryServices

    public boolean loadLinkFactoryServices()
                                    throws TransportException
    Start communication services. In the case of TCP for example, the thread which incorporates the serverSocket.accept() is started

    Specified by:
    loadLinkFactoryServices in interface LinkFactory
    Throws:
    TransportException

    canManageLinkMigrationOfType

    public boolean canManageLinkMigrationOfType(String linkType)
    Indicates if this factory can manage migration of links of a certain type

    Specified by:
    canManageLinkMigrationOfType in interface LinkFactory

    manageLinkMigration

    public void manageLinkMigration(Link link)
                             throws TransportException
    Used to migrate communications of a link to the one supported by links managed by this factory

    Specified by:
    manageLinkMigration in interface LinkFactory
    Throws:
    TransportException

    setTransportHandler

    public void setTransportHandler(TransportHandler transportHandler)
    Sets the reference to the transport handler. This is done during the loadLinkFactory() operation within the transport handler implementations.

    Specified by:
    setTransportHandler in interface LinkFactory

    dispose

    public void dispose()
    This method is used to garbage collect any resources associated with the link factory

    Specified by:
    dispose in interface LinkFactory

    handleInboundTCPLinkRequest

    public void handleInboundTCPLinkRequest(Socket socket)

    reportLinkLoss

    public void reportLinkLoss(Link linkLost)

    getTransportHandler

    public TransportHandler getTransportHandler()

    main

    public static void main(String[] args)


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