public interface FakeLoad extends Iterable<FakeLoad>, Serializable
FakeLoad, next to a FakeLoadExecutor, represents one of the two
main concepts of the FakeLoad Library. With instances of this type clients decide
what kinds of system loads they want to generate and for how long.
Clients can specify what kind of load (e.g. CPU, RAM, …), how much of it (e.g. 80%, 1024MB, …)
and for how long a specific load (e.g. 10 s, 100 ms, …) is being simulated.
Also, a fake load can itself consist of other FakeLoad instances thus
giving the client the possibility to create more elaborate patterns of system load instructions.
All setter methods of FakeLoad return a FakeLoad instance themselves, thus allowing a kind
of fluent interface like this:
FakeLoad fakeload = FakeLoads.create()
.lasting(10, TimeUnit.SECONDS)
.withCpu(30)
.withMemory(300, MemoryUnit.MB)
.withDiskInput(10, MemoryUnit.KB)
.withDiskOutput(20, MemoryUnit.MB);
Class FakeLoads offers factory methods for creating FakeLoad instances.
Class FakeLoadBuilder is an implementation of the builder pattern to create FakeLoad instances.
Note: FakeLoad objects created with classes FakeLoads and FakeLoadBuilder
are immutable. Thus, calling any of the setter methods will return newly constructed FakeLoad
instances, containing the load parameters of the "old" FakeLoad object, as well as the newly passed
load parameters. Therefore changing the load parameter of an existing FakeLoad object should
always be done like this:
// The original FakeLoad fakeload = FakeLoads.create().lasting(10, TimeUnit.SECONDS.withCpu(... // "Modifying" the original fakeload = fakeload.withCpu(50);
FakeLoadExecutor,
FakeLoads,
FakeLoadBuilder| Modifier and Type | Method and Description |
|---|---|
FakeLoad |
addLoad(FakeLoad load)
Adds the specified
FakeLoad object to this FakeLoad's inner loads. |
FakeLoad |
addLoads(Collection<FakeLoad> loads)
Adds the specified
FakeLoad objects to this FakeLoad's inner loads. |
boolean |
contains(FakeLoad load)
Determines whether the specified
FakeLoad object in contained within the FakeLoad
on which this method was called. |
int |
getCpu()
Returns the CPU load in percent
|
long |
getDiskInput()
Returns the disk input load in bytes per second
|
long |
getDiskOutput()
Returns the disk output load in bytes per second
|
long |
getDuration()
Returns the duration of this
FakeLoad system load configuration. |
Collection<FakeLoad> |
getInnerLoads()
Returns the inner
FakeLoad objects of this FakeLoad |
long |
getMemory()
Returns the memory load in bytes
|
int |
getRepetitions()
Returns the number of desired repetitions of this
FakeLoad object. |
TimeUnit |
getTimeUnit()
Returns the time unit of the duration specified by
getDuration(). |
Iterator<FakeLoad> |
iterator()
Returns an iterator of this
FakeLoad object. |
FakeLoad |
lasting(long duration,
TimeUnit unit)
Returns a
FakeLoad instance containing the specified duration. |
FakeLoad |
repeat(int noOfRepetitions)
Returns a
FakeLoad instance with the number of specified repetitions set. |
FakeLoad |
withCpu(int cpuLoad)
Returns a
FakeLoad instance with the specified CPU load. |
FakeLoad |
withDiskInput(long load,
MemoryUnit unit)
Returns a
FakeLoad instance with the specified disk input load as bytes/seconds. |
FakeLoad |
withDiskOutput(long load,
MemoryUnit unit)
Returns a
FakeLoad instance with the specified disk output load as bytes/seconds. |
FakeLoad |
withMemory(long amount,
MemoryUnit unit)
Returns a
FakeLoad instance with the specified memory load. |
forEach, spliteratorFakeLoad lasting(long duration, TimeUnit unit)
FakeLoad instance containing the specified duration.duration - the duration of the returned FakeLoadunit - the time unit of the durationFakeLoad repeat(int noOfRepetitions)
FakeLoad instance with the number of specified repetitions set.
The default value is 1. That means a FakeLoad is executed exactly as many
times as the number of repetitions, e.g. a FakeLoad with repetitions set to 3,
will be executed exactly three times.noOfRepetitions - number of repetitions of the returned FakeLoadFakeLoad withCpu(int cpuLoad)
FakeLoad instance with the specified CPU load.cpuLoad - the fake CPU load in percent (0-100%)FakeLoad withMemory(long amount, MemoryUnit unit)
FakeLoad instance with the specified memory load.amount - the amount of memory to be simulatedunit - the memory unit for the specified amountFakeLoad withDiskInput(long load, MemoryUnit unit)
FakeLoad instance with the specified disk input load as bytes/seconds.load - the amount of disk input to be simulatedunit - the memory unit for the specified amount per secondsFakeLoad withDiskOutput(long load, MemoryUnit unit)
FakeLoad instance with the specified disk output load as bytes/seconds.load - the amount of disk output to be simulatedunit - the memory unit for the specified amount per secondsFakeLoad addLoad(FakeLoad load)
FakeLoad object to this FakeLoad's inner loads.load - the FakeLoad to be added to the inner loadsFakeLoad including the newly added FakeLoadFakeLoad addLoads(Collection<FakeLoad> loads)
FakeLoad objects to this FakeLoad's inner loads.loads - the FakeLoad objects to be added to the inner loadsFakeLoad including the newly added FakeLoad objectsboolean contains(FakeLoad load)
FakeLoad object in contained within the FakeLoad
on which this method was called.load - the FakeLoad object to look forload is contained within this FakeLoadCollection<FakeLoad> getInnerLoads()
FakeLoad objects of this FakeLoadFakeLoad objectsint getCpu()
int containing the CPU load in percentlong getMemory()
long containing the memory load in byteslong getDiskInput()
long containing the disk input load in bytes per secondlong getDiskOutput()
long containing the disk output load in bytes per secondlong getDuration()
FakeLoad system load configuration.
The unit of the duration is determined by getTimeUnit().FakeLoad's load instructionsTimeUnit getTimeUnit()
getDuration().int getRepetitions()
FakeLoad object.
The number of repetitions decides how many times the FakeLoad object
will be repeated during executionIterator<FakeLoad> iterator()
FakeLoad object.
Generally, the iterator first returns the load information of the FakeLoad object on
which the method was called, and then the load information contained in its inner FakeLoad objects.
The iterator also takes the number of repetitions set by a FakeLoad into account.
If a simple FakeLoad has repetitions set to two, it will be returned twice by the iterator.
This applies also to any inner children FakeLoads.
Copyright © 2017. All rights reserved.