public abstract class Experiment extends Object implements Runnable
ExperimentRunner
.Modifier and Type | Field and Description |
---|---|
protected int |
hostsNumber |
Modifier | Constructor and Description |
---|---|
|
Experiment(int index,
ExperimentRunner runner)
Instantiates a simulation experiment with 1 Datacenter by default.
|
protected |
Experiment(int index,
ExperimentRunner runner,
long seed)
Instantiates a simulation experiment
that will create 1 broker and 1 Datacenter by default.
|
|
Experiment(long seed)
Creates a simulation experiment that is not linked to a runner,
to enable it to execute just one run.
|
Modifier and Type | Method and Description |
---|---|
protected void |
build()
Creates the simulation scenario to run the experiment.
|
protected void |
createAndSubmitCloudletsInternal(DatacenterBroker broker)
Creates all the Cloudlets required by the experiment and submits them to
a Broker.
|
protected abstract DatacenterBroker |
createBroker()
Creates a DatacenterBroker.
|
protected void |
createBrokers()
Creates a list of brokers.
|
protected abstract Cloudlet |
createCloudlet(DatacenterBroker broker) |
protected abstract List<Cloudlet> |
createCloudlets(DatacenterBroker broker)
Creates a list of Cloudlets to be used by the experiment.
|
protected DatacenterSimple |
createDatacenter()
Creates a datacenter using a
VmAllocationPolicy
suplied by the vmAllocationPolicySupplier . |
protected abstract Host |
createHost(int id) |
protected List<Host> |
createHosts() |
protected abstract Vm |
createVm(DatacenterBroker broker,
int id) |
protected List<Vm> |
createVms(DatacenterBroker broker)
Creates the Vms to be used by the experiment.
|
List<DatacenterBroker> |
getBrokerList()
Gets the list of created DatacenterBrokers.
|
int |
getBrokersNumber()
Gets the number of brokers to create.
|
List<Cloudlet> |
getCloudletList() |
List<DatacenterSimple> |
getDatacenterList() |
int |
getDatacentersNumber() |
int |
getIndex()
The index that identifies the current experiment run.
|
ExperimentRunner |
getRunner()
Gets the object that is in charge to run the experiment.
|
long |
getSeed() |
CloudSim |
getSimulation() |
List<Vm> |
getVmList() |
protected Function<DatacenterBroker,Integer> |
getVmsByBrokerFunction()
Gets a
Function that receives a DatacenterBroker and returns the
number of Vms to create for that broker. |
boolean |
isNotVerbose()
Indicates if simulation results of the experiment don't have to be
output.
|
boolean |
isVerbose()
Indicates if simulation results of the experiment have to be output.
|
protected int |
nextCloudletId() |
protected int |
nextVmId() |
void |
print(String msg)
Prints a message only if
isVerbose() . |
void |
print(String format,
Object... args)
Prints a formatted message only if
isVerbose() . |
void |
println()
Prints a line break only if
isVerbose() . |
void |
println(String msg)
Prints a message and a line break only if
isVerbose() . |
void |
println(String format,
Object... args)
Prints a formatted message and a line break only if
isVerbose() . |
abstract void |
printResults()
Prints the results for the experiment.
|
void |
run()
Builds the simulation scenario and starts execution.
|
<T extends Experiment> |
setAfterExperimentBuild(Consumer<T> afterExperimentBuild)
Sets a
Consumer that will be called after the simulation scenario is built,
which is before starting the simulation. |
<T extends Experiment> |
setAfterExperimentFinish(Consumer<T> afterExperimentFinishConsumer)
Sets a
Consumer object that will receive the experiment instance
after the experiment finishes executing and performs some post-processing
tasks. |
Experiment |
setBrokersNumber(int brokersNumber)
Sets the number of brokers to create.
|
void |
setDatacentersNumber(int datacentersNumber) |
protected void |
setHostsNumber(int hostsNumber) |
Experiment |
setVerbose(boolean verbose)
Defines if simulation results of the experiment have to be output or not.
|
void |
setVmAllocationPolicySupplier(Supplier<VmAllocationPolicy> vmAllocationPolicySupplier) |
void |
setVmsByBrokerFunction(Function<DatacenterBroker,Integer> vmsByBrokerFunction)
Sets a
Function that receives a DatacenterBroker and returns the
number of Vms to create for that broker. |
String |
toString() |
public Experiment(long seed)
public Experiment(int index, ExperimentRunner runner)
index
- the index that identifies the current experiment run.runner
- The ExperimentRunner
that is in charge of executing
this experiment a defined number of times and to collect data for
statistical analysis.setDatacentersNumber(int)
protected Experiment(int index, ExperimentRunner runner, long seed)
index
- the index that identifies the current experiment run.runner
- The ExperimentRunner
to execute the experiment.
If omitted, it means the experiment is independent and may be run just once.
If you don't provide a runner, you must provide a seedseed
- the seed to be set. If a runner is given, this value is ignored
and the seed is generated from the runner base seed.
If you don't provide a seed, you must provide a runner.setBrokersNumber(int)
,
setDatacentersNumber(int)
public Experiment setVerbose(boolean verbose)
verbose
- true if the results have to be output, false otherwisepublic int getIndex()
public boolean isNotVerbose()
public boolean isVerbose()
public final void run()
run
in interface Runnable
RuntimeException
public abstract void printResults()
printResultsInternal()
protected final void build()
protected DatacenterSimple createDatacenter()
VmAllocationPolicy
suplied by the vmAllocationPolicySupplier
.setVmAllocationPolicySupplier(Supplier)
protected void createBrokers()
protected abstract DatacenterBroker createBroker()
protected abstract List<Cloudlet> createCloudlets(DatacenterBroker broker)
broker
- the broker to create the Cloudlets toprotected abstract Cloudlet createCloudlet(DatacenterBroker broker)
protected List<Vm> createVms(DatacenterBroker broker)
broker
- protected abstract Vm createVm(DatacenterBroker broker, int id)
protected final int nextVmId()
protected final int nextCloudletId()
protected void createAndSubmitCloudletsInternal(DatacenterBroker broker)
broker
- broker to submit Cloudlets toprotected abstract Host createHost(int id)
public ExperimentRunner getRunner()
public List<DatacenterBroker> getBrokerList()
public <T extends Experiment> Experiment setAfterExperimentBuild(Consumer<T> afterExperimentBuild)
Consumer
that will be called after the simulation scenario is built,
which is before starting the simulation.
Setting a Consumer object is optional.
T
- the class of the experimentafterExperimentBuild
- the afterExperimentBuild to setpublic <T extends Experiment> Experiment setAfterExperimentFinish(Consumer<T> afterExperimentFinishConsumer)
Consumer
object that will receive the experiment instance
after the experiment finishes executing and performs some post-processing
tasks. These tasks are defined by the developer using the current class
and can include collecting data for statistical analysis.
Setting a Consumer object is optional.
T
- the class of the experimentafterExperimentFinishConsumer
- a Consumer
instance to set.public final CloudSim getSimulation()
public int getBrokersNumber()
public Experiment setBrokersNumber(int brokersNumber)
brokersNumber
- the value to setpublic List<DatacenterSimple> getDatacenterList()
public long getSeed()
public final void setVmsByBrokerFunction(Function<DatacenterBroker,Integer> vmsByBrokerFunction)
Function
that receives a DatacenterBroker
and returns the
number of Vms to create for that broker.
If you want all brokers to have the same amount of VMs,
you can give a lambda expression such as broker -> NUMER_OF_VMS_TO_CREATE
.vmsByBrokerFunction
- the Function
to setprotected Function<DatacenterBroker,Integer> getVmsByBrokerFunction()
Function
that receives a DatacenterBroker
and returns the
number of Vms to create for that broker.protected final void setHostsNumber(int hostsNumber)
public int getDatacentersNumber()
public void setDatacentersNumber(int datacentersNumber)
public void setVmAllocationPolicySupplier(Supplier<VmAllocationPolicy> vmAllocationPolicySupplier)
public void print(String msg)
isVerbose()
.msg
- the message to printpublic void print(String format, Object... args)
isVerbose()
.format
- the message formatargs
- the values to printpublic void println()
isVerbose()
.public void println(String msg)
isVerbose()
.msg
- the message to printpublic void println(String format, Object... args)
isVerbose()
.format
- the message formatargs
- the values to printCopyright © 2015–2019 Systems, Security and Image Communication Lab - Instituto de Telecomunica����es (IT) - Universidade da Beira Interior (UBI) - Instituto Federal de Educa����o Ci��ncia e Tecnologia do Tocantins (IFTO). All rights reserved.