Fairness.Nodes.NodeBehaviors
Interface NodeBehavior

All Known Implementing Classes:
AncestorRatingBehavior, DebtMaintenanceBehavior, RefuseForwardBehavior, SimpleNodeBehavior

public interface NodeBehavior

NodeBehavior class provides an interface for the different node behaviors such as allowing to forward and receive packets and also contains information about the debts and confidence of nodes. It allows implementation of a freeloader or a freeloader behavior for different behavior types such AncestorRatingBehavior and DebtMaintenanceBehavior


Method Summary
 boolean allowChild(Node myNode, Node candidateChild)
          Asks the node behavior if the given Node is allowed to be a child of the Node this behavior is for.
 boolean allowForward(Node myNode, Node target)
          Returns true if this node behavior is currently allowing the Node to send to the given target.
 java.lang.Double getConfidence(Node n)
          Returns this behavior's confidence of the given Node, or null if there is no opinion.
 java.lang.Double getDebtLevel(Node n)
          Returns this behavior's debt level measurement of the given Node, or null if there is no opinion.
 boolean hasConfidenceInformation()
          Returns true if this behavior has confidence information on any Node
 boolean hasDebtLevelInformation()
          Returns true if this behavior has debt levels for any Node
 void receivedPacket(Node myNode, NodePacket packet)
          Event to the node behavior for when a packet is received by the Node.
 void sentPacket(Node myNode, Node destination, NodePacket packet)
          Event called when a Node sends a packet to a child.
 void setParameter(java.lang.String param)
          Allows setting of a single behavior-specific parameter.
 

Method Detail

setParameter

void setParameter(java.lang.String param)
Allows setting of a single behavior-specific parameter.

Parameters:
param - non-null String

allowChild

boolean allowChild(Node myNode,
                   Node candidateChild)
Asks the node behavior if the given Node is allowed to be a child of the Node this behavior is for.

Parameters:
myNode - non-null Node to which this behavior belongs.
candidateChild - non-null Node that is not equal to myNode.
Returns:
true if the child can be added, or false otherwise.

allowForward

boolean allowForward(Node myNode,
                     Node target)
Returns true if this node behavior is currently allowing the Node to send to the given target.

Parameters:
myNode - non-null Node to which this behavior belongs.
target - non-null Node that is not equal to myNode.

receivedPacket

void receivedPacket(Node myNode,
                    NodePacket packet)
Event to the node behavior for when a packet is received by the Node.

Parameters:
myNode - non-null Node to which this behavior belongs.
packet - non-null NodePacket destined for this behavior's Node.

sentPacket

void sentPacket(Node myNode,
                Node destination,
                NodePacket packet)
Event called when a Node sends a packet to a child.

Parameters:
myNode - non-null Node to which this behavior belongs.
destination - non-null Node where the packet is going.
packet - non-null NodePacket destined for this behavior's Node.

hasConfidenceInformation

boolean hasConfidenceInformation()
Returns true if this behavior has confidence information on any Node


hasDebtLevelInformation

boolean hasDebtLevelInformation()
Returns true if this behavior has debt levels for any Node


getConfidence

java.lang.Double getConfidence(Node n)
Returns this behavior's confidence of the given Node, or null if there is no opinion.

Parameters:
n - non-null Node to get information about
Returns:
nullable Double

getDebtLevel

java.lang.Double getDebtLevel(Node n)
Returns this behavior's debt level measurement of the given Node, or null if there is no opinion.

Parameters:
n - non-null Node to get information about
Returns:
nullable Double