Fairness.Nodes.NodeBehaviors
Class AncestorRatingBehavior

java.lang.Object
  extended by Fairness.Nodes.NodeBehaviors.AncestorRatingBehavior
All Implemented Interfaces:
NodeBehavior

public class AncestorRatingBehavior
extends java.lang.Object
implements NodeBehavior

AncestorRatingBehavior keeps track of confidence values and increases/decreases the confidence levels of nodes for sending and receiving the packets respectively. When a packet is received, the child increases the confidence of all the nodes in the path to the root and similarly decreases if the packet is denied.


Constructor Summary
AncestorRatingBehavior()
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AncestorRatingBehavior

public AncestorRatingBehavior()
Method Detail

setParameter

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

Specified by:
setParameter in interface NodeBehavior
Parameters:
param - non-null String

allowChild

public 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.

Specified by:
allowChild in interface NodeBehavior
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

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

Specified by:
allowForward in interface NodeBehavior
Parameters:
myNode - non-null Node to which this behavior belongs.
target - non-null Node that is not equal to myNode.

receivedPacket

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

Specified by:
receivedPacket in interface NodeBehavior
Parameters:
myNode - non-null Node to which this behavior belongs.
packet - non-null NodePacket destined for this behavior's Node.

sentPacket

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

Specified by:
sentPacket in interface NodeBehavior
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

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

Specified by:
hasConfidenceInformation in interface NodeBehavior

hasDebtLevelInformation

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

Specified by:
hasDebtLevelInformation in interface NodeBehavior

getConfidence

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

Specified by:
getConfidence in interface NodeBehavior
Parameters:
n - non-null Node to get information about
Returns:
nullable Double

getDebtLevel

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

Specified by:
getDebtLevel in interface NodeBehavior
Parameters:
n - non-null Node to get information about
Returns:
nullable Double