Package org.jcsp.net

Class LinkManager

java.lang.Object
org.jcsp.net.LinkManager
All Implemented Interfaces:
CSProcess

class LinkManager extends Object implements CSProcess
This class manages the list of open links. It ensures that there is only ever one link between two given JCSP servers.

  • Field Details

  • Constructor Details

    • LinkManager

      LinkManager()
  • Method Details

    • run

      public void run()
      Used to run the LinkManager.
      Specified by:
      run in interface CSProcess
    • start

      public void start()
      Starts this instance of the LinkManager and returns.
    • getInstance

      static LinkManager getInstance()
      Get the singleton instance of LinkManager.
      Returns:
      The singleton LinkManager object.
    • registerLink

      boolean registerLink(Link conn)
      Register a Link in the database. Prevents duplicates. Returns true if there was no prior entry for that NodeID, and one was added. (In that case it has also notified any waiting processes). Returns false (and does not change the database) if there is an existing entry.
      Returns:
      true iff there was no prior entry for that NodeID
    • registerFailure

      void registerFailure(Link conn)
    • getTxChannel

      ChannelOutput getTxChannel(NodeID target)
      Get a channel to use to send to a remote PC. Will block (possibly forever) while the link is being established.
      Parameters:
      target - The system to connect to.
      Returns:
      The Channel to use to send to the requested computer.
      Throws:
      IllegalStateException - If init() has not been called.
    • getTxChannel

      ChannelOutput getTxChannel(NodeID target, Profile linkProfile)
    • getTxChannel

      ChannelOutput getTxChannel(NodeAddressID targetAddress)
      This is used to get a Link when no details are known about the other Node except for one of its addresses. A typical situation when this would be used is to connect to the CNS.
      Parameters:
      targetAddress - The address to which to create a link.
      Returns:
      the ChannelOuput that writes to the link.
    • getLink

      private Link getLink(NodeID target, Profile linkProfile)
      Get a Link to a remote PC. Will block (possibly forever) while the link is being established.
      Parameters:
      target - The system to connect to.
      Returns:
      The Link to the requested computer.
      Throws:
      IllegalStateException - If init() has not been called.
    • lostLink

      int lostLink(Link conn)
      Called by a Link to indicate the link broke.
      Parameters:
      conn - The broken link.
    • linkExists

      boolean linkExists(NodeID otherNode)
      This method tests whether a link exists to a specified remote Node in this LinkManager.
      Parameters:
      otherNode - The NodeID of a remote Node to check the existance
      Returns:
      true iff a link currently exists to the specified remote Node.
    • getLinkLostEventChannel

      AltingChannelInput getLinkLostEventChannel()