Package com.martensigwart.fakeload
Interface LoadSimulator
- All Superinterfaces:
java.lang.Runnable
- All Known Implementing Classes:
AbstractLoadSimulator
,CpuSimulator
,DiskInputSimulator
,DiskOutputSimulator
,FibonacciCpuSimulator
,MemorySimulator
,RandomAccessDiskInputSimulator
,RandomAccessDiskOutputSimulator
public interface LoadSimulator
extends java.lang.Runnable
Represents a thread simulating some system load. System load can be CPU, memory, Disk I/O, ...
This type simulates some system load when started as a thread. Further, it defines methods for getting and setting as well as increasing and decreasing some load parameter. Implementing classes should use the load parameter, set by those methods, for their simulation logic.
Class AbstractLoadSimulator
provides a skeleton implementation of a LoadSimulator
.
Subclassing AbstractLoadSimulator
is the preferred way for clients to create new
LoadSimulator
classes, as it already provides common simulation behavior as well as
synchronization mechanisms.
- Since:
- 1.8
- See Also:
Runnable
,AbstractLoadSimulator
-
Method Summary
Modifier and Type Method Description void
decreaseLoad(long delta)
Decreases the load of the simulator bydelta
.long
getLoad()
long
getMaximumLoad()
void
increaseLoad(long delta)
Increases the load of the simulator bydelta
.boolean
isMaximumLoad()
boolean
isZeroLoad()
void
run()
Executes the simulation logic.void
setLoad(long desiredLoad)
Sets the load to be simulated.
-
Method Details
-
run
void run()Executes the simulation logic. This method should be used to implement the simulator's main simulation logic, i.e. the actual system load (CPU, memory, etc.) for which thisLoadSimulator
is responsible should be simulated.From
Runnable.run()
:- Specified by:
run
in interfacejava.lang.Runnable
-
getLoad
long getLoad()- Returns:
- returns the load to be simulated
-
setLoad
void setLoad(long desiredLoad)Sets the load to be simulated.- Parameters:
desiredLoad
- the load to be simulated
-
increaseLoad
void increaseLoad(long delta)Increases the load of the simulator bydelta
.- Parameters:
delta
- the amount by which the load will be increased
-
decreaseLoad
void decreaseLoad(long delta)Decreases the load of the simulator bydelta
.- Parameters:
delta
- the amount by which the load will be decreased
-
getMaximumLoad
long getMaximumLoad() -
isMaximumLoad
boolean isMaximumLoad() -
isZeroLoad
boolean isZeroLoad()
-