Class NodeID
java.lang.Object
org.jcsp.net2.NodeID
- All Implemented Interfaces:
Serializable, Comparable
This class is used to uniquely identify a Node within the entire JCSP network of Nodes in operation. This is to allow
ease to identify individual Nodes when IDs come in, and to quickly find them within tables of other Links to allow
usage of existing connections. This is different to a NodeAddress, which is a symbolic name representing a Node, and
which therefore may be repeated. The hope here is that by using enough pieces of data the Node should have a unique
identification. This is done by gathering the information on the current system time in milliseconds, the current
free memory of the JVM, the hash code of a newly created object, the name of the Node, if there is one, and the
address of the Node itself. Having this much information should provide us with a unique ID. Other implementations of
the protocol can use other means of identifying a Node uniquely, but they must use the same amount of data, e.g.
string(number 64 bits) - string(number 64 bits) - string (number 32 bits) - string - address string, when
communicating with another JCSP Node for the sake of compatibility.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final NodeAddressAddress of the Nodeprivate final intHash code of a objectprivate final longCurrent amount of free memory to the JVMprivate final StringName of the Nodeprivate static final longThe SUID of this classprivate final longCurrent time in milliseconds -
Constructor Summary
ConstructorsConstructorDescriptionNodeID(long long1, long long2, int int1, String nodeName, NodeAddress nodeAddress) Constructor taking the full details for a remote Node connectionNodeID(String nodeName, NodeAddress nodeAddress) Constructor taking the name and the address of the Node -
Method Summary
Modifier and TypeMethodDescriptionintCompares this NodeID with another NodeID.booleanChecks if the given object is equal to this NodeIDGets the NodeAddress part of the NodeIDinthashCode()Returns the hashCode for this objectstatic NodeIDConverts a string representation of a NodeID back to a NodeID objecttoString()Converts the NodeID into a string for communication with other implementations, or for display purposes.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDThe SUID of this class- See Also:
-
time
private final long timeCurrent time in milliseconds -
mem
private final long memCurrent amount of free memory to the JVM -
hashCode
private final int hashCodeHash code of a object -
name
Name of the Node -
address
Address of the Node
-
-
Constructor Details
-
NodeID
NodeID(String nodeName, NodeAddress nodeAddress) Constructor taking the name and the address of the Node- Parameters:
nodeName- Symbolic name of the NodenodeAddress- Symbolic address of the Node
-
NodeID
Constructor taking the full details for a remote Node connection- Parameters:
long1- The time component of the remote Nodelong2- The memory component of the remote Nodeint1- The hashCode component of the remote NodenodeName- The name component of the remote NodenodeAddress- The NodeAddress component of the remote Node
-
-
Method Details
-
compareTo
Compares this NodeID with another NodeID.- Specified by:
compareToin interfaceComparable- Parameters:
arg0-- Returns:
- -1, 0 or 1 if less than, equal, or greater than the other NodeID
-
equals
-
hashCode
-
toString
-
getNodeAddress
Gets the NodeAddress part of the NodeID- Returns:
- The NodeAddress part of the NodeID
-
parse
-