Unverified Commit 7b51aa74 authored by Manoel Campos's avatar Manoel Campos
Browse files

Closes #124



- Enable physical expansion of a Datacenter by
  adding new Hosts (PMs) before or after simulation start.
- Introduce the Datacenter.addHost() and addHostList methods to enable creating new Hosts
  before or after starting the simulation.
- Introduce the DynamicHostCreation example to demonstrate
  the dynamic creation of Hosts.
- Refactor DatacenterCharacteristicsSimple class
- Stop requiring the creation of a DatacenterCharacteristics
  object to pass to a Datacenter constructor.
  Now a DatacenterCharacteristics object is created
  internally in the DatacenterSimple class.
- Change the signature of Datacenter classes to
  accept a Host List instead of a DatacenterCharacteristics
  object.
- Remove deprecated Datacenter constructors.
- Update all examples to use the new Datacenter constructors.
Signed-off-by: default avatarManoel Campos <manoelcampos@gmail.com>
parent 695dae63
......@@ -80,6 +80,7 @@ CloudSim Plus provides a lot of exclusive features, ranging from the most basic
- definition of the time when an idle VM should be destroyed ([#99](https://github.com/manoelcampos/cloudsim-plus/issues/99));
- sorting of requests to create submitted VMs and Cloudlets, defining priorities to create such objects ([#102](https://github.com/manoelcampos/cloudsim-plus/issues/102)).
1. [Host Fault Injection Mechanism](/cloudsim-plus-examples/src/main/java/org/cloudsimplus/examples/HostFaultInjectionExample1.java) to enable injection of random failures into Hosts PEs: it injects failures into Host PEs and reallocates working PEs to running VMs. When all PEs from a Host fail, it starts clones of failed VMs to recovery from failure. This way, it is simulated the instantiation of VM snapshots into different Hosts ([#81](https://github.com/manoelcampos/cloudsim-plus/issues/81)).
1. [Creation of Hosts at Simulation Runtime](/cloudsim-plus-examples/src/main/java/org/cloudsimplus/examples/dynamic/DynamicHostCreation.java) to enable physical expansion of Datacenter capacity ([#124](https://github.com/manoelcampos/cloudsim-plus/issues/124)).
# Project's Structure
......@@ -194,9 +195,7 @@ host0.setRamProvisioner(new ResourceProvisionerSimple())
hostList.add(host0);
//Creates a Datacenter with a list of Hosts.
DatacenterCharacteristics characts = new DatacenterCharacteristicsSimple(hostList);
VmAllocationPolicy vmAllocationPolicy = new VmAllocationPolicySimple();
Datacenter dc0 = new DatacenterSimple(cloudsim, characts, vmAllocationPolicy);
Datacenter dc0 = new DatacenterSimple(cloudsim, hostList, new VmAllocationPolicySimple());
//Creates VMs to run applications.
List<Vm> vmList = new ArrayList<>(1);
......@@ -309,15 +308,13 @@ Cloudlet cloudlet = new CloudletSimple(required, parameters, here);
The method `setBrokerId(int userId)` from `Vm` and `Cloudlet` were refactored to `setBroker(DatacenterBroker broker)`,
now requiring a `DatacenterBroker` instead of just an int ID which may be even nonexistent.
A `DatacenterCharacteristics` now requires just the list of hosts. All the other parameters (such as costs) are optional.
A `VmAllocationPolicy` doesn't require any parameter anymore. A `Datacenter` doesn't require a name, storage list and scheduling interval too.
You don't need to explicitly create a `DatacenterCharacteristics` anymore. Such object is created internally when a `Datacenter` is created.
A `VmAllocationPolicy` doesn't require any parameter at all. A `Datacenter` doesn't require a name, storage list and scheduling interval too.
The name will be automatically defined. It and all the other parameter can be set further using the respective setter methods.
Now it is just required a `CloudSim`, a `DatacenterCharacteristics` and a `VmAllocationPolicy` instance.
Now it is just required a `CloudSim`, a `Host` list and a `VmAllocationPolicy` instance.
```java
DatacenterCharacteristics characts = new DatacenterCharacteristicsSimple(hostList);
VmAllocationPolicy vmAllocationPolicy = new VmAllocationPolicySimple();
Datacenter datacenter0 = new DatacenterSimple(cloudsim, characts, vmAllocationPolicy);
Datacenter dc0 = new DatacenterSimple(cloudsim, hostList, new VmAllocationPolicySimple());
```
The way you instantiate a host has changed too. The classes `RamProvisionerSimple` and `BwProvisionerSimple` don't exist anymore. Now you just have the generic class `ResourceProvisionerSimple` and you can just use its default no-args constructor. RAM and bandwidth capacity of the host now are given in the constructor, as it already was for storage. A `VmScheduler` constructor doesn't require any parameter. You don't need to set an ID for each Host, since
......
......@@ -4,7 +4,7 @@
<groupId>org.cloudsimplus</groupId>
<artifactId>cloudsim-plus-benchmarks</artifactId>
<version>1.2.7</version>
<version>1.3.0</version>
<name>CloudSim Plus Benchmarks</name>
<description>A module containing benchmarks created using JMH (Java Microbenchmark Harness framework) to assess CloudSim Plus performance</description>
<url>http://cloudsimplus.org</url>
......
......@@ -4,7 +4,7 @@
<groupId>org.cloudsimplus</groupId>
<artifactId>cloudsim-plus-examples</artifactId>
<version>1.2.7</version>
<version>1.3.0</version>
<name>CloudSim Plus Examples</name>
<description>
Ready-to-run examples of how to use CloudSim Plus API.
......
......@@ -102,8 +102,7 @@ public class CloudSimExample0 {
hostList.add(host);
}
DatacenterCharacteristics characteristics = new DatacenterCharacteristicsSimple(hostList);
return new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
return new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
}
private Host createHost() {
......
......@@ -162,24 +162,9 @@ public class CloudSimExample1 {
hostList.add(host);
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this Datacenter
double costPerBw = 0.0; // the cost of using bw in this resource
DatacenterCharacteristics characteristics =
new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(cost)
.setCostPerMem(costPerMem)
.setCostPerStorage(costPerStorage)
.setCostPerBw(costPerBw);
// 6. Finally, we need to create a DatacenterSimple object.
return new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
return new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
}
}
......@@ -172,26 +172,11 @@ public class CloudSimExample2 {
hostList.add(host);
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this resource
double costPerBw = 0.0; // the cost of using bw in this resource
DatacenterCharacteristics characteristics =
new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(cost)
.setCostPerMem(costPerMem)
.setCostPerStorage(costPerStorage)
.setCostPerBw(costPerBw);
// 6. Finally, we need to create a DatacenterSimple object.
DatacenterSimple datacenter = new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
datacenter.setSchedulingInterval(1);
return datacenter;
DatacenterSimple dc = new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
dc.setSchedulingInterval(1);
return dc;
}
}
......@@ -181,24 +181,9 @@ public class CloudSimExample3 {
.setVmScheduler(new VmSchedulerTimeShared());
hostList.add(host1);
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this resource
double costPerBw = 0.0; // the cost of using bw in this resource
DatacenterCharacteristics characteristics =
new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(cost)
.setCostPerMem(costPerMem)
.setCostPerStorage(costPerStorage)
.setCostPerBw(costPerBw);
// 6. Finally, we need to create a DatacenterSimple object.
return new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
return new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
}
}
......@@ -171,24 +171,15 @@ public class CloudSimExample4 {
.setVmScheduler(new VmSchedulerSpaceShared());
hostList.add(host);
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this resource
double costPerBw = 0.0; // the cost of using bw in this resource
DatacenterCharacteristics characteristics =
new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(cost)
.setCostPerMem(costPerMem)
.setCostPerStorage(costPerStorage)
.setCostPerBw(costPerBw);
// 6. Finally, we need to create a DatacenterSimple object.
return new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
DatacenterSimple dc = new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
dc.getCharacteristics()
.setCostPerSecond(3.0)
.setCostPerMem(0.05)
.setCostPerStorage(0.1)
.setCostPerBw(0.1);
return dc;
}
}
......@@ -176,24 +176,15 @@ public class CloudSimExample5 {
.setVmScheduler(new VmSchedulerSpaceShared());
hostList.add(host);
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this resource
double costPerBw = 0.0; // the cost of using bw in this resource
DatacenterCharacteristics characteristics =
new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(cost)
.setCostPerMem(costPerMem)
.setCostPerStorage(costPerStorage)
.setCostPerBw(costPerBw);
// 6. Finally, we need to create a DatacenterSimple object.
return new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
DatacenterSimple dc = new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
dc.getCharacteristics()
.setCostPerSecond(3.0)
.setCostPerMem(0.05)
.setCostPerStorage(0.1)
.setCostPerBw(0.1);
return dc;
}
}
......@@ -176,24 +176,15 @@ public class CloudSimExample6 {
hostList.add(host2);
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.1; // the cost of using storage in this resource
double costPerBw = 0.1; // the cost of using bw in this resource
DatacenterCharacteristics characteristics =
new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(cost)
.setCostPerMem(costPerMem)
.setCostPerStorage(costPerStorage)
.setCostPerBw(costPerBw);
// 6. Finally, we need to create a DatacenterSimple object.
return new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
DatacenterSimple dc = new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
dc.getCharacteristics()
.setCostPerSecond(3.0)
.setCostPerMem(0.05)
.setCostPerStorage(0.1)
.setCostPerBw(0.1);
return dc;
}
}
......@@ -166,24 +166,8 @@ public class NetworkExample1 {
.setVmScheduler(new VmSchedulerTimeShared());
hostList.add(host);
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this resource
double costPerBw = 0.0; // the cost of using bw in this resource
DatacenterCharacteristics characteristics =
new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(cost)
.setCostPerMem(costPerMem)
.setCostPerStorage(costPerStorage)
.setCostPerBw(costPerBw);
// 6. Finally, we need to create a DatacenterSimple object.
return new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
return new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
}
//We strongly encourage users to develop their own broker policies, to submit vms and cloudlets according
......
......@@ -189,24 +189,8 @@ public class NetworkExample2 {
.setVmScheduler(new VmSchedulerTimeShared());
hostList.add(host);
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this resource
double costPerBw = 0.0; // the cost of using bw in this resource
DatacenterCharacteristics characteristics =
new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(cost)
.setCostPerMem(costPerMem)
.setCostPerStorage(costPerStorage)
.setCostPerBw(costPerBw);
// 6. Finally, we need to create a DatacenterSimple object.
return new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
return new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
}
//We strongly encourage users to develop their own broker policies, to submit vms and cloudlets according
......
......@@ -202,24 +202,8 @@ public class NetworkExample3 {
.setVmScheduler(new VmSchedulerSpaceShared());
hostList.add(host);
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this resource
double costPerBw = 0.0; // the cost of using bw in this resource
DatacenterCharacteristics characteristics =
new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(cost)
.setCostPerMem(costPerMem)
.setCostPerStorage(costPerStorage)
.setCostPerBw(costPerBw);
// 6. Finally, we need to create a DatacenterSimple object.
return new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
return new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
}
//We strongly encourage users to develop their own broker policies, to submit vms and cloudlets according
......
......@@ -157,25 +157,16 @@ public class NetworkExample4 {
.setBwProvisioner(new ResourceProvisionerSimple())
.setVmScheduler(new VmSchedulerTimeShared());
hostList.add(host);
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this resource
double costPerBw = 0.0; // the cost of using bw in this resource
DatacenterCharacteristics characteristics =
new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(cost)
.setCostPerMem(costPerMem)
.setCostPerStorage(costPerStorage)
.setCostPerBw(costPerBw);
// 6. Finally, we need to create a DatacenterSimple object.
return new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
DatacenterSimple dc = new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
dc.getCharacteristics()
.setCostPerSecond(3.0)
.setCostPerMem(0.05)
.setCostPerStorage(0.1)
.setCostPerBw(0.1);
return dc;
}
//We strongly encourage users to develop their own broker policies, to submit vms and cloudlets according
......
......@@ -167,24 +167,19 @@ abstract class NetworkVmExampleAbstract {
hostList.add(host);
}
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
DatacenterCharacteristics characteristics =
new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(COST)
.setCostPerMem(COST_PER_MEM)
.setCostPerStorage(COST_PER_STORAGE)
.setCostPerBw(COST_PER_BW);
// 6. Finally, we need to create a NetworkDatacenter object.
NetworkDatacenter newDatacenter =
NetworkDatacenter dc =
new NetworkDatacenter(
simulation, characteristics, new VmAllocationPolicySimple());
newDatacenter.setSchedulingInterval(5);
createNetwork(newDatacenter);
return newDatacenter;
simulation, hostList, new VmAllocationPolicySimple());
dc.setSchedulingInterval(5);
dc.getCharacteristics()
.setCostPerSecond(COST)
.setCostPerMem(COST_PER_MEM)
.setCostPerStorage(COST_PER_STORAGE)
.setCostPerBw(COST_PER_BW);
createNetwork(dc);
return dc;
}
public List<Pe> createPEs(final int numberOfPEs, final long mips) {
......@@ -240,7 +235,7 @@ abstract class NetworkVmExampleAbstract {
}
private List<Host> getDatacenterHostList() {
return datacenter.getCharacteristics().getHostList();
return datacenter.getHostList();
}
/**
......
......@@ -38,12 +38,6 @@ import org.cloudbus.cloudsim.utilizationmodels.UtilizationModelFull;
* @author Manoel Campos da Silva Filho
*/
public class NetworkVmsExample1 {
private static final double COST = 3.0; // the cost of using processing in this resource
private static final double COST_PER_MEM = 0.05; // the cost of using memory in this resource
private static final double COST_PER_STORAGE = 0.001; // the cost of using storage in this resource
private static final double COST_PER_BW = 0.0; // the cost of using bw in this resource
private static final int NUMBER_OF_HOSTS = 2;
private static final int HOST_MIPS = 1000;
private static final int HOST_PES = 4;
......@@ -118,15 +112,8 @@ public class NetworkVmsExample1 {
hostList.add(host);
}
DatacenterCharacteristics characteristics
= new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(COST)
.setCostPerMem(COST_PER_MEM)
.setCostPerStorage(COST_PER_STORAGE)
.setCostPerBw(COST_PER_BW);
NetworkDatacenter newDatacenter
= new NetworkDatacenter(simulation, characteristics, new VmAllocationPolicySimple());
= new NetworkDatacenter(simulation, hostList, new VmAllocationPolicySimple());
newDatacenter.setSchedulingInterval(5);
createNetwork(newDatacenter);
......
......@@ -165,24 +165,20 @@ public final class Helper {
Class<? extends Datacenter> datacenterClass,
List<PowerHost> hostList,
VmAllocationPolicy vmAllocationPolicy) throws Exception {
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this resource
double costPerBw = 0.0; // the cost of using bw in this resource
DatacenterCharacteristics characteristics =
new DatacenterCharacteristicsSimple(hostList)
.setCostPerSecond(cost)
.setCostPerMem(costPerMem)
.setCostPerStorage(costPerStorage)
.setCostPerBw(costPerBw);
Constructor<? extends Datacenter> construct = datacenterClass.getConstructor(CloudSim.class,
DatacenterCharacteristics.class,
VmAllocationPolicy.class);
Datacenter datacenter = construct.newInstance(simulation, characteristics, vmAllocationPolicy);
return datacenter.setSchedulingInterval(Constants.SCHEDULING_INTERVAL);
Constructor<? extends Datacenter> construct =
datacenterClass.getConstructor(
CloudSim.class,
List.class,
VmAllocationPolicy.class);
Datacenter dc = construct.newInstance(simulation, hostList, vmAllocationPolicy);
dc.getCharacteristics()
.setCostPerSecond(3.0)
.setCostPerMem(0.05)
.setCostPerStorage(0.001)
.setCostPerBw(0.0);
return dc.setSchedulingInterval(Constants.SCHEDULING_INTERVAL);
}
/**
......
......@@ -56,7 +56,7 @@ import java.util.List;
* A minimal but organized, structured and re-usable CloudSim Plus example
* which shows good coding practices for creating simulation scenarios.
*
* <p>It defines a set of constants that enable a developer
* <p>It defines a set of constants that enables a developer
* to change the number of Hosts, VMs and Cloudlets to create
* and the number of {@link Pe}s for Hosts, VMs and Cloudlets.</p>
*
......@@ -112,8 +112,7 @@ public class BasicFirstExample {
hostList.add(host);
}
DatacenterCharacteristics characteristics = new DatacenterCharacteristicsSimple(hostList);
final Datacenter dc = new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
final Datacenter dc = new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
return dc;
}
......
......@@ -144,8 +144,7 @@ public class CloudletCancellationExample {
hostList.add(host);
}
DatacenterCharacteristics characteristics = new DatacenterCharacteristicsSimple(hostList);
final Datacenter dc = new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
final Datacenter dc = new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
dc.setSchedulingInterval(SCHEDULING_INTERVAL);
return dc;
}
......
......@@ -114,8 +114,7 @@ public class CloudletSchedulerSpaceSharedExample1 {
hostList.add(host);
}
DatacenterCharacteristics characteristics = new DatacenterCharacteristicsSimple(hostList);
final Datacenter dc = new DatacenterSimple(simulation, characteristics, new VmAllocationPolicySimple());
final Datacenter dc = new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
return dc;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment