Package org.jcsp.net

Class NodeID

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

    public final class NodeID
    extends AbstractID
    implements java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

    A Class whose instances represent a unique identifier for a JCSP.NET Node.

    For an explanation of this class, see AbstractID.

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private NodeAddressID[] addressIDs
      This is a set of addresses of LinkServers that the Node, represented by this NodeID, is running.
      private DomainID domainID
      The Domain of which the Node represented by this NodeID is a member.
      private java.lang.String name
      A name assigned to this Node.
      private NodeUI nodeUI
      A unique identifier for this node.
      private java.util.HashSet unrecognisedAddressIDs
      This is the set of addresses of LinkServers that the Node, represented by this NodeID, is running but this JVM does not recognise.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      (package private) void addAddress​(NodeAddressID addressID)  
      java.lang.Object clone()
      Returns a clone of the instance of NodeID on which this method is being called.
      int compareTo​(java.lang.Object o)
      Compares this NodeID object with another NodeID object.
      int compareToLocalNode()
      This method is equivalent to calling the compareTo(Object) and supplying the local Node's NodeID as a parameter.
      (package private) static NodeID createFromStringForm​(java.lang.String stringForm)
      Deprecated.
      Not needed now channel names have been abstracted
      boolean equals​(java.lang.Object o)
      Compares this NodeID with another object.
      NodeAddressID[] getAddresses()
      Returns a clone of the set of NodeAddressID objects that this NodeID holds.
      DomainID getDomainID()
      Get the DomainID of the domain to which the Node represented by this NodeID object belongs.
      java.lang.String getName()
      Returns a name that has been assigned to the Node represented by this NodeID object.
      AbstractID getParentID()
      Returns this instance's parent AbstractID object.
      (package private) java.lang.String getStringForm()
      Deprecated.
      Not needed now channel names have been abstracted
      int hashCode()
      Returns a hash code for this NodeID object.
      (package private) boolean onSameBranch​(AbstractID abstractID)
      This tests whether another ID is on the same branch of a hierachy.
      private void readObject​(java.io.ObjectInputStream in)  
      (package private) void removeAddress​(NodeAddressID addressID)  
      (package private) void setDomainID​(DomainID domainID)  
      (package private) void setName​(java.lang.String name)  
      java.lang.String toString()
      Returns a human readable String that represents this NodeID object.
      private void writeObject​(java.io.ObjectOutputStream out)  
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • addressIDs

        private NodeAddressID[] addressIDs
        This is a set of addresses of LinkServers that the Node, represented by this NodeID, is running.
      • unrecognisedAddressIDs

        private java.util.HashSet unrecognisedAddressIDs
        This is the set of addresses of LinkServers that the Node, represented by this NodeID, is running but this JVM does not recognise. The serialized forms of the addresses are stored here so that
      • domainID

        private DomainID domainID
        The Domain of which the Node represented by this NodeID is a member.
      • nodeUI

        private NodeUI nodeUI
        A unique identifier for this node.
      • name

        private java.lang.String name
        A name assigned to this Node.
    • Constructor Detail

      • NodeID

        NodeID​(NodeUI nodeUI)
      • NodeID

        private NodeID​(java.lang.String stringRep)
                throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
    • Method Detail

      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException

        Returns a clone of the instance of NodeID on which this method is being called.

        Overrides:
        clone in class java.lang.Object
        Returns:
        a clone of the current instance of NodeID.
        Throws:
        java.lang.CloneNotSupportedException - if the NodeID cannot be cloned.
      • equals

        public boolean equals​(java.lang.Object o)

        Compares this NodeID with another object. This will only return true if the other object is a NodeID representing the same Node as this NodeID. The comparison is performed by using a Node's unique identifier. This was introduced for efficiency reasons as comparing two NodeID objects' sets of addresses could be quite slow.

        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - another object to compare with this NodeID.
        Returns:
        true iff the other object is a NodeID representing the same Node as this NodeID.
      • hashCode

        public int hashCode()

        Returns a hash code for this NodeID object.

        Overrides:
        hashCode in class java.lang.Object
        Returns:
        an int hash code.
      • compareTo

        public int compareTo​(java.lang.Object o)
                      throws java.lang.ClassCastException

        Compares this NodeID object with another NodeID object. Returns 0 if this NodeID is equal to the other NodeID, a negative int if this NodeID is less than the supplied NodeID or a positive int if this NodeID is greater than the supplied NodeID.

        This comparison is based upon the implementation of NodeUI used.

        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        o - An object to compare with this NodeID.
        Returns:
        0 if this NodeID is equal to the other NodeID, a negative int if this NodeID is less than the supplied NodeID or a positive int if this NodeID is greater than the supplied NodeID.
        Throws:
        java.lang.ClassCastException - if the parameter supplied is not a NodeID.
      • compareToLocalNode

        public int compareToLocalNode()

        This method is equivalent to calling the compareTo(Object) and supplying the local Node's NodeID as a parameter.

        Returns:
        an int following the rules of the compareTo(Object) method.
      • onSameBranch

        boolean onSameBranch​(AbstractID abstractID)
        Description copied from class: AbstractID
        This tests whether another ID is on the same branch of a hierachy. Returns true if either the supplied object is a child (or a child of child etc.) of this object or if the supplied object is a parent (or a parent of a parent etc.) of this object.
        Specified by:
        onSameBranch in class AbstractID
        Returns:
        a boolean indicating whether or not the supplied object is on the same branch.
      • getAddresses

        public NodeAddressID[] getAddresses()

        Returns a clone of the set of NodeAddressID objects that this NodeID holds.

        If any held NodeAddressID objects do not support cloning, then the actual object is returned but this should never be the case.

        Returns:
        an array of NodeAddressID objects.
      • createFromStringForm

        static NodeID createFromStringForm​(java.lang.String stringForm)
                                    throws java.lang.IllegalArgumentException
        Deprecated.
        Not needed now channel names have been abstracted
        Throws:
        java.lang.IllegalArgumentException
      • getStringForm

        java.lang.String getStringForm()
        Deprecated.
        Not needed now channel names have been abstracted
        This gets a String form of this NodeID. This is only intended to be called for NodeID's representing the current JVM as any NodeAddressIDs in serialized form in the unrecognisedAddressIDs HashSet will not be saved. This HashSet should be empty for NodeID's representing the current JVM.
        Returns:
        the String form that can be used to reconstruct this NodeID.
      • setDomainID

        void setDomainID​(DomainID domainID)
      • getParentID

        public AbstractID getParentID()
        Description copied from class: AbstractID
        Returns this instance's parent AbstractID object.
        Specified by:
        getParentID in class AbstractID
        Returns:
        the parent AbstractID of this object.
      • getDomainID

        public DomainID getDomainID()
        Get the DomainID of the domain to which the Node represented by this NodeID object belongs. If the Node is not a member of a domain then a DomainID object will be returned that will return true when its isNullDomain() method is called.
        Returns:
        this NodeID object's DomainID object.
      • getName

        public java.lang.String getName()
        Returns a name that has been assigned to the Node represented by this NodeID object. If no name has been assigned, then an empty String is returned. The Node naming feature is not currently implemented.
        Returns:
        the name assigned to this NodeID object's Node.
      • toString

        public java.lang.String toString()
        Returns a human readable String that represents this NodeID object. This will either include the name of the Node, if assigned, or else a list of the Node's addresses. The String returned by this method is only really intended as a way of supply debugging information to users. The contents is not guaranteed and should not relied upon by a program.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a human readable String.
      • setName

        void setName​(java.lang.String name)
      • readObject

        private void readObject​(java.io.ObjectInputStream in)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeObject

        private void writeObject​(java.io.ObjectOutputStream out)
                          throws java.io.IOException
        Throws:
        java.io.IOException