Package org.jcsp.net2

Class LinkFactory


  • public final class LinkFactory
    extends Object
    This class is used to create a new Link from a given NodeID or NodeAddress.

    It is perfectly reasonable for a user to create a Link to another Node without utilising the normal connection methods. This class is therefore made public to allow such an occurrence.

    Example, using TCP/IP

    TCPIPNodeAddress address = new TCPIPNodeAddress("192.168.1.100", 5000);
    Link link = LinkFactory.getLink(address);

    The getLink method will either return an existing Link if one exists, or it shall create a new one if necessary.

    Using this method allows quick creation of channels / barrier on a remote Node without going through the normal name servers. For example:

    NetChannelLocation loc = new NetChannelLocation(link.getRemoteNodeID(), 100);
    NetChannelOutput out = NetChannelEnd.one2net(loc);

    This method is generally considered faster than using the CNS, or creating channels just using the address and VCN. It does require the user to know the address and channel number that is to be connected too.

    Author:
    Kevin Chalmers (updated from Quickstone Technologies)
    See Also:
    Link, NodeAddress, NodeID
    • Method Detail

      • getLink

        public static Link getLink​(NodeAddress addr)
                            throws JCSPNetworkException
        Creates a new Link, or retrieves an existing one, from a NodeAddress
        Parameters:
        addr - The NodeAddress of the Node to connect to
        Returns:
        A new Link connected to the node at the given NodeAddress
        Throws:
        JCSPNetworkException - Thrown if anything goes wrong during the connection