Package org.jcsp.net

Class LinkManager.LinksToNodeHolder

  • Enclosing class:
    LinkManager

    private static class LinkManager.LinksToNodeHolder
    extends java.lang.Object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int addLink​(Link link, boolean addIfNoQueue)
      This sends the supplied link to any processes that are waiting for matching link.
      Link getLink​(Profile profile)  
      NodeID getTarget()  
      boolean joinQueue​(ChannelOutput channel, Profile profile)
      This method allows processes to join a queue waiting for a link to a Node (with a known NodeID) to be established.
      int notifyQueuedProcesses​(Profile profile, java.lang.Object toSend)  
      int notifyQueuedProcesses​(Specification[] specs, Link linkToSend)
      This takes a set of link specifications, looks through the set of queues, checks whether the specifications meet requirements of the profile of a queue, and if so, sends the supplied Link to the processes in that queue.
      void removeLink​(Link conn)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • target

        private NodeID target
      • links

        private java.util.HashSet links
      • linkWithNoSpecifiedFacilities

        private Link linkWithNoSpecifiedFacilities
        A link with no special facilities. This is so that if no features are required then no iteration will be needed.
      • waiting

        private java.util.Hashtable waiting
        The processes waiting for a link. The key is the FacilitiesRequired of the link we're waiting for, the value is the channel to the waiting process (or a Vector of these). When the link is available, we notify the process(es) by sending the Link down the channel(s).
    • Constructor Detail

      • LinksToNodeHolder

        public LinksToNodeHolder​(NodeID target)
    • Method Detail

      • getTarget

        public NodeID getTarget()
      • addLink

        public int addLink​(Link link,
                           boolean addIfNoQueue)
        This sends the supplied link to any processes that are waiting for matching link. If there were some processes waiting or the addIfNoQueue parameter was true, then the link is added to this link manager.
        Parameters:
        link - the Link to add.
        addIfNoQueue - boolean inidicating whether to add the link if there were no queued processes.
        Returns:
        the number of processes to which this link was sent.
      • notifyQueuedProcesses

        public int notifyQueuedProcesses​(Profile profile,
                                         java.lang.Object toSend)
      • notifyQueuedProcesses

        public int notifyQueuedProcesses​(Specification[] specs,
                                         Link linkToSend)
        This takes a set of link specifications, looks through the set of queues, checks whether the specifications meet requirements of the profile of a queue, and if so, sends the supplied Link to the processes in that queue. The method returns the number of queues that were notified.
        Parameters:
        specs - an array of Specifcation objects that the link provides.
        linkToSend - the link to send to the queued processes.
        Returns:
        the number of queues that were notified.
      • removeLink

        public void removeLink​(Link conn)
      • joinQueue

        public boolean joinQueue​(ChannelOutput channel,
                                 Profile profile)
        This method allows processes to join a queue waiting for a link to a Node (with a known NodeID) to be established. An infinite buffered channel is supplied. When it is known that a link has been created or failed to be created, notification can be sent down the supplied channel to the waiting process. There is one queue per link required matching matching a given profile. When a link is established, the profile of each queue is tested against the link and, if the profile matches, then all queued processes are notified. This can mean that multiple links to a remote Node might be established but by the time a link has been established, there may be no processes waiting for it as other links may have met their requirements.
        Parameters:
        channel - the channel to put in the queue.
        profile - the profile that the required link must meet.
        Returns:
        a boolean inidicating whether the channel is the first in the queue and hence the link needs to be initiated.