예제 #1
0
        /**
         * Creates a new client end of a NetBarrier connected to the barrier with the given index on the given Node
         *
         * @param addr
         *            NodeAddres of the Node that the barrier is located
         * @param vbn
         *            Index of the barrier to connect to
         * @param enrolled
         *            The number of locally enrolled processes
         * @return A new client end of a NetBarrier
         * @//throws JCSPNetworkException
         *             Thrown if something goes wrong in the underlying architecture
         * @//throws ArgumentException
         *             Thrown if the number of enrolled processes is outside the defined range.
         */
        public static NetBarrier netBarrier(NodeAddress addr, int vbn, int enrolled)
        {
            // Get the Link with the given address
            Link link = LinkFactory.getLink(addr);

            NetBarrier barrierToReturn = null;

            try
            {
                barrierToReturn = NetBarrier.create(new NetBarrierLocation(link.remoteID, vbn), enrolled);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e);
            }
            catch (JCSPNetworkException e)
            {
                Console.WriteLine(e);
            }

            return(barrierToReturn);


            // Create a new NetBarrier
            //return NetBarrier.create(new NetBarrierLocation(link.remoteID, vbn), enrolled);
        }
예제 #2
0
        /**
         * Creates a new server end of a NetBarrier with a given index
         *
         * @param index
         *            The index to create the NetBarrier with
         * @param localEnrolled
         *            The number of locally enrolled processes
         * @param netEnrolled
         *            The number of remote enrollments to wait for
         * @return A new NetBarrier
         * @//throws ArgumentException
         *             Thrown if the parameters are outside the defined ranges
         */
        public static NetBarrier numberedNetBarrier(int index, int localEnrolled, int netEnrolled)
        {
            NetBarrier barrierToReturn = null;

            try
            {
                barrierToReturn = NetBarrier.create(localEnrolled, netEnrolled, index);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e);
            }

            return(barrierToReturn);
        }
예제 #3
0
        /**
         * Creates a new client end of a NetBarrier
         *
         * @param loc
         *            The location of the server end of the NetBarrier
         * @param enrolled
         *            The number of locally enrolled processes
         * @return A new NetBarrier client end with the number of enrolled processes
         * @//throws JCSPNetworkException
         *             Thrown if something goes wrong in the underlying architecture
         * @//throws ArgumentException
         *             Thrown if the number of of local enrolled is outside the defined range
         */
        public static NetBarrier netBarrier(NetBarrierLocation loc, int enrolled)
        {
            NetBarrier barrierToReturn = null;

            try
            {
                barrierToReturn = NetBarrier.create(loc, enrolled);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e);
            }
            catch (JCSPNetworkException e)
            {
                Console.WriteLine(e);
            }

            return(barrierToReturn);
        }
예제 #4
0
        /**
         * Creates a new client end of a NetBarrier connected to the barrier with the given index on the given Node
         *
         * @param nodeID
         *            The NodeID of the Node to connect to
         * @param vbn
         *            The index of the barrier on the remote Node
         * @param enrolled
         *            The number of locally enrolled processes
         * @return A new client end of a NetBarrier
         * @//throws JCSPNetworkException
         *             Thrown is something goes wrong in the underlying architecture
         * @//throws ArgumentException
         *             Thrown if the number of enrolled is outside the defined range
         */
        public static NetBarrier netBarrier(NodeID nodeID, int vbn, int enrolled)
        {
            NetBarrier barrierToReturn = null;

            try
            {
                barrierToReturn = NetBarrier.create(new NetBarrierLocation(nodeID, vbn), enrolled);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e);
            }
            catch (JCSPNetworkException e)
            {
                Console.WriteLine(e);
            }

            return(barrierToReturn);

            // return NetBarrier.create(new NetBarrierLocation(nodeID, vbn), enrolled);
        }