Esempio n. 1
0
        /**
         * Converts a string representation of a NodeID back to a NodeID object
         *
         * @param str
         *            The string version of a NodeID
         * @return A new NodeID created from the String representation
         */
        public static NodeID parse(String str)
        {
            // Split the string into its separate parts

            /*        String[] pieces = new String[5];
             *      int index = 0;
             *      int last = 0;
             *      for (int i = 0; i < 5; i++)
             *      {
             *          index = str.IndexOf("-", index + 1);
             *          if (index == -1)
             *              index = str.Length;
             *          pieces[i] = str.Substring(last, index);
             *          last = index + 1;
             *      }*/
            String[] pieces = str.Split("-");


            // Get the relevant parts
            long   time     = Int64.Parse(pieces[0]);
            long   mem      = Int64.Parse(pieces[1]);
            int    hashCode = Int32.Parse(pieces[2]);
            String name     = pieces[3];
            // Parse the address
            NodeAddress addr = NodeAddress.parse(pieces[4]);

            // Return the NodeID
            return(new NodeID(time, mem, hashCode, name, addr));
        }
Esempio n. 2
0
 /**
  * Constructor taking the full details for a remote Node connection
  *
  * @param long1
  *            The time component of the remote Node
  * @param long2
  *            The memory component of the remote Node
  * @param int1
  *            The hashCode component of the remote Node
  * @param nodeName
  *            The name component of the remote Node
  * @param nodeAddress
  *            The NodeAddress component of the remote Node
  */
 public NodeID(long long1, long long2, int int1, String nodeName, NodeAddress nodeAddress)
 {
     this.time     = long1;
     this.mem      = long2;
     this.hashCode = int1;
     this.name     = nodeName;
     this.address  = nodeAddress;
 }
Esempio n. 3
0
 /**
  * Constructor taking the name and the address of the Node
  *
  * @param nodeName
  *            Symbolic name of the Node
  * @param nodeAddress
  *            Symbolic address of the Node
  */
 internal NodeID(String nodeName, NodeAddress nodeAddress)
 {
     this.time = CSTimer.CurrentTimeMillis();
     //this.mem = System.Runtime.GetRuntime().freeMemory();
     //this.mem = GC.GetTotalMemory(true);
     this.mem = Process.GetCurrentProcess().PrivateMemorySize64;
     //this.hashCode = new Object().hashCode();
     this.hashCode = new Object().GetHashCode();
     this.name     = nodeName;
     this.address  = nodeAddress;
 }
Esempio n. 4
0
 /**
  * @param name
  * @param addr
  * @return NodeKey for this Node
  * @//throws JCSPNetworkException
  */
 public NodeKey init(String name, NodeAddress addr)
 ////throws JCSPNetworkException
 {
     Node.log.log(this.GetType(), "Node initialisation begun");
     if (this.initialized)
     {
         throw new JCSPNetworkException("Node already initialised");
     }
     this.initialized = true;
     LinkServer.start(addr);
     this.nodeID = new NodeID(name, addr);
     this.nk     = new NodeKey();
     NodeAddress.installProtocol(addr.getProtocol(), addr.getProtocolID());
     Node.log.log(this.GetType(), "Node initialisation complete");
     return(this.nk);
 }
Esempio n. 5
0
        /**
         * @param factory
         * @return NodeKey for this Node
         * @//throws JCSPNetworkException
         */
        public NodeKey init(NodeFactory factory)
        ////throws JCSPNetworkException
        {
            Node.log.log(this.GetType(), "Node initialisation begun");
            if (this.initialized)
            {
                throw new JCSPNetworkException("Node already initialised");
            }
            NodeAddress localAddr = factory.initNode(this);

            this.nodeID      = new NodeID("", localAddr);
            this.initialized = true;
            this.nk          = new NodeKey();
            Link toServer = LinkFactory.getLink(factory.cnsAddress);

            CNS.CNS.initialise(toServer.remoteID);
            BNS.BNS.initialise(toServer.remoteID);
            return(this.nk);
        }
Esempio n. 6
0
 /**
  * @param addr
  * @return NodeKey for this Node
  * @//throws JCSPNetworkException
  */
 public NodeKey init(NodeAddress addr)
 ////throws JCSPNetworkException
 {
     return(this.init("", addr));
 }