public abstract class AbstractLoadSimulator extends Object implements LoadSimulator
LoadSimulator implementation.
Load is simulated by running a while loop inside the run() method.
In the loop the executing thread waits when there is nothing to do as indicated by
waitConditionFulfilled() method.
When there is something to simulate, load gets simulated via the simulateLoad(long)
method which has to be implemented by subclasses.
Note: When calling the constructor of this class from a subclass,
passing a value smaller or equal zero as maximumLoad will cause the
max value to be Long.MAX_VALUE
| Constructor and Description |
|---|
AbstractLoadSimulator(long maximumLoad,
String name) |
| Modifier and Type | Method and Description |
|---|---|
void |
decreaseLoad(long delta)
Decreases the load of the simulator by
delta. |
long |
getLoad() |
long |
getMaximumLoad() |
void |
increaseLoad(long delta)
Increases the load of the simulator by
delta. |
boolean |
isMaximumLoad() |
boolean |
isZeroLoad() |
void |
run()
Executes the simulation logic.
|
void |
setLoad(long desiredLoad)
Sets the load to be simulated.
|
public AbstractLoadSimulator(long maximumLoad,
String name)
public void run()
LoadSimulatorLoadSimulator
is responsible should be simulated.
From Runnable.run():
run in interface LoadSimulatorrun in interface Runnablepublic long getLoad()
getLoad in interface LoadSimulatorpublic void setLoad(long desiredLoad)
LoadSimulatorsetLoad in interface LoadSimulatordesiredLoad - the load to be simulatedpublic void increaseLoad(long delta)
LoadSimulatordelta.increaseLoad in interface LoadSimulatordelta - the amount by which the load will be increasedpublic void decreaseLoad(long delta)
LoadSimulatordelta.decreaseLoad in interface LoadSimulatordelta - the amount by which the load will be decreasedpublic long getMaximumLoad()
getMaximumLoad in interface LoadSimulatorpublic boolean isMaximumLoad()
isMaximumLoad in interface LoadSimulatorpublic boolean isZeroLoad()
isZeroLoad in interface LoadSimulatorCopyright © 2017. All rights reserved.