Package org.jcsp.net2

Class LinkFactory

java.lang.Object
org.jcsp.net2.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.

See Also:
  • Constructor Details

    • LinkFactory

      private LinkFactory()
      Default private constructor. Not used.
  • Method Details

    • getLink

      public static Link getLink(NodeID nodeID) throws JCSPNetworkException, IllegalArgumentException
      Creates a new Link or gets an existing one from the the given NodeID.
      Parameters:
      nodeID - NodeID of the Node to connect to.
      Returns:
      A Link connected to the remote Node of given NodeID
      Throws:
      JCSPNetworkException - Thrown if there is a problem connecting to the Node
      IllegalArgumentException - Thrown if an attempt is made to connect to the local Node
    • 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