peer2me.node
Class Node

java.lang.Object
  extended by peer2me.node.Node

public class Node
extends java.lang.Object

A simple class for storing information about a node, based on a NetworkNode. Contains also statistics regarding ping/eche detection

Author:
Tommy Bjoernsgaard

Constructor Summary
Node(NetworkNode networkNode)
          Intanciates a new Node based on a NetworkNode
 
Method Summary
 java.lang.String getAddress()
          Gets the address of the node
 int getEcho()
          Gets the number of pings the node has responded to; number of echoes.
 NetworkNode getNetworkNode()
          Gets the NetworkNode the node is based on.
 java.lang.String getNodename()
          Gets the name of the node
 int getPing()
          Gets the number of ping-messages sent by the node
 void incrementEcho()
          Increments the echo-counter by 1
 void incrementPing()
          Increments the ping-counter by 1
 boolean isNodeAbscent()
          Compares the number of pings sent and echoes received, comparing to see if the difference is larger than MAX_DIFF.
 java.lang.String toString()
          Returns the name of the node and its address
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

public Node(NetworkNode networkNode)
Intanciates a new Node based on a NetworkNode

Parameters:
networkNode - the object node is based on
Method Detail

getAddress

public java.lang.String getAddress()
Gets the address of the node

Returns:
the address of the node

getNodename

public java.lang.String getNodename()
Gets the name of the node

Returns:
the name of the node

getNetworkNode

public NetworkNode getNetworkNode()
Gets the NetworkNode the node is based on.

Returns:
the NetworkNode

toString

public java.lang.String toString()
Returns the name of the node and its address

Overrides:
toString in class java.lang.Object
Returns:
Nodename and address

getEcho

public int getEcho()
Gets the number of pings the node has responded to; number of echoes.

Returns:
the number of echoes

incrementEcho

public void incrementEcho()
Increments the echo-counter by 1


getPing

public int getPing()
Gets the number of ping-messages sent by the node

Returns:
the number of pings.

incrementPing

public void incrementPing()
Increments the ping-counter by 1


isNodeAbscent

public boolean isNodeAbscent()
Compares the number of pings sent and echoes received, comparing to see if the difference is larger than MAX_DIFF.

Returns:
true if the diff is to large and node is abscent, else false.