Package org.jcsp.net2

Class LinkManager


  • final class LinkManager
    extends java.lang.Object
    Class for managing Links. Ensures that only one Link is only ever created for each individual Node that the hosting Node may be connected to. This is an internal management class of JCSP. For information on how to create Links, see LinkFactory.
    See Also:
    Link, LinkFactory
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.ArrayList eventChans
      These event channels are used by the LinkManager to inform any process that may be interested in Link Lost events.
      private static LinkManager instance
      Singleton instance of the LinkManager.
      private static java.util.Hashtable links
      A table containing the links currently in operation within the Node.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private LinkManager()
      Private default constructor for singleton instance.
    • Field Detail

      • links

        private static final java.util.Hashtable links
        A table containing the links currently in operation within the Node. The key is a NodeID and the value is the Link itself for that specific NodeID.
      • eventChans

        private static java.util.ArrayList eventChans
        These event channels are used by the LinkManager to inform any process that may be interested in Link Lost events.
      • instance

        private static LinkManager instance
        Singleton instance of the LinkManager.
    • Constructor Detail

      • LinkManager

        private LinkManager()
        Private default constructor for singleton instance.
    • Method Detail

      • getInstance

        static LinkManager getInstance()
        Gets the singleton instance of the LinkManager
        Returns:
        The singleton instance of the LinkManager
      • lostLink

        void lostLink​(Link link)
        Handles a Link Lost event. This is done by sending messages over the event channels registered in the eventChans ArrayList. This is possible in the current thread as each event channel is infinitely buffered, so no blocking can occur.
        Parameters:
        link - The Link that has been lost.
      • registerLink

        boolean registerLink​(Link link)
        Registers a new Link with the LinkManager.
        Parameters:
        link - The Link to register.
        Returns:
        True if a Link to the Node does not yet exist, false otherwise.
      • requestLink

        Link requestLink​(NodeID id)
        Returns the Link for the given NodeID
        Parameters:
        id - The NodeID of the remote node
        Returns:
        The Link for the given NodeID
      • getLinkLostEventChannel

        AltingChannelInput getLinkLostEventChannel()
        Gets a channel input end for receiving Link Lost events.
        Returns:
        A input end for receiving Link Lost Events.