Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import org.cloudsimplus.hosts.Host;
import org.cloudsimplus.hosts.HostSimple;
import org.cloudsimplus.network.topologies.BriteNetworkTopology;
import org.cloudsimplus.resources.Pe;
import org.cloudsimplus.resources.PeSimple;
import org.cloudsimplus.resources.CoreCapacity;
import org.cloudsimplus.resources.SanStorage;
import org.cloudsimplus.schedulers.cloudlet.CloudletSchedulerTimeShared;
import org.cloudsimplus.utilizationmodels.UtilizationModelFull;
Expand All @@ -42,7 +41,7 @@
/// causing the Cloudlet to start executing just after a few seconds.
public class NetworkExample1 {
private static final String NETWORK_TOPOLOGY_FILE = "topology.brite";
private static final int VM_PES = 1;
private static final int VM_CORES = 1;
private final Datacenter datacenter0;
private final DatacenterBroker broker;

Expand Down Expand Up @@ -102,7 +101,7 @@ private void createAndSubmitCloudlets(DatacenterBroker broker) {
final var utilizationModel = new UtilizationModelFull();

final var cloudlet1 =
new CloudletSimple(length, VM_PES)
new CloudletSimple(length, VM_CORES)
.setFileSize(fileSize)
.setOutputSize(outputSize)
.setUtilizationModel(utilizationModel);
Expand All @@ -119,7 +118,7 @@ private void createAndSubmitVms(DatacenterBroker broker) {
final long size = 10000; //image size (Megabyte)
final int ram = 512; //vm memory (Megabyte)
final long bw = 1000; //in Megabits/s
final Vm vm1 = new VmSimple(mips, VM_PES)
final Vm vm1 = new VmSimple(new CoreCapacity(VM_CORES, mips))
.setRam(ram).setBw(bw).setSize(size)
.setCloudletScheduler(new CloudletSchedulerTimeShared());

Expand All @@ -129,16 +128,15 @@ private void createAndSubmitVms(DatacenterBroker broker) {

private Datacenter createDatacenter() {
final var hostList = new ArrayList<Host>();
final var peList = new ArrayList<Pe>();

final long mips = 1000;
peList.add(new PeSimple(mips));
final var cpuCapacity = new CoreCapacity(1, mips);

final long ram = 2048; // in Megabytes
final long storage = 1000000; // in Megabytes
final long bw = 10000; //in Megabits/s

final var host = new HostSimple(ram, bw, storage, peList);
final var host = new HostSimple(ram, bw, storage, cpuCapacity);
hostList.add(host);

return new DatacenterSimple(simulation, hostList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import org.cloudsimplus.hosts.Host;
import org.cloudsimplus.hosts.HostSimple;
import org.cloudsimplus.network.topologies.BriteNetworkTopology;
import org.cloudsimplus.resources.Pe;
import org.cloudsimplus.resources.PeSimple;
import org.cloudsimplus.resources.CoreCapacity;
import org.cloudsimplus.utilizationmodels.UtilizationModelFull;
import org.cloudsimplus.vms.Vm;
import org.cloudsimplus.vms.VmSimple;
Expand All @@ -32,7 +31,7 @@
/// It sets a network topology and then run 2 cloudlets.
public class NetworkExample2 {
private static final String NETWORK_TOPOLOGY_FILE = "topology.brite";
private static final int VM_PES = 1;
private static final int VM_CORES = 1;

private final List<Datacenter> datacenterList;
private final List<Cloudlet> cloudletList;
Expand Down Expand Up @@ -98,13 +97,13 @@ private void createAndSubmitCloudlets() {
final var utilizationModel = new UtilizationModelFull();

final var cloudlet1 =
new CloudletSimple(length, VM_PES)
new CloudletSimple(length, VM_CORES)
.setFileSize(fileSize)
.setOutputSize(outputSize)
.setUtilizationModel(utilizationModel);

final var cloudlet2 =
new CloudletSimple(length, VM_PES)
new CloudletSimple(length, VM_CORES)
.setFileSize(fileSize)
.setOutputSize(outputSize)
.setUtilizationModel(utilizationModel);
Expand All @@ -123,10 +122,10 @@ private void createAndSubmitVms() {
final int ram = 512; //vm memory (Megabyte)
final long bw = 1000;

final Vm vm1 = new VmSimple(mips, VM_PES)
final Vm vm1 = new VmSimple(new CoreCapacity(VM_CORES, mips))
.setRam(ram).setBw(bw).setSize(size);

final Vm vm2 = new VmSimple(mips, VM_PES)
final Vm vm2 = new VmSimple(new CoreCapacity(VM_CORES, mips))
.setRam(ram).setBw(bw).setSize(size);

vmlist.add(vm1);
Expand All @@ -137,16 +136,15 @@ private void createAndSubmitVms() {

private Datacenter createDatacenter() {
final var hostList = new ArrayList<Host>();
final var peList = new ArrayList<Pe>();

final long mips = 1000;
peList.add(new PeSimple(mips));
final var cpuCapacity = new CoreCapacity(1, mips);

final int ram = 2048; //host memory (Megabyte)
final long storage = 1000000; //host storage
final long bw = 10000;

final Host host = new HostSimple(ram, bw, storage, peList);
final Host host = new HostSimple(ram, bw, storage, cpuCapacity);
hostList.add(host);

return new DatacenterSimple(simulation, hostList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import org.cloudsimplus.hosts.Host;
import org.cloudsimplus.hosts.HostSimple;
import org.cloudsimplus.network.topologies.BriteNetworkTopology;
import org.cloudsimplus.resources.Pe;
import org.cloudsimplus.resources.PeSimple;
import org.cloudsimplus.resources.CoreCapacity;
import org.cloudsimplus.utilizationmodels.UtilizationModelFull;
import org.cloudsimplus.vms.Vm;
import org.cloudsimplus.vms.VmSimple;
Expand All @@ -31,7 +30,7 @@
/// A simple example showing how to create 2 datacenters with 1 host each and run
/// cloudlets of 2 users. It also sets a network topology.
public class NetworkExample3 {
private static final int VM_PES = 1;
private static final int VM_CORES = 1;

private final List<Datacenter> datacenterList;
private final List<DatacenterBroker> brokerList;
Expand Down Expand Up @@ -96,13 +95,13 @@ private void createAndSubmitCloudlets() {
final var utilizationModel = new UtilizationModelFull();

final var cloudlet1 =
new CloudletSimple(length, VM_PES)
new CloudletSimple(length, VM_CORES)
.setFileSize(fileSize)
.setOutputSize(outputSize)
.setUtilizationModel(utilizationModel);

final var cloudlet2 =
new CloudletSimple(length, VM_PES)
new CloudletSimple(length, VM_CORES)
.setFileSize(fileSize)
.setOutputSize(outputSize)
.setUtilizationModel(utilizationModel);
Expand All @@ -120,10 +119,10 @@ private void createAndSubmitVms() {
final int ram = 512; //vm memory (Megabyte)
final long bw = 1000;

final Vm vm1 = new VmSimple(mips, VM_PES)
final Vm vm1 = new VmSimple(new CoreCapacity(VM_CORES, mips))
.setRam(ram).setBw(bw).setSize(size);

final Vm vm2 = new VmSimple(mips, VM_PES)
final Vm vm2 = new VmSimple(new CoreCapacity(VM_CORES, mips))
.setRam(ram).setBw(bw).setSize(size);

vmList1.add(vm1);
Expand Down Expand Up @@ -159,16 +158,15 @@ private void createNetwork() {

private Datacenter createDatacenter() {
final var hostList = new ArrayList<Host>();
final var peList = new ArrayList<Pe>();

final long mips = 1000;
peList.add(new PeSimple(mips));
final var cpuCapacity = new CoreCapacity(1, mips);

final long ram = 2048; // in Megabytes
final long storage = 1000000; // in Megabytes
final long bw = 10000; //in Megabits/s

final Host host = new HostSimple(ram, bw, storage, peList);
final Host host = new HostSimple(ram, bw, storage, cpuCapacity);
hostList.add(host);

return new DatacenterSimple(simulation, hostList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import org.cloudsimplus.hosts.HostSimple;
import org.cloudsimplus.network.topologies.BriteNetworkTopology;
import org.cloudsimplus.provisioners.ResourceProvisionerSimple;
import org.cloudsimplus.resources.Pe;
import org.cloudsimplus.resources.PeSimple;
import org.cloudsimplus.resources.CoreCapacity;
import org.cloudsimplus.schedulers.vm.VmSchedulerTimeShared;
import org.cloudsimplus.utilizationmodels.UtilizationModelFull;
import org.cloudsimplus.vms.Vm;
Expand All @@ -41,7 +40,7 @@
/// If 3 messages are sent to the broker for starting a Cloudlet,
/// the total delay is the network latency multiplied by 3.
public class NetworkExample4 {
private static final int VM_PES = 1;
private static final int VM_CORES = 1;

/// In Megabits/s.
private static final double NETWORK_BW = 10.0;
Expand Down Expand Up @@ -98,7 +97,7 @@ private void createAndSubmitCloudlets() {
final var utilizationModel = new UtilizationModelFull();

final var cloudlet1 =
new CloudletSimple(length, VM_PES)
new CloudletSimple(length, VM_CORES)
.setFileSize(fileSize)
.setOutputSize(outputSize)
.setUtilizationModel(utilizationModel);
Expand All @@ -113,7 +112,7 @@ private void createAndSubmitVms() {
final int ram = 512; //vm memory (Megabyte)
final long bw = 1000;

final Vm vm1 = new VmSimple(mips, VM_PES)
final Vm vm1 = new VmSimple(new CoreCapacity(VM_CORES, mips))
.setRam(ram).setBw(bw).setSize(size);

vmList.add(vm1);
Expand All @@ -122,16 +121,15 @@ private void createAndSubmitVms() {

private Datacenter createDatacenter() {
final var hostList = new ArrayList<Host>();
final var peList = new ArrayList<Pe>();

final long mips = 1000;
peList.add(new PeSimple(mips));
final var cpuCapacity = new CoreCapacity(1, mips);

long ram = 2048; //host memory (Megabyte)
long storage = 1000000; //host storage (Megabyte)
long bw = 10000; //Megabits/s

final Host host = new HostSimple(ram, bw, storage, peList)
final Host host = new HostSimple(ram, bw, storage, cpuCapacity)
.setRamProvisioner(new ResourceProvisionerSimple())
.setBwProvisioner(new ResourceProvisionerSimple())
.setVmScheduler(new VmSchedulerTimeShared());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import org.cloudsimplus.network.switches.EdgeSwitch;
import org.cloudsimplus.network.switches.RootSwitch;
import org.cloudsimplus.provisioners.ResourceProvisionerSimple;
import org.cloudsimplus.resources.Pe;
import org.cloudsimplus.resources.PeSimple;
import org.cloudsimplus.resources.CoreCapacity;
import org.cloudsimplus.schedulers.cloudlet.CloudletSchedulerTimeShared;
import org.cloudsimplus.schedulers.vm.VmSchedulerTimeShared;
import org.cloudsimplus.vms.network.NetworkVm;
Expand Down Expand Up @@ -44,7 +43,15 @@ abstract class NetworkVmExampleAbstract {
public static final double COST_PER_BW = 0.0; // the cost of using bw in this resource

public static final int HOST_MIPS = 1000;
public static final int HOST_PES = 8;
public static final int HOST_CORES = 8;

/// The CPU capacity of every Host: a single [CoreCapacity] object is reused for all of them.
/// That's safe because a [CoreCapacity] is immutable: it never changes after it's created,
/// and each Host copies its values into its own Processor.
/// So, changing the capacity of one Host's Processor doesn't affect the other Hosts.
/// Reusing it avoids creating one temporary object per Host (fewer allocations and less GC work in large simulations).
private static final CoreCapacity HOST_CAPACITY = new CoreCapacity(HOST_CORES, HOST_MIPS);

public static final int HOST_RAM = 2048; // MEGA
public static final long HOST_STORAGE = 1000000; // MEGA
public static final long HOST_BW = 10000;
Expand All @@ -53,14 +60,21 @@ abstract class NetworkVmExampleAbstract {
public static final long VM_SIZE = 10000; // image size (Megabyte)
public static final int VM_RAM = 512; // MEGA
public static final long VM_BW = 1000;
public static final int VM_PES_NUMBER = HOST_PES / MAX_VMS_PER_HOST;
public static final int VM_PES_NUMBER = HOST_CORES / MAX_VMS_PER_HOST;

/// The CPU capacity of every VM: a single [CoreCapacity] object is reused for all of them.
/// That's safe because a [CoreCapacity] is immutable: it never changes after it's created,
/// and each VM copies its values into its own Processor.
/// So, changing the capacity of one VM (such as by vertical scaling) doesn't affect the other VMs.
/// Reusing it avoids creating one temporary object per VM (fewer allocations and less GC work in large simulations).
private static final CoreCapacity VM_CAPACITY = new CoreCapacity(VM_PES_NUMBER, VM_MIPS);

/// Number of fictitious applications to create.
/// Each application is just a list of [NetworkCloudlet].
/// @see #appMap
public static final int APPS_NUMBER = 1;

public static final int CLOUDLET_PES = VM_PES_NUMBER;
public static final int CLOUDLET_CORES = VM_PES_NUMBER;
public static final int TASK_LENGTH = 4000;
public static final int CLOUDLET_FILE_SIZE = 300;
public static final int CLOUDLET_OUTPUT_SIZE = 300;
Expand Down Expand Up @@ -154,8 +168,8 @@ protected final NetworkDatacenter createDatacenter() {
final int hostsNumber = EdgeSwitch.PORTS * AggregateSwitch.PORTS * RootSwitch.PORTS;
final var netHostList = new ArrayList<NetworkHost>(hostsNumber);
for (int i = 0; i < hostsNumber; i++) {
final List<Pe> peList = createPEs(HOST_PES, HOST_MIPS);
final var host = new NetworkHost(HOST_RAM, HOST_BW, HOST_STORAGE, peList);
final CoreCapacity cpuCapacity = HOST_CAPACITY;
final var host = new NetworkHost(HOST_RAM, HOST_BW, HOST_STORAGE, cpuCapacity);
host
.setRamProvisioner(new ResourceProvisionerSimple())
.setBwProvisioner(new ResourceProvisionerSimple())
Expand All @@ -175,15 +189,6 @@ protected final NetworkDatacenter createDatacenter() {
return dc;
}

protected List<Pe> createPEs(final int pesNumber, final long mips) {
final var peList = new ArrayList<Pe>();
for (int i = 0; i < pesNumber; i++) {
peList.add(new PeSimple(mips));
}

return peList;
}

/// Creates internal Datacenter network.
/// @param datacenter Datacenter where the network will be created
protected void createNetwork(final NetworkDatacenter datacenter) {
Expand Down Expand Up @@ -224,7 +229,7 @@ protected final List<NetworkVm> createAndSubmitVMs(DatacenterBroker broker) {
final int vmsNumber = getDatacenterHostList().size() * MAX_VMS_PER_HOST;
final var netVmList = new ArrayList<NetworkVm>();
for (int i = 0; i < vmsNumber; i++) {
final var vm = new NetworkVm(i, VM_MIPS, VM_PES_NUMBER);
final var vm = new NetworkVm(i, VM_CAPACITY);
vm.setRam(VM_RAM)
.setBw(VM_BW)
.setSize(VM_SIZE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public List<NetworkCloudlet> createNetworkCloudlets(DatacenterBroker broker){

for(int i = 0; i < CLOUDLETS_BY_APP; i++){
final var utilizationModel = new UtilizationModelFull();
final var cloudlet = new NetworkCloudlet(i, CLOUDLET_PES);
final var cloudlet = new NetworkCloudlet(i, CLOUDLET_CORES);
final NetworkVm vm = getVmList().get(i);
cloudlet
.setFileSize(CLOUDLET_FILE_SIZE)
Expand Down
Loading
Loading