|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectFairness.Nodes.Node
public class Node
The Node class is the center of the program design. It contains all of the information for its participation in the trees, for which there is one tree per stripe. A Node is typically in multiple trees at the same time, depending on its amount of inbound bandwidth. The NodeBehavior class is utilized to implement a freeloader or a freeloader detector of our two different types (ancestor rating or debt maintenance). When packets are received there is a report made to the NodeMonitor.
Constructor Summary | |
---|---|
Node(Simulation sim,
int nodeId,
int outboundBW,
int inboundBW,
NodeMonitor monitor,
NodeBehavior nodeBehavior,
TreeBehavior treeBehavior)
Constructs a new Node. |
Method Summary | |
---|---|
boolean |
allowChild(Node candidateChild)
Returns whether a Node is willing to accept a given child. |
int |
getAvailableOutboundBW(SimulationParameters params)
Returns the amount of available outbound bandwidth. |
int |
getInboundBW()
|
int |
getNodeId()
|
int |
getOutboundBW()
|
Node |
getParent(int stripeId)
Returns this Node's parent for a given stripe ID. |
java.util.List<Node> |
getPathToRoot(int stripeId)
Returns a List of all Nodes to and including the root Node for a given stripe tree. |
int |
getStripeId()
Gets the stripe ID of the primary stripe for this Node. |
java.util.Set<java.lang.Integer> |
getStripes()
Returns a Set of all stripe IDs this Node is currently in. |
TreeInfo |
getTreeInfo(int stripeId)
Returns the tree information for this Node's participation in the given stripe. |
TreeInfo |
makeTreeInfo(int stripeId)
Creates if needed, and returns the tree information for this Node's participation in the given stripe. |
void |
processPacket(Simulation sim,
NodePacket packet)
Processes a NodePacket that is being received by this Node during a Simulation. |
boolean |
receivesStripe(int stripeId)
Returns true if Node currently receives specified stripe. |
void |
resetNetwork()
Resets all network information for this Node by clearing its tree information for all stripes. |
void |
setLossRate(double lossRate)
Sets the percentage of packets received or sent that are lost due to network errors. |
void |
setStripeId(int stripeId)
Sets the stripe ID to be the primary stripe for this Node. |
java.lang.String |
toString()
Returns a string representation of this node: "Node [node ID in hex]" |
boolean |
wantsJoin()
Returns true if this Node wants to join another stripe. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Node(Simulation sim, int nodeId, int outboundBW, int inboundBW, NodeMonitor monitor, NodeBehavior nodeBehavior, TreeBehavior treeBehavior)
setLossRate(double)
method.
sim
- non-null Simulation this Node will be part ofnodeId
- Node ID as assigned from the TreeManageroutboundBW
- outbound bandwidthinboundBW
- inbound bandwidthmonitor
- non-null NodeMonitornodeBehavior
- non-null NodeBehaviortreeBehavior
- non-null TreeBehaviorMethod Detail |
---|
public void setLossRate(double lossRate)
lossRate
- a percentage (0 to 1) of packet loss.public void processPacket(Simulation sim, NodePacket packet)
sim
- non-null Simulationpacket
- non-null NodePacketpublic TreeInfo getTreeInfo(int stripeId)
stripeId
- stripe to get information about.
public TreeInfo makeTreeInfo(int stripeId)
stripeId
- stripe to get information about
public void resetNetwork()
public int getNodeId()
public int getInboundBW()
public int getOutboundBW()
public int getStripeId()
public boolean receivesStripe(int stripeId)
stripeId
- stripe ID to query about
public Node getParent(int stripeId)
stripeId
- stripe ID to query about
java.lang.IllegalArgumentException
- if this Node is not in the stripe treepublic java.util.List<Node> getPathToRoot(int stripeId)
stripeId
- stripe ID to query about
java.lang.IllegalArgumentException
- if this Node is not in the stripe treepublic boolean allowChild(Node candidateChild)
candidateChild
- non-null Node
public void setStripeId(int stripeId)
public java.lang.String toString()
toString
in class java.lang.Object
public int getAvailableOutboundBW(SimulationParameters params)
params
- non-null SimulationParameters (to get stripe size)
public java.util.Set<java.lang.Integer> getStripes()
public boolean wantsJoin()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |