public interface FakeLoadExecutor
FakeLoad objects.
This interface provides a way of decoupling FakeLoad submission from the mechanics of how a FakeLoad
is actually simulated.
Implementations of this interface should take care of scheduling and executing load instructions
contained in a FakeLoad as accurate as possible to provide a reliable simulation of system load.
A FakeLoadExecutor can be shut down, which will cause it to reject new submitted FakeLoads.
An unused FakeLoadExecutor should be shut down to allow reclamation of its resources.
Note: In a 'realistic' scenario multiple FakeLoads being executed simultaneously should
produce a system load which is an aggregation of all load instructions contained in the
FakeLoad objects. If thread A submits a FakeLoad of 20% CPU and thread B submits a
FakeLoad of 30% CPU the resulting system load should be ~ 50%. However, different scenarios
of how FakeLoads are executed are valid as well. Therefore it is at the discretion of the
FakeLoadExecutor implementation of how execution of FakeLoads is handled in
detail. To avoid confusion the exact behaviour should be clearly stated in the documentation
of the implementing class.
The FakeLoadExecutors class provides convenient factory methods for different executors
which should suffice for most simulation scenarios.
FakeLoad,
FakeLoadExecutors| Modifier and Type | Method and Description |
|---|---|
void |
execute(FakeLoad load)
Executes the specified fake load.
|
void execute(FakeLoad load)
This means the 'fake' system load instructions (CPU, memory, other FakeLoad objects, etc.)
contained withing the provided FakeLoad instance are simulated and executed by the executor.
For example after calling execute with a FakeLoad object specifying a CPU load of 80% and
a duration of 10 seconds, the executor will generate a CPU load of 80% for the next 10 seconds.
Note: This should be a blocking call, meaning within a single thread the method call blocks until
the execution of a fake load has finished. This is due to the fact that a fake load represents
a space holder for some real computation. A real computation would take all the time it needs
(and would therefore block) until it has finished, therefore the fake computation should do so as well.
However, different threads calling execute() should be able to do so at the same time.
load - the FakeLoad to be executedNullPointerException - if the load is nullRuntimeException - if the FakeLoad contains illegal loads or loads that
would exceed the limit of a specific system load (e.g. a CPU load of more than 100%)Copyright © 2017. All rights reserved.