public final class DefaultFakeLoadExecutor extends Object implements FakeLoadExecutor
FakeLoadExecutor implementation.
The DefaultFakeLoadExecutor executes a submitted FakeLoad by passing it
to the FakeLoadScheduler.schedule(FakeLoad) method which schedules each FakeLoad
for execution. Method schedule(FakeLoad) returns a Future which is done when
the execution of the submitted FakeLoad object has completed. By calling Future.get()
the execute(FakeLoad) method blocks until either execution has finished or an exception was thrown.
This blocking behavior conforms to the general contract as imposed by FakeLoadExecutor.execute(FakeLoad).
Multiple FakeLoad objects being executed simultaneously produce a system load which is the aggregation of all
load instructions contained in the 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%.
FakeLoadExecutor,
FakeLoadScheduler,
FakeLoad| Constructor and Description |
|---|
DefaultFakeLoadExecutor(FakeLoadScheduler scheduler)
Creates a new
DefaultFakeLoadExecutor instance. |
public DefaultFakeLoadExecutor(FakeLoadScheduler scheduler)
DefaultFakeLoadExecutor instance.scheduler - the scheduler to be used by the newly created executorpublic void execute(FakeLoad load)
FakeLoadExecutor
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.
execute in interface FakeLoadExecutorload - the FakeLoad to be executedCopyright © 2017. All rights reserved.