example.loadbalance
Class BasicBalance
java.lang.Object
peersim.vector.SingleValueHolder
example.loadbalance.BasicBalance
- All Implemented Interfaces:
- java.lang.Cloneable, CDProtocol, Protocol, SingleValue
- Direct Known Subclasses:
- AvgBalance
public class BasicBalance
- extends SingleValueHolder
- implements CDProtocol
This class implements a (simple) load balancing strategy: each node selects
its most "distant" neighbor in terms of load difference and exchanges with it
an amount of load not exceeding the PAR_QUOTA
parameter.
The class subclasses SingleValueHolder
in order to be
type compatible with its observers and initializers object companions.
Parameter Summary |
quota
Initial quota. |
Field Summary |
protected double |
quota
|
Constructor Summary |
BasicBalance(java.lang.String prefix)
Standard constructor that reads the configuration parameters. |
Method Summary |
protected void |
doTransfer(BasicBalance neighbor)
Performs the actual load exchange selecting to make a PUSH or PULL
approach. |
void |
nextCycle(Node node,
int protocolID)
Using an underlying Linkable protocol choses a neighbor and
performs a variance reduction step. |
protected void |
resetQuota()
Resets the current node quota value. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
quota
- Initial quota. Defaults to 1.
quota
protected double quota
BasicBalance
public BasicBalance(java.lang.String prefix)
- Standard constructor that reads the configuration parameters. Invoked by
the simulation engine.
- Parameters:
prefix
- the configuration prefix for this class.
resetQuota
protected void resetQuota()
- Resets the current node quota value.
nextCycle
public void nextCycle(Node node,
int protocolID)
- Using an underlying
Linkable
protocol choses a neighbor and
performs a variance reduction step.
- Specified by:
nextCycle
in interface CDProtocol
- Parameters:
node
- the node on which this component is run.protocolID
- the id of this protocol in the protocol array.
doTransfer
protected void doTransfer(BasicBalance neighbor)
- Performs the actual load exchange selecting to make a PUSH or PULL
approach. It affects the involved nodes quota.
- Parameters:
neighbor
- the selected node to talk with. It is assumed that it is an
instance of the BasicBalance
class.