|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.planx.xmlstore.routing.Node
public class Node
Represents a node and contains information about the IP address, UDP port, and ID of the node.
| Nested Class Summary | |
|---|---|
static class |
Node.DistanceComparator
A DistanceComparator is capable of comparing Node objects according to closeness to a predetermined identifier using the XOR metric. |
static class |
Node.FirstSeenComparator
A FirstSeenComparator is capable of comparing Node objects according to time first seen. |
static class |
Node.LastSeenComparator
A LastSeenComparator is capable of comparing Node objects according to time last seen. |
| Field Summary | |
|---|---|
static Comparator |
FIRSTSEEN_COMPARATOR
|
static Comparator |
LASTSEEN_COMPARATOR
|
| Constructor Summary | |
|---|---|
Node(DataInput in)
Constructs a node by reading the state from a DataInput. |
|
Node(InetAddress ip,
int port,
Identifier id)
Constructs a node with the specified IP address, UDP port, and identifier. |
|
Node(InetAddress ip,
int port,
int contactPort,
Identifier id)
|
|
| Method Summary | |
|---|---|
boolean |
equals(Object o)
Returns true if o is a Node
and has the same identifier as this. |
long |
firstSeen()
Returns the time this node was first seen. |
void |
fromStream(DataInput in)
Reads the internal state of the Streamable object from the input stream. |
int |
getContactPort()
Returns the contact port associated with this node. |
Identifier |
getId()
Returns the identifier of this node. |
InetAddress |
getInetAddress()
Returns the IP address of this node. |
int |
getPort()
Returns the UDP port of this node. |
int |
hashCode()
|
int |
incFailCount()
Increments the failure counter and returns the new value. |
long |
lastSeen()
Returns the time this node was last seen. |
void |
seenNow()
Update time last seen for this node and reset fail count. |
void |
setContactPort(int contactPort)
Sets the contact port associated with this node. |
static Node[] |
sort(Collection nodes,
Identifier rel)
Sorts the nodes in the specified list in order of increasing distance to the specified identifier. |
void |
toStream(DataOutput out)
Writes the internal state of the Streamable object to the output stream in a format that can later be read by the same Streamble class using the Streamable.fromStream(java.io.DataInput) method. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Comparator LASTSEEN_COMPARATOR
public static final Comparator FIRSTSEEN_COMPARATOR
| Constructor Detail |
|---|
public Node(InetAddress ip,
int port,
Identifier id)
public Node(InetAddress ip,
int port,
int contactPort,
Identifier id)
public Node(DataInput in)
throws IOException
IOException| Method Detail |
|---|
public void fromStream(DataInput in)
throws IOException
StreamableUnsupportedOperationException,
and instead implement a constructor as described above.
fromStream in interface StreamableIOException
public void toStream(DataOutput out)
throws IOException
StreamableStreamable.fromStream(java.io.DataInput) method.
toStream in interface StreamableIOExceptionpublic void seenNow()
public long firstSeen()
public long lastSeen()
public InetAddress getInetAddress()
public int getPort()
public Identifier getId()
public int getContactPort()
public void setContactPort(int contactPort)
public int incFailCount()
public boolean equals(Object o)
true if o is a Node
and has the same identifier as this. Note that IP address and port
are ignored in this comparison.
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Object
public static Node[] sort(Collection nodes,
Identifier rel)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||