Class BNS

  • All Implemented Interfaces:
    CSProcess

    public class BNS
    extends Object
    implements CSProcess
    This is the main process for the Barrier Name Server. For a more in depth discussion of name servers, see CNS.
    Author:
    Kevin Chalmers
    See Also:
    CNS, BNSService, Node
    • Method Detail

      • getInstance

        public static BNS getInstance()
        Gets the singleton instance of the BNS
        Returns:
        The singleton instance of the BNS
      • initialise

        public static void initialise​(NodeID bnsNode)
                               throws JCSPNetworkException
        Initialises the connection to the BNS
        Parameters:
        bnsNode - The NodeID of the BNS Node
        Throws:
        JCSPNetworkException - Thrown if something goes wrong in the underlying architecture
      • initialise

        public static void initialise​(NodeAddress bnsNode)
                               throws JCSPNetworkException
        Initialises the connection to the BNS
        Parameters:
        bnsNode - The NodeAddress of the BNS Node
        Throws:
        JCSPNetworkException - Thrown if something goes wrong in the underlying architecture
      • run

        public void run()
        The run method for the BNS process
        Specified by:
        run in interface CSProcess
      • netBarrier

        public static NetBarrier netBarrier​(String name,
                                            int localEnrolled,
                                            int netEnrolled)
                                     throws IllegalArgumentException,
                                            IllegalStateException
        Creates a new server end of a NetBarrier with the given name
        Parameters:
        name - The name to register with the BNS
        localEnrolled - The number of locally enrolled processes
        netEnrolled - The number of net enrolled processes to expect
        Returns:
        A new NetBarrier server end with the number of enrolled processes
        Throws:
        IllegalArgumentException - Thrown if the parameters are outside the defined ranges
        IllegalStateException - Thrown if the BNS connection has not been initialised
      • numberedNetBarrier

        public static NetBarrier numberedNetBarrier​(String name,
                                                    int index,
                                                    int localEnrolled,
                                                    int netEnrolled)
                                             throws IllegalArgumentException,
                                                    IllegalStateException
        Creates a new server end of a NetBarrier with a given index and name
        Parameters:
        name - Name to register with the BNS
        index - The index to create the NetBarrier with
        localEnrolled - The number of locally enrolled processes
        netEnrolled - The number of remote enrollments to wait for
        Returns:
        A new NetBarrier
        Throws:
        IllegalArgumentException - Thrown if the parameters are outside the defined ranges
        IllegalStateException - Thrown if the connection to the BNS has not been initialised