From d96ba2bc043cf8800e9e1f03e9d0c17c9913eafd Mon Sep 17 00:00:00 2001 From: Manoel Campos Date: Tue, 20 Oct 2026 07:46:24 -0300 Subject: [PATCH 1/2] Add missing license header to CloudSim Plus source files Co-Authored-By: Claude Opus 5.5 --- .../examples/autoscaling/package-info.java | 23 +++++++++++++++++++ .../examples/brokers/package-info.java | 23 +++++++++++++++++++ .../examples/dynamic/package-info.java | 23 +++++++++++++++++++ .../examples/listeners/package-info.java | 23 +++++++++++++++++++ .../examples/migration/package-info.java | 23 +++++++++++++++++++ .../examples/resourceusage/package-info.java | 23 +++++++++++++++++++ .../examples/schedulers/package-info.java | 23 +++++++++++++++++++ .../simulationstatus/package-info.java | 23 +++++++++++++++++++ .../examples/synchronous/package-info.java | 23 +++++++++++++++++++ .../examples/traces/package-info.java | 23 +++++++++++++++++++ 10 files changed, 230 insertions(+) diff --git a/src/main/java/org/cloudsimplus/examples/autoscaling/package-info.java b/src/main/java/org/cloudsimplus/examples/autoscaling/package-info.java index f7804f1..1453667 100755 --- a/src/main/java/org/cloudsimplus/examples/autoscaling/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/autoscaling/package-info.java @@ -1,3 +1,26 @@ +/* + * CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for + * Modeling and Simulation of Cloud Computing Infrastructures and Services. + * http://cloudsimplus.org + * + * Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and + * the Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil). + * + * This file is part of CloudSim Plus. + * + * CloudSim Plus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CloudSim Plus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CloudSim Plus. If not, see . + */ /** * Examples showing how to enable horizontal and vertical * VM scaling using the {@link org.cloudsimplus.autoscaling.HorizontalVmScaling} diff --git a/src/main/java/org/cloudsimplus/examples/brokers/package-info.java b/src/main/java/org/cloudsimplus/examples/brokers/package-info.java index f0a0c9b..91c29a3 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/package-info.java @@ -1,3 +1,26 @@ +/* + * CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for + * Modeling and Simulation of Cloud Computing Infrastructures and Services. + * http://cloudsimplus.org + * + * Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and + * the Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil). + * + * This file is part of CloudSim Plus. + * + * CloudSim Plus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CloudSim Plus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CloudSim Plus. If not, see . + */ /** * Examples showing how to use the full-featured CloudSim Plus * {@link org.cloudsimplus.brokers.DatacenterBroker} implementations. diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/package-info.java b/src/main/java/org/cloudsimplus/examples/dynamic/package-info.java index 18ea74d..bd27435 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/package-info.java @@ -1,3 +1,26 @@ +/* + * CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for + * Modeling and Simulation of Cloud Computing Infrastructures and Services. + * http://cloudsimplus.org + * + * Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and + * the Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil). + * + * This file is part of CloudSim Plus. + * + * CloudSim Plus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CloudSim Plus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CloudSim Plus. If not, see . + */ /** * Examples showing how to implement dynamic behaviour for your simulations, * such as the dynamic array of Cloudlet and VMs, and the creation diff --git a/src/main/java/org/cloudsimplus/examples/listeners/package-info.java b/src/main/java/org/cloudsimplus/examples/listeners/package-info.java index 4a827a3..807b65b 100755 --- a/src/main/java/org/cloudsimplus/examples/listeners/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/listeners/package-info.java @@ -1,3 +1,26 @@ +/* + * CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for + * Modeling and Simulation of Cloud Computing Infrastructures and Services. + * http://cloudsimplus.org + * + * Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and + * the Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil). + * + * This file is part of CloudSim Plus. + * + * CloudSim Plus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CloudSim Plus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CloudSim Plus. If not, see . + */ /** * Examples showing how to use the CloudSim Plus {@link org.cloudsimplus.listeners.EventListener} * features to track simulation events and perform some actions in response. diff --git a/src/main/java/org/cloudsimplus/examples/migration/package-info.java b/src/main/java/org/cloudsimplus/examples/migration/package-info.java index 8fdefde..a48ede5 100755 --- a/src/main/java/org/cloudsimplus/examples/migration/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/migration/package-info.java @@ -1,3 +1,26 @@ +/* + * CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for + * Modeling and Simulation of Cloud Computing Infrastructures and Services. + * http://cloudsimplus.org + * + * Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and + * the Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil). + * + * This file is part of CloudSim Plus. + * + * CloudSim Plus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CloudSim Plus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CloudSim Plus. If not, see . + */ /** * Examples showing how to enable VM migration * using a {@link org.cloudsimplus.allocationpolicies.migration.VmAllocationPolicyMigration}. diff --git a/src/main/java/org/cloudsimplus/examples/resourceusage/package-info.java b/src/main/java/org/cloudsimplus/examples/resourceusage/package-info.java index a46e81a..98e068b 100755 --- a/src/main/java/org/cloudsimplus/examples/resourceusage/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/resourceusage/package-info.java @@ -1,3 +1,26 @@ +/* + * CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for + * Modeling and Simulation of Cloud Computing Infrastructures and Services. + * http://cloudsimplus.org + * + * Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and + * the Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil). + * + * This file is part of CloudSim Plus. + * + * CloudSim Plus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CloudSim Plus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CloudSim Plus. If not, see . + */ /** * Examples showing how to track resource usage for different elements * such as Cloudlets, VMs and Hosts. diff --git a/src/main/java/org/cloudsimplus/examples/schedulers/package-info.java b/src/main/java/org/cloudsimplus/examples/schedulers/package-info.java index d7ff36d..bd7d0dc 100755 --- a/src/main/java/org/cloudsimplus/examples/schedulers/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/schedulers/package-info.java @@ -1,3 +1,26 @@ +/* + * CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for + * Modeling and Simulation of Cloud Computing Infrastructures and Services. + * http://cloudsimplus.org + * + * Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and + * the Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil). + * + * This file is part of CloudSim Plus. + * + * CloudSim Plus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CloudSim Plus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CloudSim Plus. If not, see . + */ /** * Examples showing how to use {@link org.cloudsimplus.schedulers.cloudlet.CloudletScheduler} * and {@link org.cloudsimplus.schedulers.vm.VmScheduler} in different infrastructure setups. diff --git a/src/main/java/org/cloudsimplus/examples/simulationstatus/package-info.java b/src/main/java/org/cloudsimplus/examples/simulationstatus/package-info.java index 1052255..5ecaad8 100755 --- a/src/main/java/org/cloudsimplus/examples/simulationstatus/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/simulationstatus/package-info.java @@ -1,3 +1,26 @@ +/* + * CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for + * Modeling and Simulation of Cloud Computing Infrastructures and Services. + * http://cloudsimplus.org + * + * Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and + * the Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil). + * + * This file is part of CloudSim Plus. + * + * CloudSim Plus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CloudSim Plus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CloudSim Plus. If not, see . + */ /** * Examples showing how to control simulation execution by * pausing, resuming and stopping it. diff --git a/src/main/java/org/cloudsimplus/examples/synchronous/package-info.java b/src/main/java/org/cloudsimplus/examples/synchronous/package-info.java index 0e7f196..9948c23 100755 --- a/src/main/java/org/cloudsimplus/examples/synchronous/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/synchronous/package-info.java @@ -1,3 +1,26 @@ +/* + * CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for + * Modeling and Simulation of Cloud Computing Infrastructures and Services. + * http://cloudsimplus.org + * + * Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and + * the Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil). + * + * This file is part of CloudSim Plus. + * + * CloudSim Plus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CloudSim Plus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CloudSim Plus. If not, see . + */ /** * A set of examples showing how to run synchronous simulations. * They use the {@link org.cloudsimplus.core.CloudSimPlus#startSync()} diff --git a/src/main/java/org/cloudsimplus/examples/traces/package-info.java b/src/main/java/org/cloudsimplus/examples/traces/package-info.java index f47bbea..a434ea3 100755 --- a/src/main/java/org/cloudsimplus/examples/traces/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/traces/package-info.java @@ -1,3 +1,26 @@ +/* + * CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for + * Modeling and Simulation of Cloud Computing Infrastructures and Services. + * http://cloudsimplus.org + * + * Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and + * the Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil). + * + * This file is part of CloudSim Plus. + * + * CloudSim Plus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CloudSim Plus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CloudSim Plus. If not, see . + */ /** * Examples showing how to create simulations using a trace file. * From 54f912385fc86788d273a4099230207722976fe5 Mon Sep 17 00:00:00 2001 From: Manoel Campos Date: Tue, 20 Oct 2026 07:56:27 -0300 Subject: [PATCH 2/2] Convert Javadoc comments to Markdown (JEP 467) Javadoc comments (/** */) were converted to Markdown documentation comments (///), supported since JDK 23: - HTML tags (

, , , ,

, 
    /
      /
    1. , ) converted to Markdown; - {@code x} converted to `x` and {@link X label} to [label][X]; - block tags (@param, @return, @see...) and other inline tags ({@inheritDoc}, {@return}...) kept, since they're supported. Co-Authored-By: Claude Opus 5.5 --- .../examples/network/NetworkExample1.java | 22 +- .../examples/network/NetworkExample2.java | 6 +- .../examples/network/NetworkExample3.java | 10 +- .../examples/network/NetworkExample4.java | 24 +- .../NetworkVmExampleAbstract.java | 160 ++++----- .../NetworkVmsExampleBagOfTasksApp.java | 22 +- .../NetworkVmsExampleSimpleApp.java | 94 ++--- .../NetworkVmsExampleWorkflowApp.java | 34 +- .../examples/BasicFirstExample.java | 32 +- .../CloudletAndVmLifeTimeExample.java | 72 ++-- .../examples/CloudletCancellationExample.java | 62 ++-- .../examples/CloudletLifeTimeExample.java | 32 +- ...loudletsTableBuilderFormattingExample.java | 64 ++-- .../examples/HostFaultInjectionExample1.java | 124 +++---- .../examples/LargeScaleExample.java | 58 ++- .../cloudsimplus/examples/LoggingExample.java | 42 +-- .../examples/MinTimeBetweenEventsExample.java | 75 ++-- .../examples/ParallelSimulationsExample.java | 82 ++--- .../RandomVmAllocationPolicyExample.java | 67 ++-- .../cloudsimplus/examples/ReducedExample.java | 34 +- .../examples/StorageAreaNetworkExample1.java | 81 ++--- .../VmAllocationPolicyRoundRobinExample.java | 36 +- .../VmBootTimeAndOverheadExample.java | 36 +- .../examples/VmDestructionExample.java | 92 +++-- .../examples/VmGroupPlacementExample1.java | 46 +-- ...dBalancerByHorizontalVmScalingExample.java | 177 ++++------ .../VerticalVmCpuScalingDynamicThreshold.java | 281 +++++++-------- .../VerticalVmCpuScalingExample.java | 231 ++++++------ .../VerticalVmRamScalingExample.java | 189 +++++----- .../examples/autoscaling/package-info.java | 12 +- .../BrokerTargetDatacenterExample.java | 53 ++- .../brokers/CloudletToVmMappingBestFit.java | 49 ++- ...erBrokerBatchVmCreationRequestExample.java | 40 +-- .../DatacenterBrokerHeuristicExample.java | 64 ++-- .../DatacenterBrokersMappingComparison.java | 60 ++-- .../DatacenterSelectionByTimeZoneExample.java | 60 ++-- .../examples/brokers/MultipleBrokers1.java | 86 ++--- .../examples/brokers/MultipleBrokers2.java | 149 ++++---- .../examples/brokers/MultipleBrokers3.java | 20 +- .../brokers/SelectNextDatacenterExample.java | 46 +-- .../examples/brokers/package-info.java | 28 +- .../examples/costs/CostsExample1.java | 46 +-- .../CreateCloudletAfterLastFinishedOne.java | 77 ++-- .../dynamic/DynamicCloudletsArrival1.java | 100 +++--- .../dynamic/DynamicCloudletsArrival2.java | 125 +++---- ...namicCreationOfVmsAndCloudletsExample.java | 46 ++- .../examples/dynamic/DynamicHostCreation.java | 107 +++--- ...namicVmAllocationPolicyBestFitExample.java | 105 +++--- .../examples/dynamic/DynamicVmsArrival.java | 136 +++----- .../examples/dynamic/DynamicVmsArrival2.java | 107 +++--- .../dynamic/IndefiniteLengthCloudlet.java | 63 ++-- .../dynamic/KeepSimulationRunningExample.java | 112 +++--- .../RandomCloudletsArrivalExample.java | 104 +++--- .../examples/dynamic/package-info.java | 12 +- .../listeners/CloudletListenersExample1.java | 128 +++---- ...tenersExample2_ResourceUsageAlongTime.java | 124 +++---- .../listeners/VmListenersExample1.java | 100 +++--- .../listeners/VmListenersExample2.java | 128 +++---- ...VmListenersExample3_DynamicVmCreation.java | 160 ++++----- .../examples/listeners/package-info.java | 16 +- .../migration/InterDatacenterMigration1.java | 329 ++++++++---------- .../migration/ManualMigrationExample1.java | 163 ++++----- .../examples/migration/MigrationExample1.java | 312 +++++++---------- .../examples/migration/package-info.java | 12 +- .../performance/PerformanceExample1.java | 42 +-- .../UtilizationModelFullPerformance.java | 30 +- ...UtilizationModelStochasticPerformance.java | 99 +++--- .../examples/power/HostActivationExample.java | 118 +++---- .../examples/power/PowerExample.java | 174 ++++----- .../power/PowerExampleSchedulingInterval.java | 47 +-- .../examples/power/PowerSpecFileExample.java | 74 ++-- .../resourceusage/HostsCpuUsageExample.java | 52 ++- .../UtilizationModelDynamicExample.java | 24 +- ...equestedRamHigherThanAvailableExample.java | 139 +++----- ...elativeHostResourceUtilizationExample.java | 16 +- .../resourceusage/VmsCpuUsageExample.java | 56 ++- .../VmsRamAndBwUsageExample.java | 139 +++----- .../examples/resourceusage/package-info.java | 18 +- .../CloudletSchedulerSpaceSharedExample1.java | 40 +-- .../CloudletSchedulerTimeSharedExample1.java | 40 +-- .../LinuxCompletelyFairSchedulerExample.java | 29 +- ...PEsUsingVmSchedulerSpaceSharedExample.java | 73 ++-- ...tPEsUsingVmSchedulerTimeSharedExample.java | 60 ++-- ...woCloudletsAndOneSpaceSharedVmExample.java | 40 +-- ...TwoCloudletsAndOneTimeSharedVmExample.java | 40 +-- .../VmSchedulerTimeSharedExample.java | 79 ++--- .../examples/schedulers/package-info.java | 16 +- .../PauseSimulationAtGivenTimeExample1.java | 82 ++--- .../PauseSimulationAtGivenTimeExample2.java | 110 +++--- ...nateSimulationAtGivenConditionExample.java | 52 ++- ...TerminateSimulationAtGivenTimeExample.java | 24 +- .../simulationstatus/package-info.java | 10 +- ...grationWhenCpuMetricIsViolatedExample.java | 70 ++-- .../SynchronousSimulationExample1.java | 55 ++- .../examples/synchronous/package-info.java | 22 +- .../examples/traces/PlanetLabExample1.java | 48 +-- .../traces/SwfWorkloadFormatExample1.java | 113 +++--- .../google/GoogleMachineEventsExample1.java | 106 +++--- .../google/GoogleTaskEventsExample1.java | 131 +++---- .../examples/traces/package-info.java | 8 +- 100 files changed, 3254 insertions(+), 4586 deletions(-) diff --git a/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample1.java b/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample1.java index 4c1a8ba..84aeb3c 100755 --- a/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample1.java +++ b/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample1.java @@ -30,18 +30,16 @@ import java.util.ArrayList; import java.util.List; -/** - * A simple example showing how to create a Datacenter with 1 host and a network - * topology, running 1 cloudlet on it. - * There is just one VM with a single PE of 250 MIPS. - * The Cloudlet requires 1 PE and has a length of 40000 MI. - * This way, the Cloudlet will take 160 seconds to finish (40000/250). - * - *

      The Cloudlet is not requiring any files from a {@link SanStorage}, - * but since a network topology is defined from the file topology.brite, - * communication delay between network elements is simulated, - * causing the Cloudlet to start executing just after a few seconds.

      - */ +/// A simple example showing how to create a Datacenter with 1 host and a network +/// topology, running 1 cloudlet on it. +/// There is just one VM with a single PE of 250 MIPS. +/// The Cloudlet requires 1 PE and has a length of 40000 MI. +/// This way, the Cloudlet will take 160 seconds to finish (40000/250). +/// +/// The Cloudlet is not requiring any files from a [SanStorage], +/// but since a network topology is defined from the file topology.brite, +/// communication delay between network elements is simulated, +/// 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; diff --git a/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample2.java b/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample2.java index 261d235..6d9721d 100755 --- a/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample2.java +++ b/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample2.java @@ -28,10 +28,8 @@ import java.util.ArrayList; import java.util.List; -/** - * A simple example showing how to create 2 datacenters with 1 host. - * It sets a network topology and then run 2 cloudlets. - */ +/// A simple example showing how to create 2 datacenters with 1 host. +/// 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; diff --git a/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample3.java b/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample3.java index 7a99292..31f9cb8 100755 --- a/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample3.java +++ b/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample3.java @@ -28,10 +28,8 @@ import java.util.ArrayList; import java.util.List; -/** - * 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. - */ +/// 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; @@ -135,9 +133,7 @@ private void createAndSubmitVms() { brokerList.get(1).submitVmList(vmList2); } - /** - * Creates the network topology from a brite file. - */ + /// Creates the network topology from a brite file. private void createNetwork() { //load the network topology file final var networkTopology = BriteNetworkTopology.getInstance("topology.brite"); diff --git a/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample4.java b/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample4.java index ba3b33f..192728b 100755 --- a/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample4.java +++ b/src/main/java/org/cloudbus/cloudsim/examples/network/NetworkExample4.java @@ -31,24 +31,22 @@ import java.util.ArrayList; import java.util.List; -/** - * A simple example showing how to create a Datacenter with 1 host and a network - * topology, running 1 cloudlet on it. Here, instead of using a BRITE file - * describing the links, they are just inserted in the code. - * - *

      The example defines a given latency for communication with the created broker. - * Since the broker receives multiple messages (such as for VM and Cloudlet creation), - * cloudlets start running just after such multiple messages are received. - * If 3 messages are sent to the broker for starting a Cloudlet, - * the total delay is the network latency multiplied by 3.

      - */ +/// A simple example showing how to create a Datacenter with 1 host and a network +/// topology, running 1 cloudlet on it. Here, instead of using a BRITE file +/// describing the links, they are just inserted in the code. +/// +/// The example defines a given latency for communication with the created broker. +/// Since the broker receives multiple messages (such as for VM and Cloudlet creation), +/// cloudlets start running just after such multiple messages are received. +/// 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; - /** In Megabits/s. */ + /// In Megabits/s. private static final double NETWORK_BW = 10.0; - /** In seconds. */ + /// In seconds. private static final double NETWORK_LATENCY = 10.0; private final DatacenterBroker broker; diff --git a/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmExampleAbstract.java b/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmExampleAbstract.java index c539008..c1c72e2 100755 --- a/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmExampleAbstract.java +++ b/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmExampleAbstract.java @@ -25,18 +25,16 @@ import java.util.List; import java.util.Map; -/** - * A base class for network simulation examples - * using objects such as{@link NetworkDatacenter}, - * {@link NetworkHost}, {@link NetworkVm} and {@link NetworkCloudlet}. - * - *

      The class simulate applications that are compounded by a list of - * {@link NetworkCloudlet}.

      - * - * @author Saurabh Kumar Garg - * @author Rajkumar Buyya - * @author Manoel Campos da Silva Filho - */ +/// A base class for network simulation examples +/// using objects such as[NetworkDatacenter], +/// [NetworkHost], [NetworkVm] and [NetworkCloudlet]. +/// +/// The class simulate applications that are compounded by a list of +/// [NetworkCloudlet]. +/// +/// @author Saurabh Kumar Garg +/// @author Rajkumar Buyya +/// @author Manoel Campos da Silva Filho abstract class NetworkVmExampleAbstract { public static final int MAX_VMS_PER_HOST = 2; @@ -57,11 +55,9 @@ abstract class NetworkVmExampleAbstract { public static final long VM_BW = 1000; public static final int VM_PES_NUMBER = HOST_PES / MAX_VMS_PER_HOST; - /** - * Number of fictitious applications to create. - * Each application is just a list of {@link NetworkCloudlet}. - * @see #appMap - */ + /// 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; @@ -79,16 +75,12 @@ abstract class NetworkVmExampleAbstract { private final NetworkDatacenter datacenter; private final List brokerList; - /** - * A Map representing a list of cloudlets from different applications. - * Each key represents the ID of an app that is composed by a list - * of {@link NetworkCloudlet}. - */ + /// A Map representing a list of cloudlets from different applications. + /// Each key represents the ID of an app that is composed by a list + /// of [NetworkCloudlet]. private final Map> appMap; - /** - * Creates, starts, stops the simulation and shows results. - */ + /// Creates, starts, stops the simulation and shows results. NetworkVmExampleAbstract() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -112,11 +104,9 @@ abstract class NetworkVmExampleAbstract { showSimulationResults(); } - /** - * Adds an execution task to the list of tasks of the given {@link NetworkCloudlet}. - * - * @param cloudlet the {@link NetworkCloudlet} the task will belong to - */ + /// Adds an execution task to the list of tasks of the given [NetworkCloudlet]. + /// + /// @param cloudlet the [NetworkCloudlet] the task will belong to protected static void addExecutionTask(NetworkCloudlet cloudlet) { final var task = new CloudletExecutionTask(cloudlet.getTasks().size(), TASK_LENGTH); task.setMemory(TASK_RAM); @@ -144,12 +134,10 @@ private void showSimulationResults() { System.out.printf("%n%s finished!%n", getClass().getSimpleName()); } - /** - * Create a {@link DatacenterBroker} for each list of {@link NetworkCloudlet}, - * representing cloudlets that compose the same application. - * - * @return the list of created NetworkDatacenterBroker - */ + /// Create a [DatacenterBroker] for each list of [NetworkCloudlet], + /// representing cloudlets that compose the same application. + /// + /// @return the list of created NetworkDatacenterBroker private List createBrokerForEachApp() { final var brokerList = new ArrayList(); for(int i = 1; i <= APPS_NUMBER; i++){ @@ -159,11 +147,9 @@ private List createBrokerForEachApp() { return brokerList; } - /** - * Creates the Datacenter. - * - * @return the Datacenter - */ + /// Creates the Datacenter. + /// + /// @return the Datacenter protected final NetworkDatacenter createDatacenter() { final int hostsNumber = EdgeSwitch.PORTS * AggregateSwitch.PORTS * RootSwitch.PORTS; final var netHostList = new ArrayList(hostsNumber); @@ -198,10 +184,8 @@ protected List createPEs(final int pesNumber, final long mips) { return peList; } - /** - * Creates internal Datacenter network. - * @param datacenter Datacenter where the network will be created - */ + /// Creates internal Datacenter network. + /// @param datacenter Datacenter where the network will be created protected void createNetwork(final NetworkDatacenter datacenter) { final var edgeSwitches = new EdgeSwitch[1]; for (int i = 0; i < edgeSwitches.length; i++) { @@ -215,31 +199,27 @@ protected void createNetwork(final NetworkDatacenter datacenter) { } } - /** - * Gets the index of a switch where a Host will be connected, - * considering the number of ports the switches have. - * Ensures that each set of N Hosts is connected to the same switch - * (where N is defined as the number of switch's ports). - * Since the host ID is long but the switch array index is int, - * the module operation is used safely convert a long to int - * For instance, if the id is 2147483648 (higher than the max int value 2147483647), - * it will be returned 0. For 2147483649 it will be 1 and so on. - * - * @param host the Host to get the index of the switch to connect to - * @param switchPorts the number of ports (N) the switches where the Host will be connected have - * @return the index of the switch to connect the host - */ + /// Gets the index of a switch where a Host will be connected, + /// considering the number of ports the switches have. + /// Ensures that each set of N Hosts is connected to the same switch + /// (where N is defined as the number of switch's ports). + /// Since the host ID is long but the switch array index is int, + /// the module operation is used safely convert a long to int + /// For instance, if the id is 2147483648 (higher than the max int value 2147483647), + /// it will be returned 0. For 2147483649 it will be 1 and so on. + /// + /// @param host the Host to get the index of the switch to connect to + /// @param switchPorts the number of ports (N) the switches where the Host will be connected have + /// @return the index of the switch to connect the host public static int getSwitchIndex(final NetworkHost host, final int switchPorts) { return (int) (host.getId() % Integer.MAX_VALUE) / switchPorts; } - /** - * Creates a list of virtual machines in a Datacenter for a given broker - * and submit the list to the broker. - * - * @param broker The broker that will own the created VMs - * @return the list of created VMs - */ + /// Creates a list of virtual machines in a Datacenter for a given broker + /// and submit the list to the broker. + /// + /// @param broker The broker that will own the created VMs + /// @return the list of created VMs protected final List createAndSubmitVMs(DatacenterBroker broker) { final int vmsNumber = getDatacenterHostList().size() * MAX_VMS_PER_HOST; final var netVmList = new ArrayList(); @@ -260,9 +240,7 @@ private List getDatacenterHostList() { return datacenter.getHostList(); } - /** - * @return List of VMs of all Brokers. - */ + /// @return List of VMs of all Brokers. public List getVmList() { return vmList; } @@ -275,34 +253,28 @@ public NetworkDatacenter getDatacenter() { return datacenter; } - /** - * Creates a list of {@link NetworkCloudlet}'s that represents - * a single application and then submits the created cloudlets to a given Broker. - * - * @param broker the broker to submit the list of NetworkCloudlets of the application - * @return the list of created {@link NetworkCloudlet}'s - */ + /// Creates a list of [NetworkCloudlet]'s that represents + /// a single application and then submits the created cloudlets to a given Broker. + /// + /// @param broker the broker to submit the list of NetworkCloudlets of the application + /// @return the list of created [NetworkCloudlet]'s protected final List createAppAndSubmitToBroker(DatacenterBroker broker) { final var netCloudletList = createNetworkCloudlets(broker); broker.submitCloudletList(netCloudletList); return netCloudletList; } - /** - * Creates a list of {@link NetworkCloudlet} that together represents the distributed - * processes of a given application. - * - * @param broker broker to associate the NetworkCloudlets - * @return the list of create NetworkCloudlets - */ + /// Creates a list of [NetworkCloudlet] that together represents the distributed + /// processes of a given application. + /// + /// @param broker broker to associate the NetworkCloudlets + /// @return the list of create NetworkCloudlets protected abstract List createNetworkCloudlets(DatacenterBroker broker); - /** - * Adds a SendTask to the list of tasks of the given {@link NetworkCloudlet}. - * - * @param sourceCloudlet the {@link NetworkCloudlet} from which packets will be sent - * @param targetCloudlet the destination {@link NetworkCloudlet} to send packets to - */ + /// Adds a SendTask to the list of tasks of the given [NetworkCloudlet]. + /// + /// @param sourceCloudlet the [NetworkCloudlet] from which packets will be sent + /// @param targetCloudlet the destination [NetworkCloudlet] to send packets to protected void addSendTask( final NetworkCloudlet sourceCloudlet, final NetworkCloudlet targetCloudlet) @@ -315,12 +287,10 @@ protected void addSendTask( } } - /** - * Adds a ReceiveTask to the list of tasks of the given {@link NetworkCloudlet}. - * - * @param targetCloudlet the {@link NetworkCloudlet} the task will belong to - * @param sourceCloudlet the {@link NetworkCloudlet} expected to receive packets from - */ + /// Adds a ReceiveTask to the list of tasks of the given [NetworkCloudlet]. + /// + /// @param targetCloudlet the [NetworkCloudlet] the task will belong to + /// @param sourceCloudlet the [NetworkCloudlet] expected to receive packets from protected void addReceiveTask(final NetworkCloudlet targetCloudlet, final NetworkCloudlet sourceCloudlet) { final var task = new CloudletReceiveTask(targetCloudlet.getTasks().size(), sourceCloudlet.getVm()); task.setMemory(TASK_RAM); diff --git a/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmsExampleBagOfTasksApp.java b/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmsExampleBagOfTasksApp.java index 9b2bd94..b36eea8 100755 --- a/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmsExampleBagOfTasksApp.java +++ b/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmsExampleBagOfTasksApp.java @@ -8,22 +8,18 @@ import java.util.ArrayList; import java.util.List; -/** - * An example of "Bag of Tasks" distributed application that is compounded by - * 3 {@link NetworkCloudlet}, where 2 of them send data to the first created one, - * which waits the data to be received. - * - * @author Saurabh Kumar Garg - * @author Rajkumar Buyya - * @author Manoel Campos da Silva Filho - */ +/// An example of "Bag of Tasks" distributed application that is compounded by +/// 3 [NetworkCloudlet], where 2 of them send data to the first created one, +/// which waits the data to be received. +/// +/// @author Saurabh Kumar Garg +/// @author Rajkumar Buyya +/// @author Manoel Campos da Silva Filho public class NetworkVmsExampleBagOfTasksApp extends NetworkVmExampleAbstract { private static final long CLOUDLET_LENGTH = 1; - /** - * Starts the execution of the example. - * @param args - */ + /// Starts the execution of the example. + /// @param args public static void main(String[] args) { new NetworkVmsExampleBagOfTasksApp(); } diff --git a/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmsExampleSimpleApp.java b/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmsExampleSimpleApp.java index f73a602..45a59aa 100755 --- a/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmsExampleSimpleApp.java +++ b/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmsExampleSimpleApp.java @@ -24,13 +24,11 @@ import static org.cloudbus.cloudsim.examples.network.applications.NetworkVmExampleAbstract.getSwitchIndex; -/** - * A simple example simulating a distributed application. - * It shows how 2 {@link NetworkCloudlet}'s communicate, - * each one running inside VMs on different hosts. - * - * @author Manoel Campos da Silva Filho - */ +/// A simple example simulating a distributed application. +/// It shows how 2 [NetworkCloudlet]'s communicate, +/// each one running inside VMs on different hosts. +/// +/// @author Manoel Campos da Silva Filho public class NetworkVmsExampleSimpleApp { private static final int HOSTS = 2; private static final int HOST_MIPS = 1000; @@ -53,17 +51,13 @@ public class NetworkVmsExampleSimpleApp { private final NetworkDatacenter datacenter; private final DatacenterBroker broker; - /** - * Starts the execution of the example. - * @param args - */ + /// Starts the execution of the example. + /// @param args public static void main(String[] args) { new NetworkVmsExampleSimpleApp(); } - /** - * Creates, starts, stops the simulation and shows results. - */ + /// Creates, starts, stops the simulation and shows results. private NetworkVmsExampleSimpleApp() { System.out.println("Starting " + getClass().getSimpleName()); simulation = new CloudSimPlus(); @@ -125,11 +119,9 @@ private List createPEs(final int pesNumber, final long mips) { return peList; } - /** - * Creates internal Datacenter network. - * - * @param datacenter Datacenter where the network will be created - */ + /// Creates internal Datacenter network. + /// + /// @param datacenter Datacenter where the network will be created private void createNetwork(final NetworkDatacenter datacenter) { final var edgeSwitches = new EdgeSwitch[1]; for (int i = 0; i < edgeSwitches.length; i++) { @@ -143,13 +135,11 @@ private void createNetwork(final NetworkDatacenter datacenter) { } } - /** - * Creates a list of virtual machines in a Datacenter for a given broker and - * submit the list to the broker. - * - * @param broker The broker that will own the created VMs - * @return the list of created VMs - */ + /// Creates a list of virtual machines in a Datacenter for a given broker and + /// submit the list to the broker. + /// + /// @param broker The broker that will own the created VMs + /// @return the list of created VMs private List createAndSubmitVMs(DatacenterBroker broker) { final var netVmList = new ArrayList(); for (int i = 0; i < HOSTS; i++) { @@ -171,12 +161,10 @@ private NetworkVm createVm(int id) { return vm; } - /** - * Creates a list of {@link NetworkCloudlet} that together represents the - * distributed processes of a given fictitious application. - * - * @return the list of create NetworkCloudlets - */ + /// Creates a list of [NetworkCloudlet] that together represents the + /// distributed processes of a given fictitious application. + /// + /// @return the list of create NetworkCloudlets private List createNetworkCloudlets() { final int cloudletsNumber = 2; final var netCloudletList = new ArrayList(cloudletsNumber); @@ -196,12 +184,10 @@ private List createNetworkCloudlets() { return netCloudletList; } - /** - * Creates a {@link NetworkCloudlet}. - * - * @param vm the VM that will run the created {@link NetworkCloudlet) - * @return - */ + /// Creates a [NetworkCloudlet]. + /// + /// @param vm the VM that will run the created [NetworkCloudlet] + /// @return private NetworkCloudlet createNetworkCloudlet(NetworkVm vm) { final var netCloudlet = new NetworkCloudlet(HOST_PES); netCloudlet @@ -214,24 +200,20 @@ private NetworkCloudlet createNetworkCloudlet(NetworkVm vm) { return netCloudlet; } - /** - * Adds an execution-task to the list of tasks of the given - * {@link NetworkCloudlet}. - * - * @param cloudlet the {@link NetworkCloudlet} the task will belong to - */ + /// Adds an execution-task to the list of tasks of the given + /// [NetworkCloudlet]. + /// + /// @param cloudlet the [NetworkCloudlet] the task will belong to private static void addExecutionTask(NetworkCloudlet cloudlet) { final var task = new CloudletExecutionTask(cloudlet.getTasks().size(), TASK_LENGTH); task.setMemory(TASK_RAM); cloudlet.addTask(task); } - /** - * Adds a send-task to the list of tasks of the given {@link NetworkCloudlet}. - * - * @param sourceCloudlet the {@link NetworkCloudlet} from which packets will be sent - * @param destinationCloudlet the destination {@link NetworkCloudlet} to send packets to - */ + /// Adds a send-task to the list of tasks of the given [NetworkCloudlet]. + /// + /// @param sourceCloudlet the [NetworkCloudlet] from which packets will be sent + /// @param destinationCloudlet the destination [NetworkCloudlet] to send packets to private void addSendTask(final NetworkCloudlet sourceCloudlet, final NetworkCloudlet destinationCloudlet) { final var task = new CloudletSendTask(sourceCloudlet.getTasks().size()); task.setMemory(TASK_RAM); @@ -241,13 +223,11 @@ private void addSendTask(final NetworkCloudlet sourceCloudlet, final NetworkClou } } - /** - * Adds a receive-task to the list of tasks of the given - * {@link NetworkCloudlet}. - * - * @param cloudlet the {@link NetworkCloudlet} the task will belong to - * @param sourceCloudlet the {@link NetworkCloudlet} expected to receive packets from - */ + /// Adds a receive-task to the list of tasks of the given + /// [NetworkCloudlet]. + /// + /// @param cloudlet the [NetworkCloudlet] the task will belong to + /// @param sourceCloudlet the [NetworkCloudlet] expected to receive packets from private void addReceiveTask(final NetworkCloudlet cloudlet, final NetworkCloudlet sourceCloudlet) { final var task = new CloudletReceiveTask(cloudlet.getTasks().size(), sourceCloudlet.getVm()); task.setMemory(TASK_RAM); diff --git a/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmsExampleWorkflowApp.java b/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmsExampleWorkflowApp.java index 27d104a..457ff7f 100755 --- a/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmsExampleWorkflowApp.java +++ b/src/main/java/org/cloudbus/cloudsim/examples/network/applications/NetworkVmsExampleWorkflowApp.java @@ -8,20 +8,16 @@ import java.util.Arrays; import java.util.List; -/** - * An example of a Workflow Distributed Application that is compounded by - * 3 {@link NetworkCloudlet}, each one having different stages - * such as sending, receiving or processing data. - * - * @author Saurabh Kumar Garg - * @author Rajkumar Buyya - * @author Manoel Campos da Silva Filho - */ +/// An example of a Workflow Distributed Application that is compounded by +/// 3 [NetworkCloudlet], each one having different stages +/// such as sending, receiving or processing data. +/// +/// @author Saurabh Kumar Garg +/// @author Rajkumar Buyya +/// @author Manoel Campos da Silva Filho public class NetworkVmsExampleWorkflowApp extends NetworkVmExampleAbstract { - /** - * Starts the execution of the example. - * @param args - */ + /// Starts the execution of the example. + /// @param args public static void main(String[] args) { new NetworkVmsExampleWorkflowApp(); } @@ -56,13 +52,11 @@ public List createNetworkCloudlets(final DatacenterBroker broke return Arrays.asList(networkCloudlets); } - /** - * Creates a {@link NetworkCloudlet}. - * - * @param id - * @param vm the VM that will run the created {@link NetworkCloudlet} - * @return - */ + /// Creates a [NetworkCloudlet]. + /// + /// @param id + /// @param vm the VM that will run the created [NetworkCloudlet] + /// @return private NetworkCloudlet createNetworkCloudlet(final int id, final NetworkVm vm) { final var utilizationModel = new UtilizationModelFull(); final var cloudlet = new NetworkCloudlet(id, CLOUDLET_PES); diff --git a/src/main/java/org/cloudsimplus/examples/BasicFirstExample.java b/src/main/java/org/cloudsimplus/examples/BasicFirstExample.java index b9d18aa..5038c08 100755 --- a/src/main/java/org/cloudsimplus/examples/BasicFirstExample.java +++ b/src/main/java/org/cloudsimplus/examples/BasicFirstExample.java @@ -42,17 +42,15 @@ import java.util.ArrayList; import java.util.List; -/** - * A minimal but organized, structured and re-usable CloudSim Plus example - * which shows good coding practices for creating simulation scenarios. - * - *

      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.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - */ +/// A minimal but organized, structured and re-usable CloudSim Plus example +/// which shows good coding practices for creating simulation scenarios. +/// +/// 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 [Pe]s for Hosts, VMs and Cloudlets. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 public class BasicFirstExample { private static final int HOSTS = 1; private static final int HOST_PES = 8; @@ -100,9 +98,7 @@ private BasicFirstExample() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -129,9 +125,7 @@ private Host createHost() { return new HostSimple(HOST_RAM, HOST_BW, HOST_STORAGE, peList); } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var vmList = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -144,9 +138,7 @@ private List createVms() { return vmList; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var cloudletList = new ArrayList(CLOUDLETS); diff --git a/src/main/java/org/cloudsimplus/examples/CloudletAndVmLifeTimeExample.java b/src/main/java/org/cloudsimplus/examples/CloudletAndVmLifeTimeExample.java index 9a06339..ca61dd1 100644 --- a/src/main/java/org/cloudsimplus/examples/CloudletAndVmLifeTimeExample.java +++ b/src/main/java/org/cloudsimplus/examples/CloudletAndVmLifeTimeExample.java @@ -50,25 +50,21 @@ import java.util.List; import java.util.stream.IntStream; -/** - * An example showing how to use the new {@link Lifetimed#setLifeTime(double)} to - * define the maximum time {@link Cloudlet} or {@link Vm} entity is allowed to execute. - * After this time is reached, the entity is finished as soon as possible. - * - *

      - * If the VM has a lifeTime set, it's Cloudlets follow the same lifetime. - * If both Cloudlet and Vm have a lifetime, the shorter defines the maximum - * amount of time the Cloudlet will execute. - *

      - * - *

      The example creates all Cloudlets and some VMs with a given lifetime. - * Since VM lifetime is shorter than their Cloudlets' lifetime, - * such Cloudlets finish sooner than their own lifetime.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 8.2.0 - * @see CloudletLifeTimeExample - */ +/// An example showing how to use the new [Lifetimed#setLifeTime(double)] to +/// define the maximum time [Cloudlet] or [Vm] entity is allowed to execute. +/// After this time is reached, the entity is finished as soon as possible. +/// +/// If the VM has a lifeTime set, it's Cloudlets follow the same lifetime. +/// If both Cloudlet and Vm have a lifetime, the shorter defines the maximum +/// amount of time the Cloudlet will execute. +/// +/// The example creates all Cloudlets and some VMs with a given lifetime. +/// Since VM lifetime is shorter than their Cloudlets' lifetime, +/// such Cloudlets finish sooner than their own lifetime. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 8.2.0 +/// @see CloudletLifeTimeExample public class CloudletAndVmLifeTimeExample { private static final int HOSTS = 3; private static final int HOST_PES = 10; @@ -81,23 +77,17 @@ public class CloudletAndVmLifeTimeExample { private static final int CLOUDLET_PES = 2; private static final int CLOUDLET_LENGTH = 10_000; - /** - * If the scheduling interval is not multiple of the VM/Cloudlet lifetime, - * Cloudlets may execute more than you desire. - * @see Datacenter#getSchedulingInterval() - */ + /// If the scheduling interval is not multiple of the VM/Cloudlet lifetime, + /// Cloudlets may execute more than you desire. + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 3; - /** - * Maximum time (in seconds) Cloudlets are allowed to execute. - * Set -1 to disable lifeTime and execute the Cloudlet entirely. - */ + /// Maximum time (in seconds) Cloudlets are allowed to execute. + /// Set -1 to disable lifeTime and execute the Cloudlet entirely. private static final double CLOUDLET_LIFE_TIME = 5; - /** - * Maximum time (in seconds) some VMs are allowed to execute. - * @see Lifetimed#setLifeTime(double) - */ + /// Maximum time (in seconds) some VMs are allowed to execute. + /// @see Lifetimed#setLifeTime(double) private static final double VM_LIFE_TIME = 3; private final CloudSimPlus simulation; @@ -141,21 +131,17 @@ private CloudletAndVmLifeTimeExample() { System.out.printf("Simulation finished at %s. Execution time: %.2f seconds%n", LocalTime.now(), TimeUtil.elapsedSeconds(startSecs)); } - /** - * Gets the lifetime as a String. - * If the lifetime is {@link Double#MAX_VALUE} (the default value), - * returns an empty string to indicate the attribute was not set. - * - * @param entity a Cloudlet of VM entity - * @return a String lifetime - */ + /// Gets the lifetime as a String. + /// If the lifetime is [Double#MAX_VALUE] (the default value), + /// returns an empty string to indicate the attribute was not set. + /// + /// @param entity a Cloudlet of VM entity + /// @return a String lifetime private String getLifeTimeStr(final Lifetimed entity) { return entity.getLifeTime() == Double.MAX_VALUE ? "" : "%.2f".formatted(entity.getLifeTime()); } - /** - * Sets a lifetime for half of the VMs. - */ + /// Sets a lifetime for half of the VMs. private void setVmsLifeTime() { vmList.stream() .filter(vm -> vm.getId() < VMS/2) diff --git a/src/main/java/org/cloudsimplus/examples/CloudletCancellationExample.java b/src/main/java/org/cloudsimplus/examples/CloudletCancellationExample.java index 8682f60..67124ed 100755 --- a/src/main/java/org/cloudsimplus/examples/CloudletCancellationExample.java +++ b/src/main/java/org/cloudsimplus/examples/CloudletCancellationExample.java @@ -48,25 +48,21 @@ import java.util.ArrayList; import java.util.List; -/** - * Shows how to cancel the execution of a Cloudlet - * after executing a given amount of MIPS from its total - * MIPS length. - * - *

      Realize you can't use the {@link Cloudlet#setStatus(Cloudlet.Status)} - * to directly change the status of a Cloudlet, such as to cancel it. - * That is an issue inherited from CloudSim that needs to be fixed yet. - * To change the Cloudlet status you have to use the {@link CloudletScheduler} - * that controls the execution of the Cloudlet.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.2.6 - */ +/// Shows how to cancel the execution of a Cloudlet +/// after executing a given amount of MIPS from its total +/// MIPS length. +/// +/// Realize you can't use the [Cloudlet#setStatus(Cloudlet.Status)] +/// to directly change the status of a Cloudlet, such as to cancel it. +/// That is an issue inherited from CloudSim that needs to be fixed yet. +/// To change the Cloudlet status you have to use the [CloudletScheduler] +/// that controls the execution of the Cloudlet. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.2.6 public class CloudletCancellationExample { - /** - * Defines, between other things, the time intervals - * to update the processing of Cloudlets (in seconds). - */ + /// Defines, between other things, the time intervals + /// to update the processing of Cloudlets (in seconds). private static final int SCHEDULING_INTERVAL = 1; private static final int HOSTS = 1; @@ -103,13 +99,11 @@ private CloudletCancellationExample() { vmList = createVms(); cloudletList = createCloudlets(); - /** - * Monitor the execution of the first Cloudlet to cancel it after it has executed 50% - * of its total length. - * In order to make this work, the {@link Datacenter#getSchedulingInterval()} - * most be set. - * See {@link #SCHEDULING_INTERVAL} for more details. - */ + /// Monitor the execution of the first Cloudlet to cancel it after it has executed 50% + /// of its total length. + /// In order to make this work, the [Datacenter#getSchedulingInterval()] + /// most be set. + /// See [#SCHEDULING_INTERVAL] for more details. cloudletList.get(0).addOnUpdateProcessingListener(this::cancelCloudletIfHalfExecuted); broker0.submitVmList(vmList); @@ -121,10 +115,8 @@ private CloudletCancellationExample() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Cancel a Cloudlet if it has already executed 50% of its total MIPS length. - * @param e the event information about Cloudlet processing - */ + /// Cancel a Cloudlet if it has already executed 50% of its total MIPS length. + /// @param e the event information about Cloudlet processing private void cancelCloudletIfHalfExecuted(final CloudletVmEventInfo e) { final var cloudlet = e.getCloudlet(); if(cloudlet.getFinishedLengthSoFar() >= CLOUDLET_LENGTH / 2){ @@ -135,9 +127,7 @@ private void cancelCloudletIfHalfExecuted(final CloudletVmEventInfo e) { } } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -171,9 +161,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var list = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -188,9 +176,7 @@ private List createVms() { return list; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var list = new ArrayList(CLOUDLETS); for (int i = 0; i < CLOUDLETS; i++) { diff --git a/src/main/java/org/cloudsimplus/examples/CloudletLifeTimeExample.java b/src/main/java/org/cloudsimplus/examples/CloudletLifeTimeExample.java index b7707be..dac0402 100644 --- a/src/main/java/org/cloudsimplus/examples/CloudletLifeTimeExample.java +++ b/src/main/java/org/cloudsimplus/examples/CloudletLifeTimeExample.java @@ -48,16 +48,14 @@ import java.util.List; import java.util.stream.IntStream; -/** - * An example showing how to use the new {@link Cloudlet#setLifeTime(double)} to - * define the maximum time the Cloudlet is allowed to execute. - * After this time is reached, the Cloudlet is finished as soon as possible.

      - * - * @author Sun Lingyu - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 7.2.1 - * @see CloudletAndVmLifeTimeExample - */ +/// An example showing how to use the new [Cloudlet#setLifeTime(double)] to +/// define the maximum time the Cloudlet is allowed to execute. +/// After this time is reached, the Cloudlet is finished as soon as possible. +/// +/// @author Sun Lingyu +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 7.2.1 +/// @see CloudletAndVmLifeTimeExample public class CloudletLifeTimeExample { private static final int HOSTS = 3; private static final int HOST_PES = 10; @@ -70,17 +68,13 @@ public class CloudletLifeTimeExample { private static final int CLOUDLET_PES = 2; private static final int CLOUDLET_LENGTH = 10_000; - /** - * If the scheduling interval is not multiple of the VM/Cloudlet lifetime, - * Cloudlets may execute more than you desire. - * @see Datacenter#getSchedulingInterval() - */ + /// If the scheduling interval is not multiple of the VM/Cloudlet lifetime, + /// Cloudlets may execute more than you desire. + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 2; - /** - * Maximum time (in seconds) Cloudlets are allowed to execute. - * @see Lifetimed#setLifeTime(double) - */ + /// Maximum time (in seconds) Cloudlets are allowed to execute. + /// @see Lifetimed#setLifeTime(double) private static final double CLOUDLET_LIFE_TIME = 5; private final CloudSimPlus simulation; diff --git a/src/main/java/org/cloudsimplus/examples/CloudletsTableBuilderFormattingExample.java b/src/main/java/org/cloudsimplus/examples/CloudletsTableBuilderFormattingExample.java index 6ad44f3..28be2b9 100644 --- a/src/main/java/org/cloudsimplus/examples/CloudletsTableBuilderFormattingExample.java +++ b/src/main/java/org/cloudsimplus/examples/CloudletsTableBuilderFormattingExample.java @@ -43,16 +43,14 @@ import java.util.ArrayList; import java.util.List; -/** - * A variation of BasicFirstExample.java which runs two kinds of cloudlets - * ("long" and a "short") and prints the simulations results in several different - * styles to demonstrate the functionality of CloudletsTableBuilder. - * - * The actual simulation is not the focus in this example, the formatting is. - * - * @author Lennart Demes - * @author Manoel Campos da Silva Filho - */ +/// A variation of BasicFirstExample.java which runs two kinds of cloudlets +/// ("long" and a "short") and prints the simulations results in several different +/// styles to demonstrate the functionality of CloudletsTableBuilder. +/// +/// The actual simulation is not the focus in this example, the formatting is. +/// +/// @author Lennart Demes +/// @author Manoel Campos da Silva Filho public class CloudletsTableBuilderFormattingExample { private static final int HOSTS = 1; private static final int HOST_PES = 8; @@ -67,10 +65,8 @@ public class CloudletsTableBuilderFormattingExample { private static final int CLOUDLETS = 4; private static final int CLOUDLET_PES = 2; - /** - * Cloudlet lengths are deliberately arbitrary to create more - * interesting results for custom formatting. - */ + /// Cloudlet lengths are deliberately arbitrary to create more + /// interesting results for custom formatting. private static final int CLOUDLET_LENGTH_SHORT = 124_963; private static final int CLOUDLET_LENGTH_LONG = 984_174_395; @@ -108,53 +104,39 @@ private CloudletsTableBuilderFormattingExample() { } - /** - * Displays a list of cloudlets as a table while demonstrating several formatting/display options. - * @param cloudletFinishedList The list of cloudlets to use for the demonstration. - */ + /// Displays a list of cloudlets as a table while demonstrating several formatting/display options. + /// @param cloudletFinishedList The list of cloudlets to use for the demonstration. private void demonstrateCloudletTableFormattingOptions(List cloudletFinishedList) { - /** - * Prints the results with default settings. - */ + /// Prints the results with default settings. new CloudletsTableBuilder(cloudletFinishedList) .build(); - /** - * Prints the results with a custom title. - */ + /// Prints the results with a custom title. new CloudletsTableBuilder(cloudletFinishedList) .setTitle("This is a custom title") .build(); - /** - * Prints the results with 3 instead of one decimal point for time columns. - */ + /// Prints the results with 3 instead of one decimal point for time columns. new CloudletsTableBuilder(cloudletFinishedList) .setTimeFormat("%.3f") .setTitle("3 decimal points in time columns") .build(); - /** - * Prints the results with additional separators in the length columns to increase readability. - */ + /// Prints the results with additional separators in the length columns to increase readability. new CloudletsTableBuilder(cloudletFinishedList) .setLengthFormat("%,d") .setTitle("Separators in length columns") .build(); - /** - * Adds an entire additional column for displaying the submission delay of a cloudlet. - */ + /// Adds an entire additional column for displaying the submission delay of a cloudlet. new CloudletsTableBuilder(cloudletFinishedList) .setTitle("Additional column for submission delay") .addColumn( new MarkdownTableColumn("SubmissionDelay") , Cloudlet::getSubmissionDelay) .build(); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -181,9 +163,7 @@ private Host createHost() { return new HostSimple(HOST_RAM, HOST_BW, HOST_STORAGE, peList); } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var vmList = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -196,10 +176,8 @@ private List createVms() { return vmList; } - /** - * Creates a list of Cloudlets, toggling between a "long" cloudlet with a high number of MIs - * and a "short" cloudlet with less MIs. "Short" cloudlets also receive a smaller submission delay. - */ + /// Creates a list of Cloudlets, toggling between a "long" cloudlet with a high number of MIs + /// and a "short" cloudlet with less MIs. "Short" cloudlets also receive a smaller submission delay. private List createCloudlets() { final var cloudletList = new ArrayList(CLOUDLETS); diff --git a/src/main/java/org/cloudsimplus/examples/HostFaultInjectionExample1.java b/src/main/java/org/cloudsimplus/examples/HostFaultInjectionExample1.java index dd3d64b..e3444ea 100755 --- a/src/main/java/org/cloudsimplus/examples/HostFaultInjectionExample1.java +++ b/src/main/java/org/cloudsimplus/examples/HostFaultInjectionExample1.java @@ -51,34 +51,29 @@ import java.util.List; import java.util.stream.IntStream; -/** - * Example showing how to inject random {@link Pe} faults into Hosts using - * {@link HostFaultInjection} objects. - * - *

      It's considered that we have multiple VMs from a given customer (broker), - * where all VMs are running the same services for load balancing and fault tolerance. - * If a VM fails, since they are providing the same service and there are other equal VMs running, - * there is no need for recovery. - * If the failures don't demand recovery, no new VMs need to be started up, since no service was stopped. - *

      - * - *

      If you run this example multiple times, it will give the same results. - * Check {@link #createFaultInjectionForHosts(Datacenter)} to set - * a different seed for the fault injection random number generator - * to get different results at each run.

      - * - * @author raysaoliveira - * @since CloudSim Plus 1.2.0 - */ +/// Example showing how to inject random [Pe] faults into Hosts using +/// [HostFaultInjection] objects. +/// +/// It's considered that we have multiple VMs from a given customer (broker), +/// where all VMs are running the same services for load balancing and fault tolerance. +/// If a VM fails, since they are providing the same service and there are other equal VMs running, +/// there is no need for recovery. +/// If the failures don't demand recovery, no new VMs need to be started up, since no service was stopped. +/// +/// If you run this example multiple times, it will give the same results. +/// Check [#createFaultInjectionForHosts(Datacenter)] to set +/// a different seed for the fault injection random number generator +/// to get different results at each run. +/// +/// @author raysaoliveira +/// @since CloudSim Plus 1.2.0 public final class HostFaultInjectionExample1 { private static final int SCHEDULE_TIME_TO_PROCESS_DATACENTER_EVENTS = 0; private static final int BROKERS = 1; - /** - * Number of Hosts to create for each Datacenter. The number of elements in - * this array defines the number of Datacenters to be created. - */ + /// Number of Hosts to create for each Datacenter. The number of elements in + /// this array defines the number of Datacenters to be created. private static final int HOSTS = 8; private static final int HOST_PES = 5; private static final int HOST_MIPS_BY_PE = 1000; @@ -86,13 +81,12 @@ public final class HostFaultInjectionExample1 { private static final long HOST_STORAGE = 1000000; //host storage private static final long HOST_BW = 100000000L; - /** - * The average number of failures expected to happen each hour - * in a Poisson arrival process, which is also called event rate or rate parameter. - * @see PoissonDistr */ + /// The average number of failures expected to happen each hour + /// in a Poisson arrival process, which is also called event rate or rate parameter. + /// @see PoissonDistr private static final double MEAN_FAILURE_NUMBER_PER_HOUR = 0.01; - /** @see HostFaultInjection#setMaxTimeToFailInHours(double) */ + /// @see HostFaultInjection#setMaxTimeToFailInHours(double) private static final double MAX_TIME_TO_FAIL_IN_HOURS = TimeUtil.daysToHours(30); private final List hostList = new ArrayList<>(); @@ -107,10 +101,8 @@ public final class HostFaultInjectionExample1 { private static final int CLOUDLETS_BY_BROKER = 6; private static final int CLOUDLET_PES = 2; - /** - * The length has to be large to ensure the simulation will run for long enough, - * so that faults will affect all VMs from certain broker. - */ + /// The length has to be large to ensure the simulation will run for long enough, + /// so that faults will affect all VMs from certain broker. private static final long CLOUDLET_LENGTH = 1_000_000_000L; private static final long CLOUDLET_FILESIZE = 300; @@ -124,9 +116,7 @@ public final class HostFaultInjectionExample1 { private final HostFaultInjection fault; - /** - * The Poisson Random Number Generator used to generate failure times (in hours). - */ + /// The Poisson Random Number Generator used to generate failure times (in hours). private PoissonDistr poisson; public static void main(String[] args) { @@ -197,10 +187,8 @@ public Vm createVm() { return vm; } - /** - * Creates the number of Cloudlets defined in {@link #CLOUDLETS_BY_BROKER} and submits - * them to the created broker. - */ + /// Creates the number of Cloudlets defined in [#CLOUDLETS_BY_BROKER] and submits + /// them to the created broker. public void createAndSubmitCloudlets(final DatacenterBroker broker) { final List cloudletList = new ArrayList<>(CLOUDLETS_BY_BROKER); final var utilizationModelDynamic = new UtilizationModelDynamic(0.1); @@ -254,12 +242,10 @@ public List createPeList(final int pesNumber, final long mips) { return peList; } - /** - * Creates the fault injection for host - * - * @param datacenter - * @return - */ + /// Creates the fault injection for host + /// + /// @param datacenter + /// @return private HostFaultInjection createFaultInjectionForHosts(final Datacenter datacenter) { //Use the system time to get random results every time you run the simulation //final long seed = System.currentTimeMillis(); @@ -276,15 +262,13 @@ private HostFaultInjection createFaultInjectionForHosts(final Datacenter datacen return fault; } - /** - * Clones a VM by creating another one with the same configurations of a - * given VM. - * - * @param vm the VM to be cloned - * @return the cloned (new) VM. - * - * @see #createFaultInjectionForHosts(Datacenter) - */ + /// Clones a VM by creating another one with the same configurations of a + /// given VM. + /// + /// @param vm the VM to be cloned + /// @return the cloned (new) VM. + /// + /// @see #createFaultInjectionForHosts(Datacenter) private Vm cloneVm(final Vm vm) { final Vm clone = new VmSimple(vm.getMips(), vm.getPesNumber()); /*It' not required to set an ID for the clone. @@ -307,18 +291,16 @@ private Vm cloneVm(final Vm vm) { return clone; } - /** - * Clones each Cloudlet associated to a given VM. The method is called when - * a VM is destroyed due to a Host failure and a snapshot from that VM (a - * clone) is started into another Host. In this case, all the Cloudlets - * which were running inside the destroyed VM will be recreated from scratch - * into the VM clone, re-starting their execution from the beginning. - * - * @param sourceVm the VM to clone its Cloudlets - * @return the List of cloned Cloudlets. - * @see - * #createFaultInjectionForHosts(Datacenter) - */ + /// Clones each Cloudlet associated to a given VM. The method is called when + /// a VM is destroyed due to a Host failure and a snapshot from that VM (a + /// clone) is started into another Host. In this case, all the Cloudlets + /// which were running inside the destroyed VM will be recreated from scratch + /// into the VM clone, re-starting their execution from the beginning. + /// + /// @param sourceVm the VM to clone its Cloudlets + /// @return the List of cloned Cloudlets. + /// @see + /// #createFaultInjectionForHosts(Datacenter) private List cloneCloudlets(final Vm sourceVm) { final var sourceVmCloudletList = sourceVm.getCloudletScheduler().getCloudletList(); final var clonedCloudletList = new ArrayList(sourceVmCloudletList.size()); @@ -333,12 +315,10 @@ private List cloneCloudlets(final Vm sourceVm) { return clonedCloudletList; } - /** - * Creates a clone from a given Cloudlet. - * - * @param source the Cloudlet to be cloned. - * @return the cloned (new) cloudlet - */ + /// Creates a clone from a given Cloudlet. + /// + /// @param source the Cloudlet to be cloned. + /// @return the cloned (new) cloudlet private Cloudlet cloneCloudlet(Cloudlet source) { final var clone = new CloudletSimple(source.getLength(), source.getPesNumber()); /*It' not required to set an ID for the clone. diff --git a/src/main/java/org/cloudsimplus/examples/LargeScaleExample.java b/src/main/java/org/cloudsimplus/examples/LargeScaleExample.java index 2af351b..437e77d 100755 --- a/src/main/java/org/cloudsimplus/examples/LargeScaleExample.java +++ b/src/main/java/org/cloudsimplus/examples/LargeScaleExample.java @@ -48,23 +48,21 @@ import static org.cloudsimplus.util.TimeUtil.elapsedSeconds; import static org.cloudsimplus.util.TimeUtil.secondsToStr; -/** - * An example creating a huge number of Hosts, VMs and Cloudlets - * to simulate a large-scale cloud infrastructure. - * - *

      The example may run out of memory. - * Try to increase heap memory space passing, for instance, - * -Xmx6g to the java command line, where 6g means 6GB of maximum heap size.

      - * - *

      Your computer may not even have enough memory capacity to run this example - * and it may just crashes with OutOfMemoryException.

      - * - *

      Some factors that drastically impact simulation performance and memory consumption - * is the {@link #CLOUDLETS} number and {@link #SCHEDULING_INTERVAL}.

      - * - * @author Manoel Campos da Silva Filho - * @since ClodSimPlus 7.3.1 - */ +/// An example creating a huge number of Hosts, VMs and Cloudlets +/// to simulate a large-scale cloud infrastructure. +/// +/// The example may run out of memory. +/// Try to increase heap memory space passing, for instance, +/// -Xmx6g to the java command line, where 6g means 6GB of maximum heap size. +/// +/// Your computer may not even have enough memory capacity to run this example +/// and it may just crashes with OutOfMemoryException. +/// +/// Some factors that drastically impact simulation performance and memory consumption +/// is the [#CLOUDLETS] number and [#SCHEDULING_INTERVAL]. +/// +/// @author Manoel Campos da Silva Filho +/// @since ClodSimPlus 7.3.1 public class LargeScaleExample { private static final int HOSTS = 200_000; private static final int HOST_PES = 16; @@ -80,14 +78,12 @@ public class LargeScaleExample { private static final int CLOUDLET_PES = VM_PES/2; private static final int CLOUDLET_LENGTH = HOST_MIPS * 10; - /** - * Defines a time interval to process cloudlets execution - * and possibly collect data. Setting a value greater than 0 - * enables that interval, which cause huge performance penaults for - * lage scale simulations. - * - * @see Datacenter#setSchedulingInterval(double) - */ + /// Defines a time interval to process cloudlets execution + /// and possibly collect data. Setting a value greater than 0 + /// enables that interval, which cause huge performance penaults for + /// lage scale simulations. + /// + /// @see Datacenter#setSchedulingInterval(double) private static final double SCHEDULING_INTERVAL = -1; private final CloudSimPlus simulation; @@ -146,9 +142,7 @@ private void brokerSubmit() { broker0.submitCloudletList(cloudletList); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); System.out.printf("Creating %,d Hosts%n", HOSTS); @@ -177,9 +171,7 @@ private Host createHost() { return new HostSimple(HOST_RAM, HOST_BW, HOST_STORAGE, peList); } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var vmList = new ArrayList(VMS); System.out.printf("Creating %,d VMs%n", VMS); @@ -193,9 +185,7 @@ private List createVms() { return vmList; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var cloudletList = new ArrayList(CLOUDLETS); diff --git a/src/main/java/org/cloudsimplus/examples/LoggingExample.java b/src/main/java/org/cloudsimplus/examples/LoggingExample.java index 91f5757..db6f7ac 100755 --- a/src/main/java/org/cloudsimplus/examples/LoggingExample.java +++ b/src/main/java/org/cloudsimplus/examples/LoggingExample.java @@ -51,14 +51,12 @@ import java.util.Comparator; import java.util.List; -/** - * An example showing how CloudSim Plus - * is flexible in managing logs of different entities. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 5.3.0 - * @see #configureLogs() - */ +/// An example showing how CloudSim Plus +/// is flexible in managing logs of different entities. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 5.3.0 +/// @see #configureLogs() public class LoggingExample { private static final int SCHEDULING_INTERVAL_SECS = 10; private static final double HOST_OVER_UTILIZATION_MIGRATION_THRESHOLD = 0.7; @@ -136,19 +134,15 @@ private void configureLogs() { Log.setLevel(CloudletScheduler.LOGGER, Level.WARN); } - /** - * Creates a UtilizationModel that starts the resource utilization at a given percentage - * and keeps increasing along the time. - */ + /// Creates a UtilizationModel that starts the resource utilization at a given percentage + /// and keeps increasing along the time. private UtilizationModelDynamic createDynamicUtilizationModel() { final var utilizationModel = new UtilizationModelDynamic(0.5); utilizationModel.setUtilizationUpdateFunction(model -> model.getUtilization() + model.getTimeSpan()*0.1); return utilizationModel; } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOST_PES.length); for (int pes : HOST_PES) { @@ -185,9 +179,7 @@ private Host createHost(final int pes) { return new HostSimple(HOST_RAM, HOST_BW, HOST_STORAGE, peList); } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var list = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -200,19 +192,15 @@ private List createVms() { return list; } - /** - * Creates a list of Cloudlets. - * @param utilizationModel the UtilizationModel to be used for all Cloudlet resources (CPU, RAM and BW). - */ + /// Creates a list of Cloudlets. + /// @param utilizationModel the UtilizationModel to be used for all Cloudlet resources (CPU, RAM and BW). private List createCloudlets(final UtilizationModel utilizationModel) { return createCloudlets(utilizationModel, 0); } - /** - * Creates a list of Cloudlets. - * @param utilizationModel the UtilizationModel to be used for all Cloudlet resources (CPU, RAM and BW). - * @param submissionDelay the delay to submit Cloudlets to the broker - */ + /// Creates a list of Cloudlets. + /// @param utilizationModel the UtilizationModel to be used for all Cloudlet resources (CPU, RAM and BW). + /// @param submissionDelay the delay to submit Cloudlets to the broker private List createCloudlets(final UtilizationModel utilizationModel, final double submissionDelay) { final var list = new ArrayList(CLOUDLETS); diff --git a/src/main/java/org/cloudsimplus/examples/MinTimeBetweenEventsExample.java b/src/main/java/org/cloudsimplus/examples/MinTimeBetweenEventsExample.java index aa1f38a..b67d824 100755 --- a/src/main/java/org/cloudsimplus/examples/MinTimeBetweenEventsExample.java +++ b/src/main/java/org/cloudsimplus/examples/MinTimeBetweenEventsExample.java @@ -53,40 +53,35 @@ import java.util.Comparator; import java.util.List; -/** - * An example showing how the {@link Simulation#getMinTimeBetweenEvents()} may affect the processing - * of events in your simulation. - * This way, it may affect simulation accuracy, regarding the execution time of Cloudlets. - * - *

      These issues happen when the time between some events is smaller than the - * {@link Simulation#getMinTimeBetweenEvents()} (for instance, some Cloudlets are finishing - * in a time interval smaller than the mentioned simulation attribute). - * Therefore, you may need to fine tune such attribute according to your simulation.

      - * - *

      This example reproduces the configuration - * Issue #163. - * The documentation of the {@link #MIN_TIME_BETWEEN_EVENTS} constant below shows how - * to configure the attribute to make CloudSim Plus process all events - * accurately in this scenario and then all submitted Cloudlets be finished. - *

      - * - * @author Natthasak Vechprasit - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.0.7 - */ +/// An example showing how the [Simulation#getMinTimeBetweenEvents()] may affect the processing +/// of events in your simulation. +/// This way, it may affect simulation accuracy, regarding the execution time of Cloudlets. +/// +/// These issues happen when the time between some events is smaller than the +/// [Simulation#getMinTimeBetweenEvents()] (for instance, some Cloudlets are finishing +/// in a time interval smaller than the mentioned simulation attribute). +/// Therefore, you may need to fine tune such attribute according to your simulation. +/// +/// This example reproduces the configuration +/// [Issue #163](https://github.com/cloudsimplus/cloudsimplus/issues/163). +/// The documentation of the [#MIN_TIME_BETWEEN_EVENTS] constant below shows how +/// to configure the attribute to make CloudSim Plus process all events +/// accurately in this scenario and then all submitted Cloudlets be finished. +/// +/// @author Natthasak Vechprasit +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.0.7 public class MinTimeBetweenEventsExample { - /** - * The minimum time between an event and the previous one to get the current event to be processed. - * - *

      If events happen in a time interval smaller than this value, that will - * impact results accuracy. The created Cloudlets take about 0.1 second to finish, - * but with the current MIN_TIME_BETWEEN_EVENTS, you'll see the ExecTime is greater than - * that.

      - * - *

      You can fix that by changing this constant to 0.01, for instance.

      - * - * @see CloudSimPlus#getMinTimeBetweenEvents() - */ + /// The minimum time between an event and the previous one to get the current event to be processed. + /// + /// If events happen in a time interval smaller than this value, that will + /// impact results accuracy. The created Cloudlets take about 0.1 second to finish, + /// but with the current MIN_TIME_BETWEEN_EVENTS, you'll see the ExecTime is greater than + /// that. + /// + /// You can fix that by changing this constant to 0.01, for instance. + /// + /// @see CloudSimPlus#getMinTimeBetweenEvents() private static final double MIN_TIME_BETWEEN_EVENTS = 0.5; private static final int HOST_PES_NUMBER = 4; @@ -174,10 +169,8 @@ private Vm createVm(final int id) { return vm; } - /** - * Creates a list of Cloudlets to be run inside a given VM - * @param vm the VM to run the Cloudlets - */ + /// Creates a list of Cloudlets to be run inside a given VM + /// @param vm the VM to run the Cloudlets private void createAndSubmitCloudlets(final Vm vm) { final var list = new ArrayList(CLOUDLETS); @@ -189,11 +182,9 @@ private void createAndSubmitCloudlets(final Vm vm) { cloudletList.addAll(list); } - /** - * Creates a cloudlet with random submission delay for a given VM. - * @param vm the VM to run the Cloudlet - * @return the created Cloudlet - */ + /// Creates a cloudlet with random submission delay for a given VM. + /// @param vm the VM to run the Cloudlet + /// @return the created Cloudlet private Cloudlet createCloudlet(final Vm vm) { final long fileSize = 300; //in bytes final long outputSize = 300; //in bytes diff --git a/src/main/java/org/cloudsimplus/examples/ParallelSimulationsExample.java b/src/main/java/org/cloudsimplus/examples/ParallelSimulationsExample.java index 0116d82..5c82994 100755 --- a/src/main/java/org/cloudsimplus/examples/ParallelSimulationsExample.java +++ b/src/main/java/org/cloudsimplus/examples/ParallelSimulationsExample.java @@ -47,33 +47,31 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to run two simulation scenarios with different configurations - * in parallel, using the CloudSim Plus exclusive features and - * Java 8 Lambda Expressions and Parallel Streams. - * The parallel execution of simulations doesn't ensure that the overall execution time will be reduced. - * It depends on diverse factors such as the number of simulations, the tasks that each simulation - * executes, the number of available physical CPUs at your machine, etc. - * - *

      This is just a minimal example that runs 2 simulations with different number - * of Hosts, VMs and Cloudlets. However, all these objects will have the same configurations - * in the different simulations. There will be just a difference in the number of created - * objects.

      - * - *

      To enable such a parallel simulations execution, the logging must be - * disable (as shown in the first line of the main method) and any console - * output should be avoided during simulation execution. - * Further, usage of static mutable attributes must be avoided. - * All simulation attributes must be instance attributes and one - * simulation run (a simulation instance) should not share data with other ones.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - */ +/// An example showing how to run two simulation scenarios with different configurations +/// in parallel, using the CloudSim Plus exclusive features and +/// [Java 8 Lambda Expressions and Parallel Streams](https://www.oracle.com/technical-resources/articles/java/ma14-java-se-8-streams.html). +/// The parallel execution of simulations doesn't ensure that the overall execution time will be reduced. +/// It depends on diverse factors such as the number of simulations, the tasks that each simulation +/// executes, the number of available physical CPUs at your machine, etc. +/// +/// This is just a minimal example that runs 2 simulations with different number +/// of Hosts, VMs and Cloudlets. However, all these objects will have the same configurations +/// in the different simulations. There will be just a difference in the number of created +/// objects. +/// +/// To enable such a parallel simulations execution, the logging must be +/// disable (as shown in the first line of the main method) and any console +/// output should be avoided during simulation execution. +/// Further, usage of static mutable attributes must be avoided. +/// All simulation attributes must be instance attributes and one +/// simulation run (a simulation instance) should not share data with other ones. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 public class ParallelSimulationsExample implements Runnable { private final String title; private final CloudSimPlus simulation; - /** Created when the simulation is started inside {@link #run()}. */ + /// Created when the simulation is started inside [#run()]. @SuppressWarnings("NullAway.Init") private DatacenterBroker broker; private List cloudletList; @@ -82,11 +80,9 @@ public class ParallelSimulationsExample implements Runnable { private int vmsNumber; private int cloudletsNumber; - /** - * Creates the simulation scenarios with different configurations and execute them, - * printing the results for each one after all simulations have finished. - * @param args - */ + /// Creates the simulation scenarios with different configurations and execute them, + /// printing the results for each one after all simulations have finished. + /// @param args public static void main(String[] args) { /*IT IS MANDATORY TO DISABLE THE LOG WHEN EXECUTING PARALLEL SIMULATIONS TO AVOID RUNTIME EXCEPTIONS.*/ Log.setLevel(Level.OFF); @@ -130,11 +126,9 @@ private void printResults(){ .build(); } - /** - * Default constructor where the simulation is initialized. - * @param title a title for the simulation scenario (just for log purposes) - * @see #run() - */ + /// Default constructor where the simulation is initialized. + /// @param title a title for the simulation scenario (just for log purposes) + /// @see #run() private ParallelSimulationsExample(final String title) { this.title = title; this.cloudletList = new ArrayList<>(); @@ -151,11 +145,9 @@ private List createHosts() { return hostList; } - /** - * Creates a Hosts using a {@link ResourceProvisionerSimple} - * for RAM and BW. - * @return - */ + /// Creates a Hosts using a [ResourceProvisionerSimple] + /// for RAM and BW. + /// @return private Host createHost() { final long mips = 1000; // capacity of each CPU core (in Million Instructions per Second) final long ram = 2048; // host memory (Megabyte) @@ -180,11 +172,9 @@ private void createVms() { broker.submitVmList(vmList); } - /** - * Creates a VM using a {@link CloudletSchedulerTimeShared} by default. - * @param id - * @return - */ + /// Creates a VM using a [CloudletSchedulerTimeShared] by default. + /// @param id + /// @return private Vm createVm(final int id) { final long mips = 1000; final long storage = 10000; // vm image size (Megabyte) @@ -227,9 +217,7 @@ private Cloudlet createCloudlet(final int id) { .setUtilizationModelRam(utilizationModelDynamic); } - /** - * Builds the simulation scenario and starts the simulation. - */ + /// Builds the simulation scenario and starts the simulation. @Override public void run() { final var datacenter0 = new DatacenterSimple(simulation, createHosts()); diff --git a/src/main/java/org/cloudsimplus/examples/RandomVmAllocationPolicyExample.java b/src/main/java/org/cloudsimplus/examples/RandomVmAllocationPolicyExample.java index e13fd37..a5eae5c 100755 --- a/src/main/java/org/cloudsimplus/examples/RandomVmAllocationPolicyExample.java +++ b/src/main/java/org/cloudsimplus/examples/RandomVmAllocationPolicyExample.java @@ -54,20 +54,18 @@ import java.util.List; import java.util.Optional; -/** - * An example showing how to implement a custom - * {@link VmAllocationPolicy} that randomly - * selects suitable Hosts to place submitted VMs. - * Check the {@link #createDatacenter()} method for details. - * - *

      Since CloudSim Plus provides functional - * VmAllocationPolicy implementations, you don't - * even need to create a new class to implement your own policy, - * unless you really want to (to make reuse easy).

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.0.5 - */ +/// An example showing how to implement a custom +/// [VmAllocationPolicy] that randomly +/// selects suitable Hosts to place submitted VMs. +/// Check the [#createDatacenter()] method for details. +/// +/// Since CloudSim Plus provides functional +/// VmAllocationPolicy implementations, you don't +/// even need to create a new class to implement your own policy, +/// unless you really want to (to make reuse easy). +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.0.5 public class RandomVmAllocationPolicyExample { private static final int HOSTS = 10; private static final int HOST_PES = 8; @@ -85,10 +83,9 @@ public class RandomVmAllocationPolicyExample { private List cloudletList; private Datacenter datacenter0; - /** A random number generator that returns values between [-1 .. 1], - * according to the {@link Comparator#compare(Object, Object)} method used - * to randomly sort Hosts to be allocated to VMs. - */ + /// A random number generator that returns values between \[-1 .. 1\], + /// according to the [Comparator#compare(Object,Object)] method used + /// to randomly sort Hosts to be allocated to VMs. private final ContinuousDistribution random; public static void main(String[] args) { @@ -121,11 +118,9 @@ private RandomVmAllocationPolicyExample() { System.out.println("Execution time: " + TimeUtil.secondsToStr(TimeUtil.elapsedSeconds(startSecs))); } - /** - * Creates a Datacenter and its Hosts, defining - * a {@link VmAllocationPolicy} that randomly selects suitable Hosts - * to place submitted VMs. - */ + /// Creates a Datacenter and its Hosts, defining + /// a [VmAllocationPolicy] that randomly selects suitable Hosts + /// to place submitted VMs. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -141,16 +136,14 @@ private Datacenter createDatacenter() { return new DatacenterSimple(simulation, hostList, vmAllocationPolicy); } - /** - * Define a specific policy to randomly select a suitable Host to place a given VM. - * It's a very efficient policy since it doesn't perform sorting - * in order to find a suitable Host. - * - * @param vmAllocationPolicy the {@link VmAllocationPolicy} containing Host allocation information - * @param vm the {@link Vm} to find a host to be placed - * @return an {@link Optional} that may contain a Host in which to place a Vm, or an {@link Optional#empty()} - * {@link Optional} if not suitable Host was found. - */ + /// Define a specific policy to randomly select a suitable Host to place a given VM. + /// It's a very efficient policy since it doesn't perform sorting + /// in order to find a suitable Host. + /// + /// @param vmAllocationPolicy the [VmAllocationPolicy] containing Host allocation information + /// @param vm the [Vm] to find a host to be placed + /// @return an [Optional] that may contain a Host in which to place a Vm, or an [Optional#empty()] + /// [Optional] if not suitable Host was found. private Optional findRandomSuitableHostForVm(final VmAllocationPolicy vmAllocationPolicy, final Vm vm) { final var hostList = vmAllocationPolicy.getHostList(); /* Despite the loop is bound to the number of Hosts inside the List, @@ -186,9 +179,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var list = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -203,9 +194,7 @@ private List createVms() { return list; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var list = new ArrayList(CLOUDLETS); final var utilization = new UtilizationModelDynamic(0.2); diff --git a/src/main/java/org/cloudsimplus/examples/ReducedExample.java b/src/main/java/org/cloudsimplus/examples/ReducedExample.java index 41b19cc..14d42ed 100755 --- a/src/main/java/org/cloudsimplus/examples/ReducedExample.java +++ b/src/main/java/org/cloudsimplus/examples/ReducedExample.java @@ -33,24 +33,22 @@ import org.cloudsimplus.utilizationmodels.UtilizationModelDynamic; import org.cloudsimplus.vms.VmSimple; -/** - * An example showing the very minimal code required to create - * a simulation scenario in CloudSim Plus. - * - *

      NOTICE: This example is not intended to be reused and we strongly advise - * against doing that. Since all the code is inside a single method, - * that is completely inappropriate.

      - * - *

      This code is only intended to show how it's simpler - * and easier to create cloud computing simulations using CloudSim Plus.

      - * - *

      If you want a basic, but organized and reusable first example, - * see the {@link BasicFirstExample}.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - * @see BasicFirstExample - */ +/// An example showing the very minimal code required to create +/// a simulation scenario in CloudSim Plus. +/// +/// **NOTICE: This example is not intended to be reused and we strongly advise +/// against doing that. Since all the code is inside a single method, +/// that is completely inappropriate.** +/// +/// This code is only intended to show how it's simpler +/// and easier to create cloud computing simulations using CloudSim Plus. +/// +/// If you want a basic, but organized and reusable first example, +/// see the [BasicFirstExample]. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 +/// @see BasicFirstExample void main() { //tag::cloudsimplus-reduced-example[] //Enables just some level of log messages diff --git a/src/main/java/org/cloudsimplus/examples/StorageAreaNetworkExample1.java b/src/main/java/org/cloudsimplus/examples/StorageAreaNetworkExample1.java index 66a0e66..bf9ac4c 100755 --- a/src/main/java/org/cloudsimplus/examples/StorageAreaNetworkExample1.java +++ b/src/main/java/org/cloudsimplus/examples/StorageAreaNetworkExample1.java @@ -47,19 +47,17 @@ import java.util.ArrayList; import java.util.List; - /** - * An example of how to define a {@link SanStorage Storage Area Network (SAN)} - * for a Datacenter, add files to this SAN and make Cloudlets - * require files from that SAN. - * - *

      Cloudlets' finish time is delayed due to transfer of required files - * from the SAN to the VM. - * The transfer time is computed based on the SAN's bandwidth and - * size of the required files.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.2.6 - */ + /// An example of how to define a [Storage Area Network (SAN)][SanStorage] + /// for a Datacenter, add files to this SAN and make Cloudlets + /// require files from that SAN. + /// + /// Cloudlets' finish time is delayed due to transfer of required files + /// from the SAN to the VM. + /// The transfer time is computed based on the SAN's bandwidth and + /// size of the required files. + /// + /// @author Manoel Campos da Silva Filho + /// @since CloudSim Plus 1.2.6 public class StorageAreaNetworkExample1 { private static final int HOSTS = 2; private static final int HOST_PES = 8; @@ -75,12 +73,9 @@ public class StorageAreaNetworkExample1 { private static long SAN_BANDWIDTH_Mbps = 1; private static long SAN_CAPACITY_MB = 1024 * 1024 * 10; - /** - * A matrix of two rows each one containing an array of sizes - * for different files to be added to a SAN storage. - * Each row contains the sizes of the files for a SAN. - * - */ + /// A matrix of two rows each one containing an array of sizes + /// for different files to be added to a SAN storage. + /// Each row contains the sizes of the files for a SAN. private static int FILE_SIZES_MATRIX_MB[][] = {{1000, 10000, 5000, 25000}, {250000, 35000, 12000, 10000}}; private static int SAN_COUNT = FILE_SIZES_MATRIX_MB.length; @@ -129,11 +124,9 @@ private StorageAreaNetworkExample1() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Creates a {@link SanStorage Storage Area Network (SAN)} array for a Datacenter. - * @return the List of storage devices (the SAN array) - * @see Disk Array - */ + /// Creates a [Storage Area Network (SAN)][SanStorage] array for a Datacenter. + /// @return the List of storage devices (the SAN array) + /// @see Disk Array private List createSanArray() { final var sanStorageList = new ArrayList(SAN_COUNT); int initialFileNumber = 0; @@ -147,15 +140,13 @@ private List createSanArray() { return sanStorageList; } - /** - * Adds a list of files, whose sizes are defined in a given array, - * to a {@link SanStorage}. - * The name of the files will be defined incrementally. - * - * @param san the {@link SanStorage} to add files to - * @param fileSizesMB the array containing the sizes (in MB) of the files. - * @param initialFileNumber the initial number to be used to compute the file numbered name - */ + /// Adds a list of files, whose sizes are defined in a given array, + /// to a [SanStorage]. + /// The name of the files will be defined incrementally. + /// + /// @param san the [SanStorage] to add files to + /// @param fileSizesMB the array containing the sizes (in MB) of the files. + /// @param initialFileNumber the initial number to be used to compute the file numbered name private void addFilesToSanStorage(SanStorage san, int[] fileSizesMB, int initialFileNumber) { File file; for (int i = 0; i < fileSizesMB.length; i++) { @@ -165,18 +156,14 @@ private void addFilesToSanStorage(SanStorage san, int[] fileSizesMB, int initial } } - /** - * Generates a name to be used to a file. - * @param fileNumber the integer index to be appended to a file - * @return the generated filename - */ + /// Generates a name to be used to a file. + /// @param fileNumber the integer index to be appended to a file + /// @return the generated filename private String getFileName(int fileNumber) { return "file"+fileNumber+".txt"; } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -203,9 +190,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var list = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -220,11 +205,9 @@ private List createVms() { return list; } - /** - * Creates a list of Cloudlets, binding it one to a specific VM, - * since the {@link #CLOUDLETS number of Cloudlets} - * is equal to {@link #VMS number of VMs}. - */ + /// Creates a list of Cloudlets, binding it one to a specific VM, + /// since the [number of Cloudlets][#CLOUDLETS] + /// is equal to [number of VMs][#VMS]. private List createCloudlets() { final var list = new ArrayList(CLOUDLETS); final var utilization = new UtilizationModelFull(); diff --git a/src/main/java/org/cloudsimplus/examples/VmAllocationPolicyRoundRobinExample.java b/src/main/java/org/cloudsimplus/examples/VmAllocationPolicyRoundRobinExample.java index 906eef8..3f2cce7 100755 --- a/src/main/java/org/cloudsimplus/examples/VmAllocationPolicyRoundRobinExample.java +++ b/src/main/java/org/cloudsimplus/examples/VmAllocationPolicyRoundRobinExample.java @@ -44,19 +44,17 @@ import java.util.Comparator; import java.util.List; -/** - * An example that show the usage of the {@link VmAllocationPolicyRoundRobin}, - * that cyclically places VMs into Hosts. This way, it places a VM into a Host - * and moves to the next Host. - * All hosts are not powered-on when created. As VMs need to be placed, - * Hosts are activated on demand, as can be checked in the logs. - * - *

      Keep in mind that such a policy is very naive and increases the number of active Hosts, - * leading to higher power consumption.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.4.2 - */ +/// An example that show the usage of the [VmAllocationPolicyRoundRobin], +/// that cyclically places VMs into Hosts. This way, it places a VM into a Host +/// and moves to the next Host. +/// All hosts are not powered-on when created. As VMs need to be placed, +/// Hosts are activated on demand, as can be checked in the logs. +/// +/// Keep in mind that such a policy is very naive and increases the number of active Hosts, +/// leading to higher power consumption. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.4.2 public class VmAllocationPolicyRoundRobinExample { private static final int HOSTS = 4; private static final int HOST_PES = 8; @@ -101,9 +99,7 @@ private VmAllocationPolicyRoundRobinExample() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -133,9 +129,7 @@ private Host createHost() { return new HostSimple(ram, bw, storage, peList, false); } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var list = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -148,9 +142,7 @@ private List createVms() { return list; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var list = new ArrayList(CLOUDLETS); diff --git a/src/main/java/org/cloudsimplus/examples/VmBootTimeAndOverheadExample.java b/src/main/java/org/cloudsimplus/examples/VmBootTimeAndOverheadExample.java index 7673871..eeb648d 100755 --- a/src/main/java/org/cloudsimplus/examples/VmBootTimeAndOverheadExample.java +++ b/src/main/java/org/cloudsimplus/examples/VmBootTimeAndOverheadExample.java @@ -45,13 +45,11 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to define the time for VMs to boot up - * and how the boot process will use resources. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 8.3.0 - */ +/// An example showing how to define the time for VMs to boot up +/// and how the boot process will use resources. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 8.3.0 public class VmBootTimeAndOverheadExample { private static final int HOSTS = 1; private static final int HOST_PES = 8; @@ -67,14 +65,10 @@ public class VmBootTimeAndOverheadExample { private static final int CLOUDLET_PES = 2; private static final int CLOUDLET_LENGTH = 10_000; // Million Instructions (MI) - /** - * Defines the time (in seconds) each VM will take to boot up. - */ + /// Defines the time (in seconds) each VM will take to boot up. private static final double VM_BOOT_DELAY = 5; - /** - * Defines the time (in seconds) each VM will take to shut down. - */ + /// Defines the time (in seconds) each VM will take to shut down. private static final double VM_SHUTDOWN_DELAY = 2; private static final double SCHEDULING_INTERVAL = 1; @@ -127,9 +121,7 @@ private static double getVmRamUsage(final Vm vm) { return vm.getRam().getPercentUtilization() * 100.0; } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -156,11 +148,9 @@ private Host createHost() { return new HostSimple(HOST_RAM, HOST_BW, HOST_STORAGE, peList); } - /** - * Creates a list of VMs setting a {@link BootModel} - * to indicate how the VM will use CPU and RAM during the boot process. - * @see BootModel#BootModel(UtilizationModel, UtilizationModel) - */ + /// Creates a list of VMs setting a [BootModel] + /// to indicate how the VM will use CPU and RAM during the boot process. + /// @see BootModel#BootModel(UtilizationModel, UtilizationModel) private List createVms() { final var vmList = new ArrayList(VMS); final var bootModelCpu = new UtilizationModelDynamic(0.5); @@ -180,9 +170,7 @@ private List createVms() { return vmList; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var cloudletList = new ArrayList(CLOUDLETS); diff --git a/src/main/java/org/cloudsimplus/examples/VmDestructionExample.java b/src/main/java/org/cloudsimplus/examples/VmDestructionExample.java index 077396b..a3c538b 100755 --- a/src/main/java/org/cloudsimplus/examples/VmDestructionExample.java +++ b/src/main/java/org/cloudsimplus/examples/VmDestructionExample.java @@ -49,38 +49,34 @@ import java.util.List; import java.util.function.Function; -/** - * Shows how to destroy an overloaded VM during simulation runtime, - * after its CPU usage reaches a defined threshold. - * - *

      The example uses the {@link UtilizationModelDynamic} to - * increase VM CPU usage over time (in seconds). - * This {@link UtilizationModelDynamic} relies on a {@link Function} - * to increase resource usage. Such a Function is defined using a Lambda Expression.

      - * - *

      It shows Host CPU utilization every second, so that when the overloaded VM - * is destroyed, we can check the Host CPU utilization reduces.

      - * - *

      Lambda Expressions and Functional Interfaces are Java 8+ features. - * If you don't know what these features are, I suggest checking out this - * tutorial

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.3.0 - */ +/// Shows how to destroy an overloaded VM during simulation runtime, +/// after its CPU usage reaches a defined threshold. +/// +/// The example uses the [UtilizationModelDynamic] to +/// increase VM CPU usage over time (in seconds). +/// This [UtilizationModelDynamic] relies on a [Function] +/// to increase resource usage. Such a Function is defined using a Lambda Expression. +/// +/// It shows Host CPU utilization every second, so that when the overloaded VM +/// is destroyed, we can check the Host CPU utilization reduces. +/// +/// **Lambda Expressions and Functional Interfaces are Java 8+ features.** +/// If you don't know what these features are, I suggest checking out this +/// [tutorial](http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html) +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.3.0 public class VmDestructionExample { - /** - * Defines, between other things, the time intervals - * to update the processing of simulation events. - * This way, simulation clock increases according to this time. - * Since a {@link UtilizationModelDynamic} is being used to define CPU usage of VMs, - * the utilization is updated at this time interval. - * - * Setting the Datacenter scheduling interval is required to allow - * the CPU utilization to increase along the simulation execution. - * - * @see Datacenter#setSchedulingInterval(double) - */ + /// Defines, between other things, the time intervals + /// to update the processing of simulation events. + /// This way, simulation clock increases according to this time. + /// Since a [UtilizationModelDynamic] is being used to define CPU usage of VMs, + /// the utilization is updated at this time interval. + /// + /// Setting the Datacenter scheduling interval is required to allow + /// the CPU utilization to increase along the simulation execution. + /// + /// @see Datacenter#setSchedulingInterval(double) private static final int SCHEDULING_INTERVAL = 1; private static final int HOSTS = 1; @@ -133,15 +129,13 @@ private VmDestructionExample() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Tracks the update of execution for a VM. - * If that VM is overloaded then destroys it. - * In this example, this {@link EventListener} is just - * attached for VM 1, therefore, just such a VM will be destroyed - * if overloaded. - * - * @param info event information, including the VM that was updated - */ + /// Tracks the update of execution for a VM. + /// If that VM is overloaded then destroys it. + /// In this example, this [EventListener] is just + /// attached for VM 1, therefore, just such a VM will be destroyed + /// if overloaded. + /// + /// @param info event information, including the VM that was updated private void vmProcessingUpdateListener(VmHostEventInfo info) { final Vm vm = info.getVm(); //Destroys VM 1 when its CPU usage reaches 90% @@ -155,9 +149,7 @@ private void vmProcessingUpdateListener(VmHostEventInfo info) { datacenter0.getHostList().forEach(h -> System.out.printf("# %.2f: %s CPU Utilization %.2f%%%n", info.getTime(), h, h.getCpuPercentUtilization()*100)); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -191,9 +183,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var list = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -208,9 +198,7 @@ private List createVms() { return list; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var list = new ArrayList(CLOUDLETS); final var utilization = new UtilizationModelFull(); @@ -219,10 +207,8 @@ private List createCloudlets() { * It is used to define the CPU usage of VMs dynamically.*/ final var dynamicUtilization = new UtilizationModelDynamic(); - /** - * Sets a {@link Function} that enables the utilization model to increment resource usage by 10% over time. - * This function is defined using a Lambda Expression. - */ + /// Sets a [Function] that enables the utilization model to increment resource usage by 10% over time. + /// This function is defined using a Lambda Expression. dynamicUtilization.setUtilizationUpdateFunction(um -> um.getUtilization() + um.getTimeSpan()*0.1); for (int i = 0; i < CLOUDLETS; i++) { diff --git a/src/main/java/org/cloudsimplus/examples/VmGroupPlacementExample1.java b/src/main/java/org/cloudsimplus/examples/VmGroupPlacementExample1.java index 15c5e44..8116efb 100755 --- a/src/main/java/org/cloudsimplus/examples/VmGroupPlacementExample1.java +++ b/src/main/java/org/cloudsimplus/examples/VmGroupPlacementExample1.java @@ -46,27 +46,21 @@ import java.util.Comparator; import java.util.List; -/** - * An example showing how to submit {@link VmGroup groups of VMs} to a broker - * to try placing all VMs belonging to a group into the same Host. - * It creates two groups but there is no Host - * with enough capacity to place all VMs from the second group. - * This way, only VMs from the first group are created. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.6.0 - */ +/// An example showing how to submit [groups of VMs][VmGroup] to a broker +/// to try placing all VMs belonging to a group into the same Host. +/// It creates two groups but there is no Host +/// with enough capacity to place all VMs from the second group. +/// This way, only VMs from the first group are created. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.6.0 public class VmGroupPlacementExample1 { private static final int HOSTS = 4; - /** - * Number of {@link VmGroup} to create. - */ + /// Number of [VmGroup] to create. private static final int GROUPS = 2; - /** - * Number of {@link Vm}s in each {@link VmGroup}. - */ + /// Number of [Vm]s in each [VmGroup]. private static final int VMS_BY_GROUP = 2; @@ -85,9 +79,7 @@ public class VmGroupPlacementExample1 { private final CloudSimPlus simulation; private final DatacenterBroker broker0; - /** - * A {@link VmGroup} containing a List of VM to try to place them into the same Host. - */ + /// A [VmGroup] containing a List of VM to try to place them into the same Host. private final List vmGroupList; private final List cloudletList; private final Datacenter datacenter0; @@ -126,9 +118,7 @@ private VmGroupPlacementExample1() { .build(); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 1; i <= HOSTS; i++) { @@ -162,10 +152,8 @@ private Host createHost(final long id, final int pes) { return host; } - /** - * Creates a list of {@link VmGroup}s. - * Each group contains a List of VMs to try to place them into the same Host. - */ + /// Creates a list of [VmGroup]s. + /// Each group contains a List of VMs to try to place them into the same Host. private List createVmGroupList() { final var vmGroupList = new ArrayList(GROUPS); for (int i = 0; i < GROUPS; i++) { @@ -187,10 +175,8 @@ private List createVms() { return vmList; } - /** - * Creates a list of Cloudlets for a given group of VMs. - * @param group - */ + /// Creates a list of Cloudlets for a given group of VMs. + /// @param group private void createCloudlets(final VmGroup group) { //UtilizationModel defining the Cloudlets use only 10% of RAM and BW all the time final var utilizationModelRamBw = new UtilizationModelDynamic(0.1); diff --git a/src/main/java/org/cloudsimplus/examples/autoscaling/LoadBalancerByHorizontalVmScalingExample.java b/src/main/java/org/cloudsimplus/examples/autoscaling/LoadBalancerByHorizontalVmScalingExample.java index 55bae0c..c7b8b17 100755 --- a/src/main/java/org/cloudsimplus/examples/autoscaling/LoadBalancerByHorizontalVmScalingExample.java +++ b/src/main/java/org/cloudsimplus/examples/autoscaling/LoadBalancerByHorizontalVmScalingExample.java @@ -58,58 +58,49 @@ import static java.util.Comparator.comparingDouble; -/** - * An example that balances load by dynamically creating VMs, - * according to the arrival of Cloudlets. - * Cloudlets are {@link #createNewCloudlets(EventInfo) dynamically created and submitted to the broker - * at specific time intervals}. - * - *

      A {@link HorizontalVmScalingSimple} - * is set to each {@link #createListOfScalableVms(int) initially created VM}, - * that will check at {@link #SCHEDULING_INTERVAL specific time intervals} - * if the VM {@link #isVmOverloaded(Vm) is overloaded or not} to then - * request the creation of a new VM to attend arriving Cloudlets.

      - * - *

      The example uses CloudSim Plus {@link EventListener} feature - * to enable monitoring the simulation and dynamically creating objects such as Cloudlets and VMs. - * It relies on - * Java 8 Lambda Expressions - * to set a Listener for the {@link Simulation#addOnClockTickListener(EventListener) onClockTick event}. - * That Listener gets notified every time the simulation clock advances and then creates and submits new Cloudlets. - *

      - * - *

      The {@link DatacenterBroker} is accountable to perform horizontal down scaling. - * The down scaling is enabled by setting a {@link Function} using the {@link DatacenterBroker#setVmDestructionDelayFunction(Function)}. - * This Function defines the time the broker has to wait to destroy a VM after it becomes idle. - * If no Function is set, the broker just destroys VMs after all running Cloudlets are finished - * and there is no Cloudlet waiting to be created. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - */ +/// An example that balances load by dynamically creating VMs, +/// according to the arrival of Cloudlets. +/// Cloudlets are [dynamically created and submitted to the broker at specific time intervals][#createNewCloudlets(EventInfo)]. +/// +/// A [HorizontalVmScalingSimple] +/// is set to each [initially created VM][#createListOfScalableVms(int)], +/// that will check at [specific time intervals][#SCHEDULING_INTERVAL] +/// if the VM [is overloaded or not][#isVmOverloaded(Vm)] to then +/// request the creation of a new VM to attend arriving Cloudlets. +/// +/// The example uses CloudSim Plus [EventListener] feature +/// to enable monitoring the simulation and dynamically creating objects such as Cloudlets and VMs. +/// It relies on +/// [Java 8 Lambda Expressions](http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html) +/// to set a Listener for the [onClockTick event][Simulation#addOnClockTickListener(EventListener)]. +/// That Listener gets notified every time the simulation clock advances and then creates and submits new Cloudlets. +/// +/// The [DatacenterBroker] is accountable to perform horizontal down scaling. +/// The down scaling is enabled by setting a [Function] using the [DatacenterBroker#setVmDestructionDelayFunction(Function)]. +/// This Function defines the time the broker has to wait to destroy a VM after it becomes idle. +/// If no Function is set, the broker just destroys VMs after all running Cloudlets are finished +/// and there is no Cloudlet waiting to be created. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 public class LoadBalancerByHorizontalVmScalingExample { - /** - * The interval in which the Datacenter will schedule events. - * As lower is this interval, sooner the processing of VMs and Cloudlets - * is updated and you will get more notifications about the simulation execution. - * However, that also affect the simulation performance. - * - *

      A large schedule interval, such as 15, will make that just - * at every 15 seconds the processing of VMs is updated. If a VM is overloaded, just - * after this time the creation of a new one will be requested - * by the VM's {@link HorizontalVmScaling Horizontal Scaling} mechanism.

      - * - *

      If this interval is defined using a small value, you may get - * more dynamically created VMs than expected. - * Accordingly, this value has to be trade-off. - * For more details, see {@link Datacenter#getSchedulingInterval()}.

      - */ + /// The interval in which the Datacenter will schedule events. + /// As lower is this interval, sooner the processing of VMs and Cloudlets + /// is updated and you will get more notifications about the simulation execution. + /// However, that also affect the simulation performance. + /// + /// A large schedule interval, such as 15, will make that just + /// at every 15 seconds the processing of VMs is updated. If a VM is overloaded, just + /// after this time the creation of a new one will be requested + /// by the VM's [Horizontal Scaling][HorizontalVmScaling] mechanism. + /// + /// If this interval is defined using a small value, you may get + /// more dynamically created VMs than expected. + /// Accordingly, this value has to be trade-off. + /// For more details, see [Datacenter#getSchedulingInterval()]. private static final int SCHEDULING_INTERVAL = 5; - /** - * The interval to request the creation of new Cloudlets. - */ + /// The interval to request the creation of new Cloudlets. private static final int CLOUDLETS_CREATION_INTERVAL = SCHEDULING_INTERVAL * 2; private static final int HOSTS = 50; @@ -123,9 +114,7 @@ public class LoadBalancerByHorizontalVmScalingExample { private final List vmList; private final List cloudletList; - /** - * Different lengths that will be randomly assigned to created Cloudlets. - */ + /// Different lengths that will be randomly assigned to created Cloudlets. private static final long[] CLOUDLET_LENGTHS = {2000, 4000, 10000, 16000, 2000, 30000, 20000}; private final ContinuousDistribution rand; @@ -136,9 +125,7 @@ public static void main(String[] args) { new LoadBalancerByHorizontalVmScalingExample(); } - /** - * Default constructor that builds the simulation scenario and starts the simulation. - */ + /// Default constructor that builds the simulation scenario and starts the simulation. private LoadBalancerByHorizontalVmScalingExample() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -158,14 +145,12 @@ private LoadBalancerByHorizontalVmScalingExample() { dc0 = createDatacenter(); broker0 = new DatacenterBrokerSimple(simulation); - /** - * Defines the Vm Destruction Delay Function as a lambda expression - * so that the broker will wait 10 seconds before destroying any idle VM. - * By commenting this line, no down scaling will be performed - * and idle VMs will be destroyed just after all running Cloudlets - * are finished and there is no waiting Cloudlet. - * @see DatacenterBroker#setVmDestructionDelayFunction(Function) - * */ + /// Defines the Vm Destruction Delay Function as a lambda expression + /// so that the broker will wait 10 seconds before destroying any idle VM. + /// By commenting this line, no down scaling will be performed + /// and idle VMs will be destroyed just after all running Cloudlets + /// are finished and there is no waiting Cloudlet. + /// @see DatacenterBroker#setVmDestructionDelayFunction(Function) broker0.setVmDestructionDelay(10.0); vmList.addAll(createListOfScalableVms(VMS)); @@ -194,14 +179,12 @@ private void createCloudletList() { } } - /** - * Creates new Cloudlets at every {@link #CLOUDLETS_CREATION_INTERVAL} seconds, up to the 50th simulation second. - * A reference to this method is set as the {@link EventListener} - * to the {@link Simulation#addOnClockTickListener(EventListener)}. - * The method is called every time the simulation clock advances. - * - * @param info the information about the OnClockTick event that has happened - */ + /// Creates new Cloudlets at every [#CLOUDLETS_CREATION_INTERVAL] seconds, up to the 50th simulation second. + /// A reference to this method is set as the [EventListener] + /// to the [Simulation#addOnClockTickListener(EventListener)]. + /// The method is called every time the simulation clock advances. + /// + /// @param info the information about the OnClockTick event that has happened private void createNewCloudlets(final EventInfo info) { final long time = (long) info.getTime(); if (time % CLOUDLETS_CREATION_INTERVAL == 0 && time <= 50) { @@ -218,9 +201,7 @@ private void createNewCloudlets(final EventInfo info) { } } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { for (int i = 0; i < HOSTS; i++) { hostList.add(createHost()); @@ -244,14 +225,12 @@ private Host createHost() { .setVmScheduler(new VmSchedulerTimeShared()); } - /** - * Creates a list of initial VMs in which each VM is able to scale horizontally - * when it is overloaded. - * - * @param vmsNumber number of VMs to create - * @return the list of scalable VMs - * @see #createHorizontalVmScaling(Vm) - */ + /// Creates a list of initial VMs in which each VM is able to scale horizontally + /// when it is overloaded. + /// + /// @param vmsNumber number of VMs to create + /// @return the list of scalable VMs + /// @see #createHorizontalVmScaling(Vm) private List createListOfScalableVms(final int vmsNumber) { final var newVmList = new ArrayList(vmsNumber); for (int i = 0; i < vmsNumber; i++) { @@ -263,12 +242,10 @@ private List createListOfScalableVms(final int vmsNumber) { return newVmList; } - /** - * Creates a {@link HorizontalVmScaling} object for a given VM. - * - * @param vm the VM for which the Horizontal Scaling will be created - * @see #createListOfScalableVms(int) - */ + /// Creates a [HorizontalVmScaling] object for a given VM. + /// + /// @param vm the VM for which the Horizontal Scaling will be created + /// @see #createListOfScalableVms(int) private void createHorizontalVmScaling(final Vm vm) { final var horizontalScaling = new HorizontalVmScalingSimple(); horizontalScaling @@ -277,24 +254,20 @@ private void createHorizontalVmScaling(final Vm vm) { vm.setHorizontalScaling(horizontalScaling); } - /** - * A {@link Predicate} that checks if a given VM is overloaded or not, - * based on upper CPU utilization threshold. - * A reference to this method is assigned to each {@link HorizontalVmScaling} created. - * - * @param vm the VM to check if it is overloaded - * @return true if the VM is overloaded, false otherwise - * @see #createHorizontalVmScaling(Vm) - */ + /// A [Predicate] that checks if a given VM is overloaded or not, + /// based on upper CPU utilization threshold. + /// A reference to this method is assigned to each [HorizontalVmScaling] created. + /// + /// @param vm the VM to check if it is overloaded + /// @return true if the VM is overloaded, false otherwise + /// @see #createHorizontalVmScaling(Vm) private boolean isVmOverloaded(final Vm vm) { return vm.getCpuPercentUtilization() > 0.7; } - /** - * Creates a Vm object. - * - * @return the created Vm - */ + /// Creates a Vm object. + /// + /// @return the created Vm private Vm createVm() { final int id = createsVms++; return new VmSimple(id, 1000, 2) diff --git a/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmCpuScalingDynamicThreshold.java b/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmCpuScalingDynamicThreshold.java index 6ec58fe..e121948 100755 --- a/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmCpuScalingDynamicThreshold.java +++ b/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmCpuScalingDynamicThreshold.java @@ -61,44 +61,39 @@ import static java.util.Comparator.comparingDouble; -/** - * An example that scales VM PEs up or down, according to the arrival of Cloudlets. - * A {@link VerticalVmScaling} - * is set to each {@link #createListOfScalableVms(int) initially created VM}. - * Every VM will check at {@link #SCHEDULING_INTERVAL specific time intervals} - * if its PEs {@link #upperCpuUtilizationThreshold(Vm) are over or underloaded}, - * according to a dynamic computed utilization threshold. - * Then it requests such PEs to be up or down scaled. - * - *

      The example uses the CloudSim Plus {@link EventListener} feature - * to enable monitoring the simulation and dynamically create objects such as Cloudlets and VMs at runtime. - * It relies on - * Java 8 Method References - * to set a method to be called for {@link Simulation#addOnClockTickListener(EventListener) onClockTick events}. - * It enables getting notifications when the simulation clock advances, then creating and submitting new cloudlets. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 2.2.1 - * @see VerticalVmCpuScalingExample - */ +/// An example that scales VM PEs up or down, according to the arrival of Cloudlets. +/// A [VerticalVmScaling] +/// is set to each [initially created VM][#createListOfScalableVms(int)]. +/// Every VM will check at [specific time intervals][#SCHEDULING_INTERVAL] +/// if its PEs [are over or underloaded][#upperCpuUtilizationThreshold(Vm)], +/// according to a **dynamic computed utilization threshold**. +/// Then it requests such PEs to be up or down scaled. +/// +/// The example uses the CloudSim Plus [EventListener] feature +/// to enable monitoring the simulation and dynamically create objects such as Cloudlets and VMs at runtime. +/// It relies on +/// [Java 8 Method References](https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html) +/// to set a method to be called for [onClockTick events][Simulation#addOnClockTickListener(EventListener)]. +/// It enables getting notifications when the simulation clock advances, then creating and submitting new cloudlets. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 2.2.1 +/// @see VerticalVmCpuScalingExample public class VerticalVmCpuScalingDynamicThreshold { - /** - * The interval in which the Datacenter will schedule events. - * As lower is this interval, sooner the processing of VMs and Cloudlets - * is updated and you will get more notifications about the simulation execution. - * However, it can affect the simulation performance. - * - *

      For this example, a large schedule interval such as 15 will make that just - * at every 15 seconds the processing of VMs is updated. If a VM is overloaded, just - * after this time the creation of a new one will be requested - * by the VM's {@link HorizontalVmScaling Horizontal Scaling} mechanism.

      - * - *

      If this interval is defined using a small value, you may get - * more dynamically created VMs than expected. Accordingly, this value - * has to be trade-off. - * For more details, see {@link Datacenter#getSchedulingInterval()}.

      - */ + /// The interval in which the Datacenter will schedule events. + /// As lower is this interval, sooner the processing of VMs and Cloudlets + /// is updated and you will get more notifications about the simulation execution. + /// However, it can affect the simulation performance. + /// + /// For this example, a large schedule interval such as 15 will make that just + /// at every 15 seconds the processing of VMs is updated. If a VM is overloaded, just + /// after this time the creation of a new one will be requested + /// by the VM's [Horizontal Scaling][HorizontalVmScaling] mechanism. + /// + /// If this interval is defined using a small value, you may get + /// more dynamically created VMs than expected. Accordingly, this value + /// has to be trade-off. + /// For more details, see [Datacenter#getSchedulingInterval()]. private static final int SCHEDULING_INTERVAL = 1; private static final int HOSTS = 1; @@ -121,9 +116,7 @@ public static void main(String[] args) { new VerticalVmCpuScalingDynamicThreshold(); } - /** - * Default constructor that builds the simulation scenario and starts the simulation. - */ + /// Default constructor that builds the simulation scenario and starts the simulation. private VerticalVmCpuScalingDynamicThreshold() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -150,10 +143,8 @@ private VerticalVmCpuScalingDynamicThreshold() { printSimulationResults(); } - /** - * Shows updates every time the simulation clock advances. - * @param evt information about the event happened (that for this Listener is just the simulation time) - */ + /// Shows updates every time the simulation clock advances. + /// @param evt information about the event happened (that for this Listener is just the simulation time) private void onClockTickListener(EventInfo evt) { vmList.forEach(vm -> { System.out.printf( @@ -174,9 +165,7 @@ private void printSimulationResults() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private void createDatacenter() { for (int i = 0; i < HOSTS; i++) { hostList.add(createHost()); @@ -202,14 +191,12 @@ private Host createHost() { .setVmScheduler(new VmSchedulerTimeShared()); } - /** - * Creates a list of initial VMs in which each VM is able to scale vertically - * when it is over or underloaded. - * - * @param numberOfVms number of VMs to create - * @return the list of scalable VMs - * @see #createVerticalPeScaling() - */ + /// Creates a list of initial VMs in which each VM is able to scale vertically + /// when it is over or underloaded. + /// + /// @param numberOfVms number of VMs to create + /// @return the list of scalable VMs + /// @see #createVerticalPeScaling() private List createListOfScalableVms(final int numberOfVms) { List newList = new ArrayList<>(numberOfVms); for (int i = 0; i < numberOfVms; i++) { @@ -221,13 +208,11 @@ private List createListOfScalableVms(final int numberOfVms) { return newList; } - /** - * Creates a Vm object, enabling it to store - * CPU utilization history which is used - * to compute a dynamic threshold for CPU vertical scaling. - * - * @return the created Vm - */ + /// Creates a Vm object, enabling it to store + /// CPU utilization history which is used + /// to compute a dynamic threshold for CPU vertical scaling. + /// + /// @return the created Vm private Vm createVm() { final int id = createsVms++; @@ -237,26 +222,21 @@ private Vm createVm() { return vm; } - /** - * Creates a {@link VerticalVmScaling} for scaling VM's CPU when it's under or overloaded. - * - *

      Realize the lower and upper thresholds are defined inside this method by using - * references to the methods {@link #lowerCpuUtilizationThreshold(Vm)} - * and {@link #upperCpuUtilizationThreshold(Vm)}. - * These methods enable defining thresholds in a dynamic way - * and even different thresholds for distinct VMs. - * Therefore, it's a powerful mechanism. - *

      - * - *

      - * However, if you are defining thresholds in a static way, - * and they are the same for all VMs, you can use a Lambda Expression - * like below, for instance, instead of creating a new method that just returns a constant value:
      - * {@code verticalCpuScaling.setLowerThresholdFunction(vm -> 0.4);} - *

      - * - * @see #createListOfScalableVms(int) - */ + /// Creates a [VerticalVmScaling] for scaling VM's CPU when it's under or overloaded. + /// + /// Realize the lower and upper thresholds are defined inside this method by using + /// references to the methods [#lowerCpuUtilizationThreshold(Vm)] + /// and [#upperCpuUtilizationThreshold(Vm)]. + /// These methods enable defining thresholds in a dynamic way + /// and even different thresholds for distinct VMs. + /// Therefore, it's a powerful mechanism. + /// + /// However, if you are defining thresholds in a static way, + /// and they are the same for all VMs, you can use a Lambda Expression + /// like below, for instance, instead of creating a new method that just returns a constant value:
      + /// `verticalCpuScaling.setLowerThresholdFunction(vm -> 0.4);` + /// + /// @see #createListOfScalableVms(int) private VerticalVmScaling createVerticalPeScaling() { //The percentage in which the number of PEs has to be scaled final double scalingFactor = 0.1; @@ -270,18 +250,17 @@ private VerticalVmScaling createVerticalPeScaling() { */ //verticalCpuScaling.setResourceScaling(new ResourceScalingInstantaneous()); - /** Different from the commented line above, the line below implements a ResourceScaling using a Lambda Expression. - * It is just an example which scales the resource twice the amount defined by the scaling factor - * defined in the constructor. - * - * Realize that if the setResourceScaling method is not called, a ResourceScalingGradual will be used, - * which scales the resource according to the scaling factor. - * The lower and upper thresholds after this line can also be defined using a Lambda Expression. - * - * So, here we are defining our own {@link ResourceScaling} instead of - * using the available ones such as the {@link ResourceScalingGradual} - * or {@link ResourceScalingInstantaneous}. - */ + /// Different from the commented line above, the line below implements a ResourceScaling using a Lambda Expression. + /// It is just an example which scales the resource twice the amount defined by the scaling factor + /// defined in the constructor. + /// + /// Realize that if the setResourceScaling method is not called, a ResourceScalingGradual will be used, + /// which scales the resource according to the scaling factor. + /// The lower and upper thresholds after this line can also be defined using a Lambda Expression. + /// + /// So, here we are defining our own [ResourceScaling] instead of + /// using the available ones such as the [ResourceScalingGradual] + /// or [ResourceScalingInstantaneous]. verticalCpuScaling.setResourceScaling(vs -> 2*vs.getScalingFactor()*vs.getAllocatedResource()); verticalCpuScaling.setLowerThresholdFunction(this::lowerCpuUtilizationThreshold); @@ -290,49 +269,43 @@ private VerticalVmScaling createVerticalPeScaling() { return verticalCpuScaling; } - /** - * Defines the minimum CPU utilization percentage that indicates a Vm is underloaded. - * This function is using a statically defined threshold, but it would be defined - * a dynamic threshold based on any condition you want. - * A reference to this method is assigned to each Vertical VM Scaling created. - * - * @param vm the VM to check if its CPU is underloaded. - * The parameter is not being used internally, which means the same - * threshold is used for any Vm. - * @return the lower CPU utilization threshold - * @see #createVerticalPeScaling() - */ + /// Defines the minimum CPU utilization percentage that indicates a Vm is underloaded. + /// This function is using a statically defined threshold, but it would be defined + /// a dynamic threshold based on any condition you want. + /// A reference to this method is assigned to each Vertical VM Scaling created. + /// + /// @param vm the VM to check if its CPU is underloaded. + /// **The parameter is not being used internally, which means the same + /// threshold is used for any Vm.** + /// @return the lower CPU utilization threshold + /// @see #createVerticalPeScaling() private double lowerCpuUtilizationThreshold(final Vm vm) { return 0.4; } - /** - * Defines a dynamic CPU utilization threshold that indicates a Vm is overloaded. - * Such a threshold is the maximum CPU a VM can use before requesting vertical CPU scaling. - * A reference to this method is assigned to each Vertical VM Scaling created. - * - *

      The dynamic upper threshold is defined as 20% above the mean (mean * 1.2), - * if there are at least 10 CPU utilization history entries. - * That means if the CPU utilization of a VM is 20% above its mean - * CPU utilization, it indicates the VM is overloaded. - * If there aren't enough history entries, - * it defines a static threshold as 70% of CPU utilization.

      - * - * @param vm the VM to check if its CPU is overloaded. - * The parameter is not being used internally, that means the same - * threshold is used for any Vm. - * @return the upper dynamic CPU utilization threshold - * @see #createVerticalPeScaling() - */ + /// Defines a dynamic CPU utilization threshold that indicates a Vm is overloaded. + /// Such a threshold is the maximum CPU a VM can use before requesting vertical CPU scaling. + /// A reference to this method is assigned to each Vertical VM Scaling created. + /// + /// The dynamic upper threshold is defined as 20% above the mean (mean * 1.2), + /// if there are at least 10 CPU utilization history entries. + /// That means if the CPU utilization of a VM is 20% above its mean + /// CPU utilization, it indicates the VM is overloaded. + /// If there aren't enough history entries, + /// it defines a static threshold as 70% of CPU utilization. + /// + /// @param vm the VM to check if its CPU is overloaded. + /// The parameter is not being used internally, that means the same + /// threshold is used for any Vm. + /// @return the upper dynamic CPU utilization threshold + /// @see #createVerticalPeScaling() private double upperCpuUtilizationThreshold(final Vm vm) { return vm.getCpuUtilizationStats().count() > 10 ? vm.getCpuUtilizationStats().getMean() * 1.2 : 0.7; } - /** - * Creates lists of Cloudlets to be submitted to the broker with different delays, - * simulating their arrivals at different times. - * Adds all created Cloudlets to the {@link #cloudletList}. - */ + /// Creates lists of Cloudlets to be submitted to the broker with different delays, + /// simulating their arrivals at different times. + /// Adds all created Cloudlets to the [#cloudletList]. private void createCloudletListsWithDifferentDelays() { final int initialCloudletsNumber = (int)(CLOUDLETS/2.5); final int remainingCloudletsNumber = CLOUDLETS-initialCloudletsNumber; @@ -357,26 +330,22 @@ private void createCloudletListsWithDifferentDelays() { } } - /** - * Creates a single Cloudlet with no delay, which means the Cloudlet arrival time will - * be zero (exactly when the simulation starts). - * - * @param length the Cloudlet length - * @param pesNumber the number of PEs the Cloudlets requires - * @return the created Cloudlet - */ + /// Creates a single Cloudlet with no delay, which means the Cloudlet arrival time will + /// be zero (exactly when the simulation starts). + /// + /// @param length the Cloudlet length + /// @param pesNumber the number of PEs the Cloudlets requires + /// @return the created Cloudlet private Cloudlet createCloudlet(final long length, final int pesNumber) { return createCloudlet(length, pesNumber, 0); } - /** - * Creates a single Cloudlet. - * - * @param length the length of the cloudlet to create. - * @param pesNumber the number of PEs the Cloudlets requires. - * @param delay the delay that defines the arrival time of the Cloudlet at the Cloud infrastructure. - * @return the created Cloudlet - */ + /// Creates a single Cloudlet. + /// + /// @param length the length of the cloudlet to create. + /// @param pesNumber the number of PEs the Cloudlets requires. + /// @param delay the delay that defines the arrival time of the Cloudlet at the Cloud infrastructure. + /// @return the created Cloudlet private Cloudlet createCloudlet(final long length, final int pesNumber, final double delay) { /* Since a VM PE isn't used by two Cloudlets at the same time, @@ -388,18 +357,16 @@ private Cloudlet createCloudlet(final long length, final int pesNumber, final do */ final var utilizationCpu = new UtilizationModelFull(); - /** - * Since BW e RAM are shared resources that don't enable preemption, - * two Cloudlets can't use the same portion of such resources at the same time - * (unless virtual memory is enabled, but such a feature is not available in simulation). - * This way, the total capacity of such resources is being evenly split among created Cloudlets. - * If there are 10 Cloudlets, each one will use just 10% of such resources. - * This value can be defined in different ways, as you want. For instance, some Cloudlets - * can require more resources than other ones. - * To enable that, you would need to instantiate specific {@link UtilizationModelDynamic} for each Cloudlet, - * use a {@link UtilizationModelStochastic} to define resource usage randomly, - * or use any other {@link UtilizationModel} implementation. - */ + /// Since BW e RAM are shared resources that don't enable preemption, + /// two Cloudlets can't use the same portion of such resources at the same time + /// (unless virtual memory is enabled, but such a feature is not available in simulation). + /// This way, the total capacity of such resources is being evenly split among created Cloudlets. + /// If there are 10 Cloudlets, each one will use just 10% of such resources. + /// This value can be defined in different ways, as you want. For instance, some Cloudlets + /// can require more resources than other ones. + /// To enable that, you would need to instantiate specific [UtilizationModelDynamic] for each Cloudlet, + /// use a [UtilizationModelStochastic] to define resource usage randomly, + /// or use any other [UtilizationModel] implementation. final var utilizationModelDynamic = new UtilizationModelDynamic(1.0/CLOUDLETS); final var cl = new CloudletSimple(length, pesNumber); cl.setFileSize(1024) diff --git a/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmCpuScalingExample.java b/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmCpuScalingExample.java index ce820ed..d268bf5 100755 --- a/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmCpuScalingExample.java +++ b/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmCpuScalingExample.java @@ -57,42 +57,37 @@ import static java.util.Comparator.comparingDouble; -/** - * An example that scales VM PEs up or down, according to the arrival of Cloudlets. - * A {@link VerticalVmScaling} - * is set to each {@link #createListOfScalableVms(int) initially created VM}. - * Every VM will check at {@link #SCHEDULING_INTERVAL specific time intervals} - * if its PEs {@link #upperCpuUtilizationThreshold(Vm) are over or underloaded}, - * according to a static computed utilization threshold. - * Then it requests such PEs to be up or down scaled, increasing or decreasing - * the number of PEs. - * - *

      The example uses the CloudSim Plus {@link EventListener} feature - * to enable monitoring the simulation and dynamically create objects such as Cloudlets and VMs at runtime. - * The {@link Simulation#addOnClockTickListener(EventListener) onClockTick listener}. - * enables getting notifications when the simulation clock changes, then creating and submitting new cloudlets. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.2.0 - * @see VerticalVmRamScalingExample - * @see VerticalVmCpuScalingDynamicThreshold - */ +/// An example that scales VM PEs up or down, according to the arrival of Cloudlets. +/// A [VerticalVmScaling] +/// is set to each [initially created VM][#createListOfScalableVms(int)]. +/// Every VM will check at [specific time intervals][#SCHEDULING_INTERVAL] +/// if its PEs [are over or underloaded][#upperCpuUtilizationThreshold(Vm)], +/// according to a **static computed utilization threshold**. +/// Then it requests such PEs to be up or down scaled, increasing or decreasing +/// the number of PEs. +/// +/// The example uses the CloudSim Plus [EventListener] feature +/// to enable monitoring the simulation and dynamically create objects such as Cloudlets and VMs at runtime. +/// The [onClockTick listener][Simulation#addOnClockTickListener(EventListener)]. +/// enables getting notifications when the simulation clock changes, then creating and submitting new cloudlets. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.2.0 +/// @see VerticalVmRamScalingExample +/// @see VerticalVmCpuScalingDynamicThreshold public class VerticalVmCpuScalingExample { - /** - * The interval in which the Datacenter will schedule events (in seconds). - * As lower is this interval, sooner the processing of VMs and Cloudlets is updated, - * resulting in more notifications about the simulation execution. - * However, it can affect the simulation performance. - * - *

      A larger schedule interval makes processing of VMs to be updated less frequently. - * If a VM is overloaded, just after that interval the creation of a new one will be requested - * by the VM's {@link HorizontalVmScaling Horizontal Scaling} mechanism.

      - * - *

      If this interval is defined using a small value, you may get - * more dynamically created VMs than expected. Accordingly, this value has to be trade-off. - * For more details, see {@link Datacenter#getSchedulingInterval()}.

      - */ + /// The interval in which the Datacenter will schedule events (in seconds). + /// As lower is this interval, sooner the processing of VMs and Cloudlets is updated, + /// resulting in more notifications about the simulation execution. + /// However, it can affect the simulation performance. + /// + /// A larger schedule interval makes processing of VMs to be updated less frequently. + /// If a VM is overloaded, just after that interval the creation of a new one will be requested + /// by the VM's [Horizontal Scaling][HorizontalVmScaling] mechanism. + /// + /// If this interval is defined using a small value, you may get + /// more dynamically created VMs than expected. Accordingly, this value has to be trade-off. + /// For more details, see [Datacenter#getSchedulingInterval()]. private static final int SCHEDULING_INTERVAL = 1; private static final int HOSTS = 1; @@ -109,7 +104,7 @@ public class VerticalVmCpuScalingExample { private static final int CLOUDLETS = 10; - /** A base length (in MI) for initially created Cloudlets. */ + /// A base length (in MI) for initially created Cloudlets. private static final int CLOUDLET_LEN_BASE = 80_000; private int createsVms; @@ -118,9 +113,7 @@ public static void main(String[] args) { new VerticalVmCpuScalingExample(); } - /** - * Default constructor that builds the simulation scenario and starts the simulation. - */ + /// Default constructor that builds the simulation scenario and starts the simulation. private VerticalVmCpuScalingExample() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -147,10 +140,8 @@ private VerticalVmCpuScalingExample() { printSimulationResults(); } - /** - * Shows updates every time the simulation clock changes. - * @param evt information about the event happened (that for this Listener is just the simulation time) - */ + /// Shows updates every time the simulation clock changes. + /// @param evt information about the event happened (that for this Listener is just the simulation time) private void onClockTickListener(EventInfo evt) { vmList.forEach(vm -> System.out.printf( @@ -191,14 +182,12 @@ private Host createHost() { return new HostSimple(ram, bw, storage, peList).setVmScheduler(new VmSchedulerTimeShared()); } - /** - * Creates a list of initial VMs in which each VM is able to scale vertically - * when it is over or underloaded. - * - * @param vmsNumber number of VMs to create - * @return the list of scalable VMs - * @see #createVerticalPeScaling() - */ + /// Creates a list of initial VMs in which each VM is able to scale vertically + /// when it is over or underloaded. + /// + /// @param vmsNumber number of VMs to create + /// @return the list of scalable VMs + /// @see #createVerticalPeScaling() private List createListOfScalableVms(final int vmsNumber) { final var newVmList = new ArrayList(vmsNumber); for (int i = 0; i < vmsNumber; i++) { @@ -216,26 +205,21 @@ private Vm createVm() { return new VmSimple(id, VM_MIPS, VM_PES).setRam(VM_RAM).setBw(1000).setSize(10000); } - /** - * Creates a {@link VerticalVmScaling} for scaling VM's CPU when it is under or overloaded. - * - *

      Realize the lower and upper thresholds are defined inside this method by using - * references to the methods {@link #lowerCpuUtilizationThreshold(Vm)} - * and {@link #upperCpuUtilizationThreshold(Vm)}. - * These methods enable defining thresholds in a dynamic way, - * setting different thresholds for distinct VMs. - *

      - * - *

      - * However, if you are defining thresholds in a static way, - * and they are the same for all VMs, you can use a Lambda Expression - * like below, instead of creating a new method that just returns a constant value:
      - * - * {@code verticalCpuScaling.setLowerThresholdFunction(vm -> 0.4);} - *

      - * - * @see #createListOfScalableVms(int) - */ + /// Creates a [VerticalVmScaling] for scaling VM's CPU when it is under or overloaded. + /// + /// Realize the lower and upper thresholds are defined inside this method by using + /// references to the methods [#lowerCpuUtilizationThreshold(Vm)] + /// and [#upperCpuUtilizationThreshold(Vm)]. + /// These methods enable defining thresholds in a dynamic way, + /// setting different thresholds for distinct VMs. + /// + /// However, if you are defining thresholds in a static way, + /// and they are the same for all VMs, you can use a Lambda Expression + /// like below, instead of creating a new method that just returns a constant value:
      + /// + /// `verticalCpuScaling.setLowerThresholdFunction(vm -> 0.4);` + /// + /// @see #createListOfScalableVms(int) private VerticalVmScaling createVerticalPeScaling() { //The percentage in which the number of PEs has to be scaled final double scalingFactor = 0.1; @@ -249,17 +233,16 @@ private VerticalVmScaling createVerticalPeScaling() { */ //verticalCpuScaling.setResourceScaling(new ResourceScalingInstantaneous()); - /** Different from the commented line above, the line below implements a ResourceScaling using a Lambda Expression. - * It is just an example which scales the resource twice the amount defined by the scaling factor. - * - * Realize that if the setResourceScaling method isn't called, a ResourceScalingGradual will be used, - * scaling the resource according to the scaling factor. - * The lower and upper thresholds after this line can also be defined using a Lambda Expression. - * - * So, here we are defining our own {@link ResourceScaling} instead of - * using the available ones such as the {@link ResourceScalingGradual} - * or {@link ResourceScalingInstantaneous}. - */ + /// Different from the commented line above, the line below implements a ResourceScaling using a Lambda Expression. + /// It is just an example which scales the resource twice the amount defined by the scaling factor. + /// + /// Realize that if the setResourceScaling method isn't called, a ResourceScalingGradual will be used, + /// scaling the resource according to the scaling factor. + /// The lower and upper thresholds after this line can also be defined using a Lambda Expression. + /// + /// So, here we are defining our own [ResourceScaling] instead of + /// using the available ones such as the [ResourceScalingGradual] + /// or [ResourceScalingInstantaneous]. final double multiplier = 2; verticalCpuScaling.setResourceScaling(vs -> multiplier * vs.getScalingFactor() * vs.getAllocatedResource()) .setLowerThresholdFunction(this::lowerCpuUtilizationThreshold) @@ -268,45 +251,39 @@ private VerticalVmScaling createVerticalPeScaling() { return verticalCpuScaling; } - /** - * Defines the minimum CPU utilization percentage that indicates a Vm is underloaded. - * This function is using a statically defined threshold, but it would be defined - * a dynamic one based on any condition you want. - * A reference to this method is assigned to each {@link VerticalVmScaling} created. - * - * @param vm the VM to check if its CPU is underloaded. - * The parameter is not being used internally, which means the same - * threshold is used for any Vm. - * @return the lower CPU utilization threshold - * @see #createVerticalPeScaling() - */ + /// Defines the minimum CPU utilization percentage that indicates a Vm is underloaded. + /// This function is using a statically defined threshold, but it would be defined + /// a dynamic one based on any condition you want. + /// A reference to this method is assigned to each [VerticalVmScaling] created. + /// + /// @param vm the VM to check if its CPU is underloaded. + /// **The parameter is not being used internally, which means the same + /// threshold is used for any Vm.** + /// @return the lower CPU utilization threshold + /// @see #createVerticalPeScaling() private double lowerCpuUtilizationThreshold(Vm vm) { return 0.4; } - /** - * Defines the maximum CPU utilization percentage that indicates a Vm is overloaded. - * This function is using a statically defined threshold, but it would be defined - * a dynamic one based on any condition you want. - * A reference to this method is assigned to each {@link VerticalVmScaling} created. - * - * @param vm the VM to check if its CPU is overloaded. - * The parameter is not being used internally, that means the same - * threshold is used for any Vm. - * @return the upper CPU utilization threshold - * @see #createVerticalPeScaling() - */ + /// Defines the maximum CPU utilization percentage that indicates a Vm is overloaded. + /// This function is using a statically defined threshold, but it would be defined + /// a dynamic one based on any condition you want. + /// A reference to this method is assigned to each [VerticalVmScaling] created. + /// + /// @param vm the VM to check if its CPU is overloaded. + /// **The parameter is not being used internally, that means the same + /// threshold is used for any Vm.** + /// @return the upper CPU utilization threshold + /// @see #createVerticalPeScaling() private double upperCpuUtilizationThreshold(Vm vm) { return 0.8; } - /** - * Creates several Cloudlets by increasing the arrival delay, - * simulating their arrivals at different times. - * That enables VMs CPU usage to rise gradually, along the arrival of - * new Cloudlets (triggering CPU up scaling at some point in time). - * Check the logs to understand how the scaling is working. - */ + /// Creates several Cloudlets by increasing the arrival delay, + /// simulating their arrivals at different times. + /// That enables VMs CPU usage to rise gradually, along the arrival of + /// new Cloudlets (triggering CPU up scaling at some point in time). + /// Check the logs to understand how the scaling is working. private void createCloudletListsWithDifferentDelays() { final int pesNumber = 2; final long cloudletsNumber = Math.round(CLOUDLETS * 1.5); @@ -317,26 +294,22 @@ private void createCloudletListsWithDifferentDelays() { } } - /** - * Creates a single Cloudlet with no delay, meaning the Cloudlet arrival time will - * be zero (exactly when the simulation starts). - * - * @param length the Cloudlet length - * @param pesNumber the number of PEs the Cloudlets requires - * @return the created Cloudlet - */ + /// Creates a single Cloudlet with no delay, meaning the Cloudlet arrival time will + /// be zero (exactly when the simulation starts). + /// + /// @param length the Cloudlet length + /// @param pesNumber the number of PEs the Cloudlets requires + /// @return the created Cloudlet private Cloudlet createCloudlet(final long length, final int pesNumber) { return createCloudlet(length, pesNumber, 0); } - /** - * Creates a single Cloudlet. - * - * @param length the length of the cloudlet to create. - * @param pesNumber the number of PEs the Cloudlets requires. - * @param delay the delay defining the arrival time of the Cloudlet at the Cloud infrastructure. - * @return the created Cloudlet - */ + /// Creates a single Cloudlet. + /// + /// @param length the length of the cloudlet to create. + /// @param pesNumber the number of PEs the Cloudlets requires. + /// @param delay the delay defining the arrival time of the Cloudlet at the Cloud infrastructure. + /// @return the created Cloudlet private Cloudlet createCloudlet(final long length, final int pesNumber, final double delay) { /* Since a VM PE isn't used by two Cloudlets at the same time, diff --git a/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmRamScalingExample.java b/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmRamScalingExample.java index 2ad3a61..dcdd218 100755 --- a/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmRamScalingExample.java +++ b/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmRamScalingExample.java @@ -56,70 +56,61 @@ import static java.util.Comparator.comparingDouble; import static org.cloudsimplus.utilizationmodels.UtilizationModel.Unit; -/** - * An example that scales VM RAM up or down, according to resource requests from running Cloudlets. - * It relies on {@link UtilizationModelDynamic} to - * set Vm RAM usage increasingly along the time. - * Cloudlets are created with different lengths, so that they will finish gradually. - * This way, it's possible to check that RAM usage decreases along the time. - * - *

      A {@link VerticalVmScaling} - * is set to each initially created VM (check {@link #createListOfScalableVms(int)}), - * which will check at {@link #SCHEDULING_INTERVAL specific time intervals} - * if a VM's RAM {@link #upperRamUtilizationThreshold(Vm) is overloaded or not}, - * according to a statically computed utilization threshold. - * Then it requests the RAM to be scaled up.

      - * - *

      The example uses the CloudSim Plus {@link EventListener} feature - * to enable monitoring the simulation and dynamically creating objects such as Cloudlets and VMs. - * It creates a Listener for the {@link Simulation#addOnClockTickListener(EventListener) onClockTick event} - * to get notifications when the simulation clock advances, then creating and submitting new cloudlets. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.2.0 - * @see VerticalVmCpuScalingExample - */ +/// An example that scales VM RAM up or down, according to resource requests from running Cloudlets. +/// It relies on [UtilizationModelDynamic] to +/// set Vm RAM usage increasingly along the time. +/// Cloudlets are created with different lengths, so that they will finish gradually. +/// This way, it's possible to check that RAM usage decreases along the time. +/// +/// A [VerticalVmScaling] +/// is set to each initially created VM (check [#createListOfScalableVms(int)]), +/// which will check at [specific time intervals][#SCHEDULING_INTERVAL] +/// if a VM's RAM [is overloaded or not][#upperRamUtilizationThreshold(Vm)], +/// according to a **statically computed utilization threshold**. +/// Then it requests the RAM to be scaled up. +/// +/// The example uses the CloudSim Plus [EventListener] feature +/// to enable monitoring the simulation and dynamically creating objects such as Cloudlets and VMs. +/// It creates a Listener for the [onClockTick event][Simulation#addOnClockTickListener(EventListener)] +/// to get notifications when the simulation clock advances, then creating and submitting new cloudlets. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.2.0 +/// @see VerticalVmCpuScalingExample public class VerticalVmRamScalingExample { - /** - * The interval in which the Datacenter will schedule events. - * As lower this interval is, sooner the processing of VMs and Cloudlets - * is updated, and you get more notifications about the simulation execution. - * However, it can affect the simulation performance. - * - *

      For this example, a larger schedule interval such as 15 will make that just - * at every 15 seconds the processing of VMs is updated. If a VM is overloaded, just - * after this time the creation of a new one will be requested - * by the VM's {@link HorizontalVmScaling Horizontal Scaling} mechanism.

      - * - *

      If this interval is defined using a small value, you may get - * more dynamically created VMs than expected. Accordingly, this value - * has to be trade-off. - * For more details, see {@link Datacenter#getSchedulingInterval()}.

      - */ + /// The interval in which the Datacenter will schedule events. + /// As lower this interval is, sooner the processing of VMs and Cloudlets + /// is updated, and you get more notifications about the simulation execution. + /// However, it can affect the simulation performance. + /// + /// For this example, a larger schedule interval such as 15 will make that just + /// at every 15 seconds the processing of VMs is updated. If a VM is overloaded, just + /// after this time the creation of a new one will be requested + /// by the VM's [Horizontal Scaling][HorizontalVmScaling] mechanism. + /// + /// If this interval is defined using a small value, you may get + /// more dynamically created VMs than expected. Accordingly, this value + /// has to be trade-off. + /// For more details, see [Datacenter#getSchedulingInterval()]. private static final int SCHEDULING_INTERVAL = 1; private static final int HOSTS = 1; private static final int HOST_PES = 8; - /** Host RAM capacity in Megabytes. */ + /// Host RAM capacity in Megabytes. private static final long HOST_RAM = 20000; private static final int HOST_MIPS = 1000; private static final int VMS = 1; - /** - * Vm RAM capacity in Megabytes. - */ + /// Vm RAM capacity in Megabytes. private static final int VM_RAM = 1000; private static final int VM_PES = 5; private static final int VM_MIPS = 1000; - /** - * The percentage (in scale from 0 to 1) to scale VM RAM capacity up/down - * when it becomes under/overloaded. - * @see #createVerticalRamScalingForVm(Vm) - */ + /// The percentage (in scale from 0 to 1) to scale VM RAM capacity up/down + /// when it becomes under/overloaded. + /// @see #createVerticalRamScalingForVm(Vm) private static final double VM_RAM_SCALING_FACTOR = 0.1; private final CloudSimPlus simulation; @@ -128,12 +119,10 @@ public class VerticalVmRamScalingExample { private final List vmList; private final List cloudletList; - /** - * Different lengths (in MI) to be used when creating Cloudlets. - * For each VM, one Cloudlet for each one of these lengths will be created. - * Creating Cloudlets with different lengths, since some Cloudlets will finish prior to others along the time, - * the VM resource usage will reduce when a Cloudlet finishes. - */ + /// Different lengths (in MI) to be used when creating Cloudlets. + /// For each VM, one Cloudlet for each one of these lengths will be created. + /// Creating Cloudlets with different lengths, since some Cloudlets will finish prior to others along the time, + /// the VM resource usage will reduce when a Cloudlet finishes. private static final long[] CLOUDLET_LENGTHS = {40_000, 50_000, 60_000, 70_000, 80_000}; private static final int CLOUDLET_PES = 1; @@ -145,9 +134,7 @@ public static void main(String[] args) { new VerticalVmRamScalingExample(); } - /** - * Default constructor that builds the simulation scenario and starts the simulation. - */ + /// Default constructor that builds the simulation scenario and starts the simulation. private VerticalVmRamScalingExample() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -216,14 +203,12 @@ private Host createHost() { return new HostSimple(HOST_RAM, bw, storage, peList).setVmScheduler(new VmSchedulerTimeShared()); } - /** - * Creates a list of initial VMs in which each one is able to scale horizontally - * when it is overloaded. - * - * @param vmsNumber number of VMs to create - * @return the list of scalable VMs - * @see #createVerticalRamScalingForVm(Vm) - */ + /// Creates a list of initial VMs in which each one is able to scale horizontally + /// when it is overloaded. + /// + /// @param vmsNumber number of VMs to create + /// @return the list of scalable VMs + /// @see #createVerticalRamScalingForVm(Vm) private List createListOfScalableVms(final int vmsNumber) { final var newVmList = new ArrayList(vmsNumber); for (int i = 0; i < vmsNumber; i++) { @@ -242,12 +227,10 @@ private Vm createVm() { .setRam(VM_RAM).setBw(1000).setSize(10000); } - /** - * Creates a {@link VerticalVmScaling} for the RAM of a given VM. - * - * @param vm the VM in which the VerticalVmScaling will be created - * @see #createListOfScalableVms(int) - */ + /// Creates a [VerticalVmScaling] for the RAM of a given VM. + /// + /// @param vm the VM in which the VerticalVmScaling will be created + /// @see #createListOfScalableVms(int) private void createVerticalRamScalingForVm(final Vm vm) { final var verticalRamScaling = new VerticalVmScalingSimple(Ram.class, VM_RAM_SCALING_FACTOR); @@ -264,32 +247,28 @@ private void createVerticalRamScalingForVm(final Vm vm) { vm.setRamVerticalScaling(verticalRamScaling); } - /** - * Defines the minimum RAM utilization percentage that indicates a Vm is underloaded. - * This function is using a statically defined threshold, but it would be defined - * a dynamic threshold based on any condition you want. - * A reference to this method is assigned to each {@link VerticalVmScaling} created. - * - * @param vm the VM to check if its RAM is underloaded. - * The parameter is not being used internally, that means the same - * threshold is applied for any Vm. - * @return the lower RAM utilization threshold - */ + /// Defines the minimum RAM utilization percentage that indicates a Vm is underloaded. + /// This function is using a statically defined threshold, but it would be defined + /// a dynamic threshold based on any condition you want. + /// A reference to this method is assigned to each [VerticalVmScaling] created. + /// + /// @param vm the VM to check if its RAM is underloaded. + /// The parameter is not being used internally, that means the same + /// threshold is applied for any Vm. + /// @return the lower RAM utilization threshold private double lowerRamUtilizationThreshold(final Vm vm) { return 0.5; } - /** - * Defines the maximum RAM utilization percentage that indicates a Vm is overloaded. - * This function is using a statically defined threshold, but it would be defined - * a dynamic threshold based on any condition you want. - * A reference to this method is assigned to each {@link VerticalVmScaling} created. - * - * @param vm the VM to check if its RAM is overloaded. - * The parameter is not being used internally, that means the same - * threshold is applied for any Vm. - * @return the upper RAM utilization threshold - */ + /// Defines the maximum RAM utilization percentage that indicates a Vm is overloaded. + /// This function is using a statically defined threshold, but it would be defined + /// a dynamic threshold based on any condition you want. + /// A reference to this method is assigned to each [VerticalVmScaling] created. + /// + /// @param vm the VM to check if its RAM is overloaded. + /// The parameter is not being used internally, that means the same + /// threshold is applied for any Vm. + /// @return the upper RAM utilization threshold private double upperRamUtilizationThreshold(final Vm vm) { return 0.7; } @@ -314,12 +293,10 @@ private void createCloudletList() { cloudletList.get(0).setUtilizationModelRam(ramModel2); } - /** - * Creates a Cloudlet - * @param ramUtilizationModel the object that defines how Cloudlet will use RAM - * @param length the Cloudlet length in MI - * @return - */ + /// Creates a Cloudlet + /// @param ramUtilizationModel the object that defines how Cloudlet will use RAM + /// @param length the Cloudlet length in MI + /// @return private Cloudlet createCloudlet(final UtilizationModel ramUtilizationModel, final long length) { final int id = createdCloudlets++; final double initialBwUtilizationPercent = 0.1; @@ -329,13 +306,11 @@ private Cloudlet createCloudlet(final UtilizationModel ramUtilizationModel, fina .setUtilizationModelRam(ramUtilizationModel); } - /** - * Increments the RAM resource utilization (defined in absolute values) - * in 10MB every second. - * - * @param um the Utilization Model that has called this function - * @return the new resource utilization after the increment - */ + /// Increments the RAM resource utilization (defined in absolute values) + /// in 10MB every second. + /// + /// @param um the Utilization Model that has called this function + /// @return the new resource utilization after the increment private double utilizationIncrement(final UtilizationModelDynamic um) { final int ramIncreaseMB = 10; return um.getUtilization() + um.getTimeSpan() * ramIncreaseMB; diff --git a/src/main/java/org/cloudsimplus/examples/autoscaling/package-info.java b/src/main/java/org/cloudsimplus/examples/autoscaling/package-info.java index 1453667..c3137ad 100755 --- a/src/main/java/org/cloudsimplus/examples/autoscaling/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/autoscaling/package-info.java @@ -21,13 +21,11 @@ * You should have received a copy of the GNU General Public License * along with CloudSim Plus. If not, see . */ -/** - * Examples showing how to enable horizontal and vertical - * VM scaling using the {@link org.cloudsimplus.autoscaling.HorizontalVmScaling} - * and {@link org.cloudsimplus.autoscaling.VerticalVmScaling}. - * - * @author Manoel Campos da Silva Filho - */ +/// Examples showing how to enable horizontal and vertical +/// VM scaling using the [org.cloudsimplus.autoscaling.HorizontalVmScaling] +/// and [org.cloudsimplus.autoscaling.VerticalVmScaling]. +/// +/// @author Manoel Campos da Silva Filho @NullMarked package org.cloudsimplus.examples.autoscaling; diff --git a/src/main/java/org/cloudsimplus/examples/brokers/BrokerTargetDatacenterExample.java b/src/main/java/org/cloudsimplus/examples/brokers/BrokerTargetDatacenterExample.java index ef398a5..67a34ba 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/BrokerTargetDatacenterExample.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/BrokerTargetDatacenterExample.java @@ -43,21 +43,18 @@ import java.util.List; import java.util.stream.IntStream; -/** - * An example showing how to make the {@link DatacenterBrokerSimple} - * to set a specific target {@link Datacenter} to place VMs, - * before trying the next Datacenter if VM placement fails - * (due to lack of suitable Hosts). - * - *

      You can see that VM 11 submitted to Broker 6 targeting Datacenter 3 - * could not be placed into that DC due to lack of suitable Hosts. - * Then, the next Datacenter was selected, in a round-robin (circular) way. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 7.3.2 - * @see #createBrokersVmsAndCloudlets() - */ +/// An example showing how to make the [DatacenterBrokerSimple] +/// to set a specific target [Datacenter] to place VMs, +/// before trying the next Datacenter if VM placement fails +/// (due to lack of suitable Hosts). +/// +/// You can see that VM 11 submitted to Broker 6 targeting Datacenter 3 +/// could not be placed into that DC due to lack of suitable Hosts. +/// Then, the next Datacenter was selected, in a round-robin (circular) way. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 7.3.2 +/// @see #createBrokersVmsAndCloudlets() public class BrokerTargetDatacenterExample { private static final int DATACENTERS = 3; private static final int HOSTS_BY_DC = 5; @@ -96,10 +93,8 @@ private BrokerTargetDatacenterExample() { brokerList.forEach(BrokerTargetDatacenterExample::createCloudletsResultTable); } - /** - * Creates a broker for each available Datacenter - * and submit VMs and Cloudlets. - */ + /// Creates a broker for each available Datacenter + /// and submit VMs and Cloudlets. private void createBrokersVmsAndCloudlets() { for (final var dc : datacenterList) { final var broker = createBroker(dc); @@ -116,11 +111,9 @@ private void createBrokersVmsAndCloudlets() { } } - /** - * Creates a broker that sets a target Datacenter to initially place arriving VMs. - * @param dc the target datacenter - * @return the new broker - */ + /// Creates a broker that sets a target Datacenter to initially place arriving VMs. + /// @param dc the target datacenter + /// @return the new broker private DatacenterBrokerSimple createBroker(final Datacenter dc) { final var broker = new DatacenterBrokerSimple(simulation); broker.setName("Broker %d for %s".formatted(broker.getId(), dc)); @@ -142,9 +135,7 @@ private List createDatacenters(){ .toList(); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = IntStream.range(0, HOSTS_BY_DC) .mapToObj(i -> createHost()) @@ -173,9 +164,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms(final int vmsNumber) { final var vms = new ArrayList(vmsNumber); for (int i = 0; i < vmsNumber; i++) { @@ -188,9 +177,7 @@ private List createVms(final int vmsNumber) { return vms; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets(int cloudletsNumber) { final var cloudlets = new ArrayList(cloudletsNumber); diff --git a/src/main/java/org/cloudsimplus/examples/brokers/CloudletToVmMappingBestFit.java b/src/main/java/org/cloudsimplus/examples/brokers/CloudletToVmMappingBestFit.java index 3f2ca20..e3d2024 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/CloudletToVmMappingBestFit.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/CloudletToVmMappingBestFit.java @@ -45,22 +45,19 @@ import java.util.Comparator; import java.util.List; -/** - * An example showing how to change the policy - * used by a {@link DatacenterBroker} to map Cloudlets to VMs. - * - *

      The example uses the CloudSim Plus - * Functional DatacenterBroker that enables - * changing the method used for that goal, - * without requiring to create a subclass to accomplish that.

      - * - *

      The example uses the class {@link DatacenterBrokerBestFit} that performs - * an optimal mapping of Cloudlets to VMs based on the free Pes in VMs. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.3.0 - */ +/// An example showing how to change the policy +/// used by a [DatacenterBroker] to map Cloudlets to VMs. +/// +/// The example uses the CloudSim Plus +/// Functional DatacenterBroker that enables +/// changing the method used for that goal, +/// without requiring to create a subclass to accomplish that. +/// +/// The example uses the class [DatacenterBrokerBestFit] that performs +/// an optimal mapping of Cloudlets to VMs based on the free Pes in VMs. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.3.0 public class CloudletToVmMappingBestFit { private static final int HOSTS = 2; private static final int HOST_PES = 8; @@ -103,9 +100,7 @@ private CloudletToVmMappingBestFit() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -133,11 +128,9 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs with decreasing number of PEs. - * The IDs of the VMs aren't defined and will be set when - * they are submitted to the broker. - */ + /// Creates a list of VMs with decreasing number of PEs. + /// The IDs of the VMs aren't defined and will be set when + /// they are submitted to the broker. private List createVms() { final var vmList = new ArrayList(VMS); for (int i = VMS-1; i >= 0; i--) { @@ -152,11 +145,9 @@ private List createVms() { return vmList; } - /** - * Creates a list of Cloudlets with increasing number of required PEs. - * The IDs of the Cloudlets aren't defined and will be set when - * they are submitted to the broker. - */ + /// Creates a list of Cloudlets with increasing number of required PEs. + /// The IDs of the Cloudlets aren't defined and will be set when + /// they are submitted to the broker. private List createCloudlets() { final var cloudletList = new ArrayList(CLOUDLETS); final var utilization = new UtilizationModelFull(); diff --git a/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokerBatchVmCreationRequestExample.java b/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokerBatchVmCreationRequestExample.java index 82b9755..7d2d94d 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokerBatchVmCreationRequestExample.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokerBatchVmCreationRequestExample.java @@ -48,17 +48,15 @@ import static java.util.stream.Collectors.joining; -/** - * An example showing how to enable a {@link DatacenterBroker} to - * request creation of a Vm List in batch, instead of in a one-by-one basis. - * It can use any {@link org.cloudsimplus.allocationpolicies.VmAllocationPolicy} - * but it uses the {@link VmAllocationPolicyBatchPlacementUnderloadedHosts} - * as an example. - * Check {@link DatacenterBroker#setBatchVmCreation(boolean)} - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 8.5.0 - */ +/// An example showing how to enable a [DatacenterBroker] to +/// request creation of a Vm List in batch, instead of in a one-by-one basis. +/// It can use any [org.cloudsimplus.allocationpolicies.VmAllocationPolicy] +/// but it uses the [VmAllocationPolicyBatchPlacementUnderloadedHosts] +/// as an example. +/// Check [DatacenterBroker#setBatchVmCreation(boolean)] +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 8.5.0 public class DatacenterBrokerBatchVmCreationRequestExample { private static final int HOSTS = 2; private static final int HOST_PES = 8; @@ -79,12 +77,10 @@ public class DatacenterBrokerBatchVmCreationRequestExample { private List cloudletList; private Datacenter datacenter0; - /** @see Datacenter#setSchedulingInterval(double) */ + /// @see Datacenter#setSchedulingInterval(double) private static final double SCHEDULING_INTERVAL = 1; - /** - * Indicates wether no cloudlets were created during simulation runtime yet. - */ + /// Indicates wether no cloudlets were created during simulation runtime yet. private boolean noDynamicCloudletsCreated = true; public static void main(String[] args) { @@ -113,17 +109,13 @@ private DatacenterBrokerBatchVmCreationRequestExample() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * {@return a new broker} Enables batch VM creation. - */ + /// {@return a new broker} Enables batch VM creation. private DatacenterBroker createBroker() { return new DatacenterBrokerSimple(simulation).setBatchVmCreation(true); } - /** - * @param info - * @see Datacenter#setSchedulingInterval(double) - */ + /// @param info + /// @see Datacenter#setSchedulingInterval(double) private void onClockTick(final EventInfo info) { if(info.getTime() >= 10 && noDynamicCloudletsCreated) { noDynamicCloudletsCreated = false; @@ -146,9 +138,7 @@ private void createVmsAndCloudlets() { createAndSubmitCloudlets(newVms); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { diff --git a/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokerHeuristicExample.java b/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokerHeuristicExample.java index ec84240..a44daba 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokerHeuristicExample.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokerHeuristicExample.java @@ -53,32 +53,28 @@ import java.util.List; import java.util.Map; -/** - * An example that uses a - * Simulated Annealing - * heuristic to find a suboptimal mapping between Cloudlets and Vm's submitted to a - * DatacenterBroker. The number of {@link Pe}s of Vm's and Cloudlets are defined - * randomly. - * - *

      The {@link DatacenterBrokerHeuristic} is used - * with the {@link CloudletToVmMappingSimulatedAnnealing} class - * in order to find an acceptable solution with a high - * {@link HeuristicSolution#getFitness() fitness value}.

      - * - *

      Different {@link CloudletToVmMappingHeuristic} implementations can be used - * with the {@link DatacenterBrokerHeuristic} class.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - */ +/// An example that uses a +/// [Simulated Annealing](http://en.wikipedia.org/wiki/Simulated_annealing) +/// heuristic to find a suboptimal mapping between Cloudlets and Vm's submitted to a +/// DatacenterBroker. The number of [Pe]s of Vm's and Cloudlets are defined +/// randomly. +/// +/// The [DatacenterBrokerHeuristic] is used +/// with the [CloudletToVmMappingSimulatedAnnealing] class +/// in order to find an acceptable solution with a high +/// [fitness value][HeuristicSolution#getFitness()]. +/// +/// Different [CloudletToVmMappingHeuristic] implementations can be used +/// with the [DatacenterBrokerHeuristic] class. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 public class DatacenterBrokerHeuristicExample { private static final int HOSTS_TO_CREATE = 100; private static final int VMS_TO_CREATE = 50; private static final int CLOUDLETS_TO_CREATE = 100; - /** - * Simulated Annealing (SA) parameters. - */ + /// Simulated Annealing (SA) parameters. public static final double SA_INITIAL_TEMPERATURE = 1.0; public static final double SA_COLD_TEMPERATURE = 0.0001; public static final double SA_COOLING_RATE = 0.003; @@ -89,26 +85,18 @@ public class DatacenterBrokerHeuristicExample { private List vmList; private CloudletToVmMappingSimulatedAnnealing heuristic; - /** - * Number of cloudlets created so far. - */ + /// Number of cloudlets created so far. private int createdCloudlets = 0; - /** - * Number of VMs created so far. - */ + /// Number of VMs created so far. private int createdVms = 0; - /** - * Number of hosts created so far. - */ + /// Number of hosts created so far. private int createdHosts = 0; public static void main(String[] args) { new DatacenterBrokerHeuristicExample(); } - /** - * Default constructor where the simulation is built. - */ + /// Default constructor where the simulation is built. private DatacenterBrokerHeuristicExample() { //Enables just some level of log messages. Log.setLevel(Level.WARN); @@ -181,12 +169,10 @@ private void print(final DatacenterBrokerHeuristic broker0) { System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * Randomly gets a number of PEs (CPU cores). - * - * @param maxPesNumber the maximum value to get a random number of PEs - * @return the randomly generated PEs number - */ + /// Randomly gets a number of PEs (CPU cores). + /// + /// @param maxPesNumber the maximum value to get a random number of PEs + /// @return the randomly generated PEs number private int getRandomPesNumber(final int maxPesNumber) { return heuristic.getRandomValue(maxPesNumber)+1; } diff --git a/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokersMappingComparison.java b/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokersMappingComparison.java index 7b5ad0f..46b9c55 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokersMappingComparison.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokersMappingComparison.java @@ -60,32 +60,28 @@ import static java.util.Map.Entry; -/** - * An example that uses a - * Simulated Annealing - * heuristic to find a suboptimal mapping between Cloudlets and Vm's submitted to a - * DatacenterBroker. The number of {@link Pe}s of Vm's and Cloudlets are defined - * randomly. - * - *

      The {@link DatacenterBrokerHeuristic} is used - * with the {@link CloudletToVmMappingSimulatedAnnealing} class - * in order to find an acceptable solution with a high - * {@link HeuristicSolution#getFitness() fitness value}.

      - * - *

      Different {@link CloudletToVmMappingHeuristic} implementations can be used - * with the {@link DatacenterBrokerHeuristic} class.

      - * - *

      A comparison of cloudlet-VM mapping is done among the best fit approach, - * heuristic approach and round robin mapping.

      - * - * @author Humaira Abdul Salam - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.3.8 - */ +/// An example that uses a +/// [Simulated Annealing](http://en.wikipedia.org/wiki/Simulated_annealing) +/// heuristic to find a suboptimal mapping between Cloudlets and Vm's submitted to a +/// DatacenterBroker. The number of [Pe]s of Vm's and Cloudlets are defined +/// randomly. +/// +/// The [DatacenterBrokerHeuristic] is used +/// with the [CloudletToVmMappingSimulatedAnnealing] class +/// in order to find an acceptable solution with a high +/// [fitness value][HeuristicSolution#getFitness()]. +/// +/// Different [CloudletToVmMappingHeuristic] implementations can be used +/// with the [DatacenterBrokerHeuristic] class. +/// +/// A comparison of cloudlet-VM mapping is done among the best fit approach, +/// heuristic approach and round robin mapping. +/// +/// @author Humaira Abdul Salam +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.3.8 public class DatacenterBrokersMappingComparison { - /** - * Simulated Annealing (SA) parameters. - */ + /// Simulated Annealing (SA) parameters. public static final double SA_INITIAL_TEMPERATURE = 1.0; public static final double SA_COLD_TEMPERATURE = 0.0001; public static final double SA_COOLING_RATE = 0.003; @@ -130,9 +126,7 @@ public static void main(String[] args) { System.out.println("Comparison finished!"); } - /** - * Default constructor where the simulation is built. - */ + /// Default constructor where the simulation is built. private DatacenterBrokersMappingComparison(final DatacenterBroker broker, final ContinuousDistribution random, final boolean verbose) { this.broker = broker; this.simulation = broker.getSimulation(); @@ -196,12 +190,10 @@ private void print(final boolean verbose) { "The solution based on %s mapper costs %.2f.%n", broker.getClass().getSimpleName(), brokersMappingCost); } - /** - * Randomly gets a number of PEs (CPU cores). - * - * @param maxPesNumber the maximum value to get a random number of PEs - * @return the randomly generated PEs number - */ + /// Randomly gets a number of PEs (CPU cores). + /// + /// @param maxPesNumber the maximum value to get a random number of PEs + /// @return the randomly generated PEs number private int getRandomPesNumber(final int maxPesNumber, final ContinuousDistribution random) { final double uniform = random.sample(); diff --git a/src/main/java/org/cloudsimplus/examples/brokers/DatacenterSelectionByTimeZoneExample.java b/src/main/java/org/cloudsimplus/examples/brokers/DatacenterSelectionByTimeZoneExample.java index 003a3d7..37cc399 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/DatacenterSelectionByTimeZoneExample.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/DatacenterSelectionByTimeZoneExample.java @@ -50,22 +50,18 @@ import static java.util.Map.Entry; -/** - * An example showing how to use the {@link DatacenterBrokerSimple} - * to select the {@link Datacenter} closest to every submitted {@link Vm}, - * according to their {@link TimeZoned#getTimeZone() TimeZone offset}. - * - *

      Realize that for this feature to work, the {@link DatacenterBroker#setSelectClosestDatacenter(boolean)} - * must be called to enable it.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.8.0 - */ +/// An example showing how to use the [DatacenterBrokerSimple] +/// to select the [Datacenter] closest to every submitted [Vm], +/// according to their [TimeZone offset][TimeZoned#getTimeZone()]. +/// +/// Realize that for this feature to work, the [DatacenterBroker#setSelectClosestDatacenter(boolean)] +/// must be called to enable it. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.8.0 public class DatacenterSelectionByTimeZoneExample { - /** - * Amazon Web Services Regions (just some of them). - * @see AWS Global Infrastructure - */ + /// Amazon Web Services Regions (just some of them). + /// @see AWS Global Infrastructure private static final Map DATACENTERS_TIMEZONES = Map.of( "Oregon", -7.0, "Canada", -4.0, @@ -82,11 +78,9 @@ public class DatacenterSelectionByTimeZoneExample { private static final int HOSTS = 5; private static final int HOST_PES = 8; - /** - * The list of timezones where each VM is expected to be placed. - * This way, the broker will try to place each VM at the closest - * Datacenter as possible. - */ + /// The list of timezones where each VM is expected to be placed. + /// This way, the broker will try to place each VM at the closest + /// Datacenter as possible. private static final double[] VMS_TIMEZONES = {1, 5, -3, -5, 0, 5.5, 2, 4, 9, 11, -9}; private static final int VM_PES = 4; @@ -143,11 +137,9 @@ public String getVmTimeZone(final Cloudlet cloudlet) { return TimeZoned.format(cloudlet.getVm().getTimeZone()); } - /** - * Creates a List of Datacenters, each Datacenter having - * Hosts with a number of PEs higher than the previous Datacenter. - * @return - */ + /// Creates a List of Datacenters, each Datacenter having + /// Hosts with a number of PEs higher than the previous Datacenter. + /// @return private List createDatacenters(){ final var dcList = new ArrayList(DATACENTERS_TIMEZONES.size()); for (Entry entry : DATACENTERS_TIMEZONES.entrySet()) { @@ -160,10 +152,8 @@ private List createDatacenters(){ return dcList; } - /** - * Creates a Datacenter in a given timezone. - * @param timeZone the time zone offset - */ + /// Creates a Datacenter in a given timezone. + /// @param timeZone the time zone offset private Datacenter createDatacenter(final double timeZone) { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -198,11 +188,9 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs, setting the timezone they are expected to be placed. - * This way, the broker will try to place each VM at the closest - * Datacenter as possible. - */ + /// Creates a list of VMs, setting the timezone they are expected to be placed. + /// This way, the broker will try to place each VM at the closest + /// Datacenter as possible. private List createVms() { final var vmList = new ArrayList(VMS_TIMEZONES.length); for (final double timezone : VMS_TIMEZONES) { @@ -215,9 +203,7 @@ private List createVms() { return vmList; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var cloudletList = new ArrayList(CLOUDLETS); diff --git a/src/main/java/org/cloudsimplus/examples/brokers/MultipleBrokers1.java b/src/main/java/org/cloudsimplus/examples/brokers/MultipleBrokers1.java index e96afe6..7e871d5 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/MultipleBrokers1.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/MultipleBrokers1.java @@ -46,34 +46,30 @@ import java.util.List; import java.util.function.Function; -/** - * An example showing how to create VMs and Cloudlets - * for multiple customers, each one represented - * by a {@link DatacenterBroker} object. - * - *

      It creates Cloudlets with different lengths to enable - * them to finish in different times. - * It also uses the {@link DatacenterBroker#setVmDestructionDelayFunction(Function)} - * method to define a {@link Function} which will be used - * to get the time delay a VM will be destroyed after becoming idle. - * Setting a delay before destroying an idle VM - * gives dynamically arrived Cloudltes the opportunity to possibly - * run inside such a VM. In this case, the VM stays idle for a - * period of time to balance the load of arrived Cloudlets - * or even to enable fault tolerance.

      - * - *

      See the {@link DatacenterBroker#DEF_VM_DESTRUCTION_DELAY} - * for details about the default behaviour.

      - * - *

      For details about Fault Injection, check the {@link org.cloudsimplus.faultinjection} package.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.2.2 - */ +/// An example showing how to create VMs and Cloudlets +/// for multiple customers, each one represented +/// by a [DatacenterBroker] object. +/// +/// It creates Cloudlets with different lengths to enable +/// them to finish in different times. +/// It also uses the [DatacenterBroker#setVmDestructionDelayFunction(Function)] +/// method to define a [Function] which will be used +/// to get the time delay a VM will be destroyed after becoming idle. +/// Setting a delay before destroying an idle VM +/// gives dynamically arrived Cloudltes the opportunity to possibly +/// run inside such a VM. In this case, the VM stays idle for a +/// period of time to balance the load of arrived Cloudlets +/// or even to enable fault tolerance. +/// +/// See the [DatacenterBroker#DEF_VM_DESTRUCTION_DELAY] +/// for details about the default behaviour. +/// +/// For details about Fault Injection, check the [org.cloudsimplus.faultinjection] package. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.2.2 public class MultipleBrokers1 { - /** - * @see Datacenter#getSchedulingInterval() - */ + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 5; private static final int HOSTS = 2; private static final int HOST_PES = 8; @@ -114,9 +110,7 @@ private MultipleBrokers1() { printResults(); } - /** - * Creates VMs and Cloudlets for each DatacenterBroker. - */ + /// Creates VMs and Cloudlets for each DatacenterBroker. private void createVmsAndCloudlets() { int i = 0; for (var broker : brokers) { @@ -141,17 +135,15 @@ private void printResults() { System.out.println(); } - /** - * Creates the list of {@link DatacenterBroker}s. - * It enables you to define when a broker should destroy - * an idle VM, according to a given - * {@link DatacenterBroker#setVmDestructionDelayFunction(Function) VM Destruction Delay Function}. - * - *

      See Issue #99 for more details.

      - * - * @see DatacenterBroker#setVmDestructionDelayFunction(Function) - * @return the List of created brokers - */ + /// Creates the list of [DatacenterBroker]s. + /// It enables you to define when a broker should destroy + /// an idle VM, according to a given + /// [VM Destruction Delay Function][DatacenterBroker#setVmDestructionDelayFunction(Function)]. + /// + /// See [Issue #99](https://github.com/cloudsimplus/cloudsimplus/issues/99) for more details. + /// + /// @see DatacenterBroker#setVmDestructionDelayFunction(Function) + /// @return the List of created brokers private List createBrokers() { final var brokerList = new ArrayList(BROKERS); for(int i = 0; i < BROKERS; i++) { @@ -169,9 +161,7 @@ private List createBrokers() { return brokerList; } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -205,9 +195,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createAndSubmitVms(DatacenterBroker broker) { final var vmList = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -223,9 +211,7 @@ private List createAndSubmitVms(DatacenterBroker broker) { return vmList; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createAndSubmitCloudlets(DatacenterBroker broker, final int initialLength) { final var cloudletList = new ArrayList(CLOUDLETS); for (int i = 1; i <= CLOUDLETS; i++) { diff --git a/src/main/java/org/cloudsimplus/examples/brokers/MultipleBrokers2.java b/src/main/java/org/cloudsimplus/examples/brokers/MultipleBrokers2.java index 59864a9..fa61b81 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/MultipleBrokers2.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/MultipleBrokers2.java @@ -48,35 +48,31 @@ import java.util.List; import java.util.function.Function; -/** - * An example showing how to create VMs and Cloudlets - * for multiple customers, each one represented - * by a {@link DatacenterBroker} object. - * - *

      It creates Cloudlets with different lengths to enable - * them to finish in different times. - * It also uses the {@link DatacenterBroker#setVmDestructionDelayFunction(Function)} - * method to define a {@link Function} which will be used - * to get the time delay a VM will be destroyed after becoming idle. - * Setting a delay before destroying an idle VM - * gives dynamically arrived Cloudltes the opportunity to possibly - * run inside such a VM. In this case, the VM stay idle for a - * period of time to balance the load of arrived Cloudlets - * or even to enable fault tolerance.

      - * - *

      See the {@link DatacenterBroker#DEF_VM_DESTRUCTION_DELAY} - * for details about the default behaviour.

      - * - *

      For details about Fault Injection, check the {@link org.cloudsimplus.faultinjection} package.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.2.2 - * @see MultipleBrokers1 - */ +/// An example showing how to create VMs and Cloudlets +/// for multiple customers, each one represented +/// by a [DatacenterBroker] object. +/// +/// It creates Cloudlets with different lengths to enable +/// them to finish in different times. +/// It also uses the [DatacenterBroker#setVmDestructionDelayFunction(Function)] +/// method to define a [Function] which will be used +/// to get the time delay a VM will be destroyed after becoming idle. +/// Setting a delay before destroying an idle VM +/// gives dynamically arrived Cloudltes the opportunity to possibly +/// run inside such a VM. In this case, the VM stay idle for a +/// period of time to balance the load of arrived Cloudlets +/// or even to enable fault tolerance. +/// +/// See the [DatacenterBroker#DEF_VM_DESTRUCTION_DELAY] +/// for details about the default behaviour. +/// +/// For details about Fault Injection, check the [org.cloudsimplus.faultinjection] package. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.2.2 +/// @see MultipleBrokers1 public class MultipleBrokers2 { - /** - * @see Datacenter#getSchedulingInterval() - */ + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 5; private static final int HOSTS = 2; private static final int HOST_PES = 8; @@ -129,48 +125,43 @@ private MultipleBrokers2() { printResults(); } - /** - * Statically submits a Cloudlet with a specific delay, - * meaning it will start executing only after the defined time. - * The Cloudlet is submitted before the simulation starts. - */ + /// Statically submits a Cloudlet with a specific delay, + /// meaning it will start executing only after the defined time. + /// The Cloudlet is submitted before the simulation starts. private void submitCloudletWithDelay() { final var cloudlet = createCloudlet(cloudletList.size(), CLOUDLET_LENGTH); cloudlet.setSubmissionDelay(35); brokers.get(1).submitCloudlet(cloudlet); } - /** - * Dynamically submits a cloudlet during simulation execution. - * This method is called every time when the simulation clock - * increases. - * The created Cloudlet is submitted only at a specific simulation time. - * - *

      Realize the interval in which this method is called is defined - * according to the {@link #SCHEDULING_INTERVAL}.

      - * - *

      Different from the {@link #submitCloudletWithDelay()} method, - * which creates all Cloudtets when the simulation starts and make them wait - * to start executing, this method is called dynamically during - * simulation. It defines internally, when - * we want the Cloudlet to be submitted. - * The method is called by the {@link CloudSimPlus} object - * because an {@link EventListener} was added to be - * notified when the simulation clock changes. - * This way it allows, between uncountable possibilities, - * to define specific conditions when a new Cloudlet should be submitted - * to a broker. - *

      - * - *

      The dynamic way of submitting Cloudlets is more flexible because it allows you to define - * any condition you want inside a method such as this one. - * That condition may include any other variables besides the time.

      - * - * @param e information about the generated event - * @return - * @see Datacenter#getSchedulingInterval() - * @see CloudSimPlus#addOnClockTickListener(EventListener) - */ + /// Dynamically submits a cloudlet during simulation execution. + /// This method is called every time when the simulation clock + /// increases. + /// The created Cloudlet is submitted only at a specific simulation time. + /// + /// Realize the interval in which this method is called is defined + /// according to the [#SCHEDULING_INTERVAL]. + /// + /// Different from the [#submitCloudletWithDelay()] method, + /// which creates all Cloudtets when the simulation starts and make them wait + /// to start executing, this method is called dynamically during + /// simulation. It defines internally, when + /// we want the Cloudlet to be submitted. + /// The method is called by the [CloudSimPlus] object + /// because an [EventListener] was added to be + /// notified when the simulation clock changes. + /// This way it allows, between uncountable possibilities, + /// to define specific conditions when a new Cloudlet should be submitted + /// to a broker. + /// + /// The dynamic way of submitting Cloudlets is more flexible because it allows you to define + /// any condition you want inside a method such as this one. + /// That condition may include any other variables besides the time. + /// + /// @param e information about the generated event + /// @return + /// @see Datacenter#getSchedulingInterval() + /// @see CloudSimPlus#addOnClockTickListener(EventListener) private void dynamicCloudletArrival(EventInfo e) { if((int)e.getTime() != 35) { return; @@ -182,16 +173,14 @@ private void dynamicCloudletArrival(EventInfo e) { broker.submitCloudlet(cloudlet); } - /** - * Creates VMs and Cloudlets for each DatacenterBroker. - * It enables you to define when a broker should destroy - * an idle VM, according to a given - * {@link DatacenterBroker#setVmDestructionDelayFunction(Function) VM Destruction Delay Function}. - * - *

      See Issue #99 for more details.

      - * - * @see DatacenterBroker#setVmDestructionDelayFunction(Function) - */ + /// Creates VMs and Cloudlets for each DatacenterBroker. + /// It enables you to define when a broker should destroy + /// an idle VM, according to a given + /// [VM Destruction Delay Function][DatacenterBroker#setVmDestructionDelayFunction(Function)]. + /// + /// See [Issue #99](https://github.com/cloudsimplus/cloudsimplus/issues/99) for more details. + /// + /// @see DatacenterBroker#setVmDestructionDelayFunction(Function) private void createVmsAndCloudlets() { int i = 0; for (var broker : brokers) { @@ -226,9 +215,7 @@ private List createBrokers() { return brokerList; } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -262,9 +249,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createAndSubmitVms(DatacenterBroker broker) { final var vmList = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -280,9 +265,7 @@ private List createAndSubmitVms(DatacenterBroker broker) { return vmList; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createAndSubmitCloudlets(DatacenterBroker broker, final int initialLength) { final var cloudletList = new ArrayList(CLOUDLETS); for (int i = 1; i <= CLOUDLETS; i++) { diff --git a/src/main/java/org/cloudsimplus/examples/brokers/MultipleBrokers3.java b/src/main/java/org/cloudsimplus/examples/brokers/MultipleBrokers3.java index b11d5bf..a0209b6 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/MultipleBrokers3.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/MultipleBrokers3.java @@ -45,15 +45,13 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to create multiple VMs and Cloudlets for different customers, - * each one represented by a {@link DatacenterBroker} object. - * The example creates VMs and Cloudlets without defining an ID, which - * are defined when such objects are submitted to their brokers. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.3.1 - */ +/// An example showing how to create multiple VMs and Cloudlets for different customers, +/// each one represented by a [DatacenterBroker] object. +/// The example creates VMs and Cloudlets without defining an ID, which +/// are defined when such objects are submitted to their brokers. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.3.1 public class MultipleBrokers3 { private static final int HOSTS = 2; private static final int HOST_PES = 8; @@ -127,9 +125,7 @@ private List createBrokers() { return brokerList; } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { diff --git a/src/main/java/org/cloudsimplus/examples/brokers/SelectNextDatacenterExample.java b/src/main/java/org/cloudsimplus/examples/brokers/SelectNextDatacenterExample.java index 4290d62..07dbe9c 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/SelectNextDatacenterExample.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/SelectNextDatacenterExample.java @@ -42,19 +42,17 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how the {@link DatacenterBrokerSimple} - * selects the next {@link Datacenter} when the previous one - * is not able to create all {@link Vm}s due to lack - * of suitable Hosts. - * - *

      Each created Datacenter has hosts with more PEs than the previous Datacenter. - * This way, only the Datacenter 4 will have Hosts to place the - * created VMs.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.8.0 - */ +/// An example showing how the [DatacenterBrokerSimple] +/// selects the next [Datacenter] when the previous one +/// is not able to create all [Vm]s due to lack +/// of suitable Hosts. +/// +/// Each created Datacenter has hosts with more PEs than the previous Datacenter. +/// This way, only the Datacenter 4 will have Hosts to place the +/// created VMs. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.8.0 public class SelectNextDatacenterExample { private static final int DATACENTERS = 5; private static final int HOSTS = 5; @@ -99,11 +97,9 @@ private SelectNextDatacenterExample() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Creates a List of Datacenters, each Datacenter having - * Hosts with a number of PEs higher than the previous Datacenter. - * @return - */ + /// Creates a List of Datacenters, each Datacenter having + /// Hosts with a number of PEs higher than the previous Datacenter. + /// @return private List createDatacenters(){ final var datacenterList = new ArrayList(DATACENTERS); for (int i = 1; i <= DATACENTERS; i++) { @@ -113,10 +109,8 @@ private List createDatacenters(){ return datacenterList; } - /** - * Creates a Datacenter and its Hosts. - * @param hostsPes the number of PEs for the Hosts in the Datacenter created - */ + /// Creates a Datacenter and its Hosts. + /// @param hostsPes the number of PEs for the Hosts in the Datacenter created private Datacenter createDatacenter(final int hostsPes) { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -149,9 +143,7 @@ private Host createHost(final int pes) { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var vmList = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -164,9 +156,7 @@ private List createVms() { return vmList; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var cloudletList = new ArrayList(CLOUDLETS); diff --git a/src/main/java/org/cloudsimplus/examples/brokers/package-info.java b/src/main/java/org/cloudsimplus/examples/brokers/package-info.java index 91c29a3..50939cd 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/package-info.java @@ -21,22 +21,18 @@ * You should have received a copy of the GNU General Public License * along with CloudSim Plus. If not, see . */ -/** - * Examples showing how to use the full-featured CloudSim Plus - * {@link org.cloudsimplus.brokers.DatacenterBroker} implementations. - * - *

      - * Some examples include the utilization of multiple brokers - * to represent multiple cloud customers, the utilization - * of a {@link org.cloudsimplus.examples.brokers.DatacenterBrokerHeuristicExample} - * that maps Cloudlets to VMs based on the Simulated Annealing Heuristic, - * and other example showing how to dynamically change the policy used - * to map Cloudlets to VMs without requiring to subclass the - * {@link org.cloudsimplus.brokers.DatacenterBrokerSimple}. - *

      - * - * @author Manoel Campos da Silva Filho - */ +/// Examples showing how to use the full-featured CloudSim Plus +/// [org.cloudsimplus.brokers.DatacenterBroker] implementations. +/// +/// Some examples include the utilization of multiple brokers +/// to represent multiple cloud customers, the utilization +/// of a [org.cloudsimplus.examples.brokers.DatacenterBrokerHeuristicExample] +/// that maps Cloudlets to VMs based on the Simulated Annealing Heuristic, +/// and other example showing how to dynamically change the policy used +/// to map Cloudlets to VMs without requiring to subclass the +/// [org.cloudsimplus.brokers.DatacenterBrokerSimple]. +/// +/// @author Manoel Campos da Silva Filho @NullMarked package org.cloudsimplus.examples.brokers; diff --git a/src/main/java/org/cloudsimplus/examples/costs/CostsExample1.java b/src/main/java/org/cloudsimplus/examples/costs/CostsExample1.java index 0aef31e..4efe13e 100755 --- a/src/main/java/org/cloudsimplus/examples/costs/CostsExample1.java +++ b/src/main/java/org/cloudsimplus/examples/costs/CostsExample1.java @@ -45,20 +45,16 @@ import java.util.Comparator; import java.util.List; -/** - * A simple example showing how to define datacenter resource utilization - * and individual VM's costs ($). - * It creates VMs that run some cloudlets, - * while other VMs will just be idle all the time. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 6.2.7 - */ +/// A simple example showing how to define datacenter resource utilization +/// and individual VM's costs ($). +/// It creates VMs that run some cloudlets, +/// while other VMs will just be idle all the time. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 6.2.7 public class CostsExample1 { - /** - * Datacenter scheduling interval (in seconds) - * @see Datacenter#getSchedulingInterval() - */ + /// Datacenter scheduling interval (in seconds) + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 1; private static final int HOSTS = 4; @@ -113,10 +109,8 @@ private CostsExample1() { printTotalVmsCost(); } - /** - * Creates a broker which is a software acting on behalf of a cloud customer to manage his/her VMs and Cloudlets. - * It disables VM creation retry, so that VMs that can't be placed are just added to the {@link DatacenterBroker#getVmFailedList()}. - */ + /// Creates a broker which is a software acting on behalf of a cloud customer to manage his/her VMs and Cloudlets. + /// It disables VM creation retry, so that VMs that can't be placed are just added to the [DatacenterBroker#getVmFailedList()]. private DatacenterBroker createBroker() { final var broker = new DatacenterBrokerSimple(simulation); //Disables VM creation retry, so that VMs that can't be placed are just added to the broker's failed VM list @@ -127,9 +121,7 @@ private DatacenterBroker createBroker() { return broker; } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -164,9 +156,7 @@ private Host createHost() { return new HostSimple(ram, bw, storage, peList); } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var vmList = new ArrayList(VMS); for (int id = 0; id < VMS; id++) { @@ -179,9 +169,7 @@ private List createVms() { return vmList; } - /** - * Creates Cloudlets only for some VMs. - */ + /// Creates Cloudlets only for some VMs. private List createCloudlets() { final var newCloudletList = new ArrayList(VMS * CLOUDLET_BY_VM); @@ -203,10 +191,8 @@ private List createCloudlets() { return newCloudletList; } - /** - * Computes and print the cost ($) of resources (processing, bw, memory, storage) - * for each VM inside the datacenter. - */ + /// Computes and print the cost ($) of resources (processing, bw, memory, storage) + /// for each VM inside the datacenter. private void printTotalVmsCost() { System.out.println(); double totalCost = 0.0; diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/CreateCloudletAfterLastFinishedOne.java b/src/main/java/org/cloudsimplus/examples/dynamic/CreateCloudletAfterLastFinishedOne.java index 79df1ec..5a40123 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/CreateCloudletAfterLastFinishedOne.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/CreateCloudletAfterLastFinishedOne.java @@ -47,19 +47,17 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to dynamically create one Cloudlet after the previous one finishes. - * It stops creating Cloudlets when the number reaches {@link #CLOUDLETS}. - * - *

      This example uses CloudSim Plus Listener features to intercept when - * the a Cloudlet finishes its execution to then request - * the creation of a new Cloudlet. It uses the Java 8+ Lambda Functions features - * to pass a listener to the mentioned Cloudlet, by means of the - * {@link Cloudlet#addOnFinishListener(EventListener)} method.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 2.2.0 - */ +/// An example showing how to dynamically create one Cloudlet after the previous one finishes. +/// It stops creating Cloudlets when the number reaches [#CLOUDLETS]. +/// +/// This example uses CloudSim Plus Listener features to intercept when +/// the a Cloudlet finishes its execution to then request +/// the creation of a new Cloudlet. It uses the Java 8+ Lambda Functions features +/// to pass a listener to the mentioned Cloudlet, by means of the +/// [Cloudlet#addOnFinishListener(EventListener)] method. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 2.2.0 public class CreateCloudletAfterLastFinishedOne { private static final int HOSTS = 2; private static final int VMS = 4; @@ -74,19 +72,15 @@ public class CreateCloudletAfterLastFinishedOne { private final Datacenter datacenter; private final CloudSimPlus simulation; - /** - * Starts the example execution, calling the class constructor\ - * to build and run the simulation. - * - * @param args command line parameters - */ + /// Starts the example execution, calling the class constructor\ + /// to build and run the simulation. + /// + /// @param args command line parameters public static void main(String[] args) { new CreateCloudletAfterLastFinishedOne(); } - /** - * Default constructor that builds and starts the simulation. - */ + /// Default constructor that builds and starts the simulation. private CreateCloudletAfterLastFinishedOne() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -124,12 +118,9 @@ private List createAndSubmitVms() { return newVmList; } - /** - * Creates a VM with pre-defined configuration. - * - * @return the created VM - * - */ + /// Creates a VM with pre-defined configuration. + /// + /// @return the created VM private Vm createVm() { final int mips = 1000; @@ -138,13 +129,11 @@ private Vm createVm() { .setCloudletScheduler(new CloudletSchedulerTimeShared()); } - /** - * Creates and submit one Cloudlet, - * defining an Event Listener that is notified when such a Cloudlet - * is finished in order to create another one. - * Cloudlets stop to be created when the - * number of Cloudlets reaches {@link #CLOUDLETS}. - */ + /// Creates and submit one Cloudlet, + /// defining an Event Listener that is notified when such a Cloudlet + /// is finished in order to create another one. + /// Cloudlets stop to be created when the + /// number of Cloudlets reaches [#CLOUDLETS]. private void createAndSubmitOneCloudlet() { final int id = cloudletList.size(); final long length = 10000; //in number of Million Instructions (MI) @@ -170,11 +159,9 @@ private void cloudletFinishListener(final CloudletVmEventInfo info) { createAndSubmitOneCloudlet(); } - /** - * Creates a Datacenter with pre-defined configuration. - * - * @return the created Datacenter - */ + /// Creates a Datacenter with pre-defined configuration. + /// + /// @return the created Datacenter private Datacenter createDatacenter() { for (int i = 0; i < HOSTS; i++) { hostList.add(createHost(i)); @@ -183,12 +170,10 @@ private Datacenter createDatacenter() { return new DatacenterSimple(simulation, hostList); } - /** - * Creates a host with pre-defined configuration. - * - * @param id The Host id - * @return the created host - */ + /// Creates a host with pre-defined configuration. + /// + /// @param id The Host id + /// @return the created host private Host createHost(int id) { final var peList = new ArrayList(); long mips = 1000; diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCloudletsArrival1.java b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCloudletsArrival1.java index 7406145..de118bc 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCloudletsArrival1.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCloudletsArrival1.java @@ -46,32 +46,24 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to delay the submission of cloudlets. - * Although there is enough resources to run all cloudlets simultaneously, - * the example delays the creation and execution of some cloudlets inside a VM, - * simulating the dynamic arrival of cloudlets. - * It first creates a set of cloudlets without delay and - * another set of cloudlets all with the same submission delay. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - */ +/// An example showing how to delay the submission of cloudlets. +/// Although there is enough resources to run all cloudlets simultaneously, +/// the example delays the creation and execution of some cloudlets inside a VM, +/// simulating the dynamic arrival of cloudlets. +/// It first creates a set of cloudlets without delay and +/// another set of cloudlets all with the same submission delay. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 public class DynamicCloudletsArrival1 { - /** - * Number of Processor Elements (CPU Cores) of each Host. - */ + /// Number of Processor Elements (CPU Cores) of each Host. private static final int HOST_PES_NUMBER = 8; - /** - * Number of Processor Elements (CPU Cores) of each VM and cloudlet. - */ + /// Number of Processor Elements (CPU Cores) of each VM and cloudlet. private static final int VM_PES_NUMBER = HOST_PES_NUMBER/2; - /** - * Number of Cloudlets to create simultaneously. - * Other cloudlets will be enqueued. - */ + /// Number of Cloudlets to create simultaneously. + /// Other cloudlets will be enqueued. private static final int NUMBER_OF_CLOUDLETS = VM_PES_NUMBER*2; private final List hostList; @@ -81,19 +73,15 @@ public class DynamicCloudletsArrival1 { private final Datacenter datacenter; private final CloudSimPlus simulation; - /** - * Starts the example execution, calling the class constructor\ - * to build and run the simulation. - * - * @param args command line parameters - */ + /// Starts the example execution, calling the class constructor\ + /// to build and run the simulation. + /// + /// @param args command line parameters public static void main(String[] args) { new DynamicCloudletsArrival1(); } - /** - * Default constructor that builds and starts the simulation. - */ + /// Default constructor that builds and starts the simulation. private DynamicCloudletsArrival1() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -134,15 +122,13 @@ private void runSimulationAndPrintResults() { .build(); } - /** - * Creates cloudlets and submit them to the broker, applying - * a submission delay for each one (simulating the dynamic cloudlet arrival). - * - * @param vm Vm to run the cloudlets to be created - * @param submissionDelay the delay the broker has to include when submitting the Cloudlets - * - * @see #createCloudlet(Vm) - */ + /// Creates cloudlets and submit them to the broker, applying + /// a submission delay for each one (simulating the dynamic cloudlet arrival). + /// + /// @param vm Vm to run the cloudlets to be created + /// @param submissionDelay the delay the broker has to include when submitting the Cloudlets + /// + /// @see #createCloudlet(Vm) private void createAndSubmitCloudlets(Vm vm, double submissionDelay) { final var newCloudletList = new ArrayList(NUMBER_OF_CLOUDLETS); for(int i = 0; i < NUMBER_OF_CLOUDLETS; i++){ @@ -154,11 +140,9 @@ private void createAndSubmitCloudlets(Vm vm, double submissionDelay) { cloudletList.addAll(newCloudletList); } - /** - * Creates one Vm and a group of cloudlets to run inside it, - * and submit the Vm and its cloudlets to the broker. - * @see #createVm() - */ + /// Creates one Vm and a group of cloudlets to run inside it, + /// and submit the Vm and its cloudlets to the broker. + /// @see #createVm() private void createAndSubmitVmAndCloudlets(final double submissionDelay) { final var newVmList = new ArrayList(); final var vm = createVm(); @@ -182,12 +166,10 @@ private Vm createVm() { .setCloudletScheduler(new CloudletSchedulerTimeShared()); } - /** - * Creates a cloudlet with pre-defined configuration. - * - * @param vm vm to run the cloudlet - * @return the created cloudlet - */ + /// Creates a cloudlet with pre-defined configuration. + /// + /// @param vm vm to run the cloudlet + /// @return the created cloudlet private Cloudlet createCloudlet(Vm vm) { final long fileSize = 300; final long outputSize = 300; @@ -207,23 +189,19 @@ private Cloudlet createCloudlet(Vm vm) { return cloudlet; } - /** - * Creates a Datacenter with pre-defined configuration. - * - * @return the created Datacenter - */ + /// Creates a Datacenter with pre-defined configuration. + /// + /// @return the created Datacenter private Datacenter createDatacenter() { final var host = createHost(0); hostList.add(host); return new DatacenterSimple(simulation, hostList); } - /** - * Creates a host with pre-defined configuration. - * - * @param id The Host id - * @return the created host - */ + /// Creates a host with pre-defined configuration. + /// + /// @param id The Host id + /// @return the created host private Host createHost(int id) { final var peList = new ArrayList(); final long mips = 1000; diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCloudletsArrival2.java b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCloudletsArrival2.java index a1eb31c..760b698 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCloudletsArrival2.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCloudletsArrival2.java @@ -45,36 +45,28 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to delay the submission of cloudlets. - * Although there is enough resources to run all cloudlets simultaneously, - * the example delays the creation of each cloudlet inside a VM, - * simulating the dynamic arrival of cloudlets. - * For each instantiated cloudlet will be defined a different - * submission delay. - * Even there is enough resources to run all cloudlets simultaneously, - * it is used a CloudletSchedulerTimeShared, analyzing the output - * you can see that each cloudlet starts in a different time, - * simulating different arrivals. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - */ +/// An example showing how to delay the submission of cloudlets. +/// Although there is enough resources to run all cloudlets simultaneously, +/// the example delays the creation of each cloudlet inside a VM, +/// simulating the dynamic arrival of cloudlets. +/// For each instantiated cloudlet will be defined a different +/// submission delay. +/// Even there is enough resources to run all cloudlets simultaneously, +/// it is used a CloudletSchedulerTimeShared, analyzing the output +/// you can see that each cloudlet starts in a different time, +/// simulating different arrivals. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 public class DynamicCloudletsArrival2 { - /** - * Number of Processor Elements (CPU Cores) of each Host. - */ + /// Number of Processor Elements (CPU Cores) of each Host. private static final int HOST_PES_NUMBER = 4; - /** - * Number of Processor Elements (CPU Cores) of each VM and cloudlet. - */ + /// Number of Processor Elements (CPU Cores) of each VM and cloudlet. private static final int VM_PES_NUMBER = HOST_PES_NUMBER; - /** - * Number of Cloudlets to create simultaneously. - * Other cloudlets will be enqueued. - */ + /// Number of Cloudlets to create simultaneously. + /// Other cloudlets will be enqueued. private static final int NUMBER_OF_CLOUDLETS = VM_PES_NUMBER; private final List hostList; @@ -84,19 +76,15 @@ public class DynamicCloudletsArrival2 { private final Datacenter datacenter; private final CloudSimPlus simulation; - /** - * Starts the example execution, calling the class constructor\ - * to build and run the simulation. - * - * @param args command line parameters - */ + /// Starts the example execution, calling the class constructor\ + /// to build and run the simulation. + /// + /// @param args command line parameters public static void main(String[] args) { new DynamicCloudletsArrival2(); } - /** - * Default constructor that builds and starts the simulation. - */ + /// Default constructor that builds and starts the simulation. private DynamicCloudletsArrival2() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -123,14 +111,12 @@ private void runSimulationAndPrintResults() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Creates cloudlets and submit them to the broker, applying - * a different submission delay for each one (simulating the dynamic cloudlet arrival). - * - * @param vm Vm to run the cloudlets to be created - * - * @see #createCloudlet(int, Vm, DatacenterBroker) - */ + /// Creates cloudlets and submit them to the broker, applying + /// a different submission delay for each one (simulating the dynamic cloudlet arrival). + /// + /// @param vm Vm to run the cloudlets to be created + /// + /// @see #createCloudlet(int, Vm, DatacenterBroker) private void createAndSubmitCloudlets(Vm vm) { int cloudletId = cloudletList.size(); double submissionDelay = 0; @@ -146,12 +132,10 @@ private void createAndSubmitCloudlets(Vm vm) { cloudletList.addAll(newCloudletList); } - /** - * Creates one Vm and a group of cloudlets to run inside it, - * and submit the Vm and its cloudlets to the broker. - * - * @see #createVm(int, DatacenterBroker) - */ + /// Creates one Vm and a group of cloudlets to run inside it, + /// and submit the Vm and its cloudlets to the broker. + /// + /// @see #createVm(int, DatacenterBroker) private void createAndSubmitVmAndCloudlets() { final var newVmList = new ArrayList(); final var vm = createVm(this.vmList.size(), broker); @@ -163,14 +147,11 @@ private void createAndSubmitVmAndCloudlets() { createAndSubmitCloudlets(vm); } - /** - * Creates a VM with pre-defined configuration. - * - * @param id the VM id - * @param broker the broker that will be submit the VM - * @return the created VM - * - */ + /// Creates a VM with pre-defined configuration. + /// + /// @param id the VM id + /// @param broker the broker that will be submit the VM + /// @return the created VM private Vm createVm(int id, DatacenterBroker broker) { final int mips = 1000; final long size = 10000; // image size (Megabyte) @@ -182,14 +163,12 @@ private Vm createVm(int id, DatacenterBroker broker) { .setCloudletScheduler(new CloudletSchedulerTimeShared()); } - /** - * Creates a cloudlet with pre-defined configuration. - * - * @param id Cloudlet id - * @param vm vm to run the cloudlet - * @param broker the broker that will submit the cloudlets - * @return the created cloudlet - */ + /// Creates a cloudlet with pre-defined configuration. + /// + /// @param id Cloudlet id + /// @param vm vm to run the cloudlet + /// @param broker the broker that will submit the cloudlets + /// @return the created cloudlet private Cloudlet createCloudlet(int id, Vm vm, DatacenterBroker broker) { final long fileSize = 300; final long outputSize = 300; @@ -205,11 +184,9 @@ private Cloudlet createCloudlet(int id, Vm vm, DatacenterBroker broker) { .setVm(vm); } - /** - * Creates a Datacenter with pre-defined configuration. - * - * @return the created Datacenter - */ + /// Creates a Datacenter with pre-defined configuration. + /// + /// @return the created Datacenter private Datacenter createDatacenter() { final var host = createHost(0); hostList.add(host); @@ -217,12 +194,10 @@ private Datacenter createDatacenter() { return new DatacenterSimple(simulation, hostList); } - /** - * Creates a host with pre-defined configuration. - * - * @param id The Host id - * @return the created host - */ + /// Creates a host with pre-defined configuration. + /// + /// @param id The Host id + /// @return the created host private Host createHost(int id) { final var peList = new ArrayList(); final long mips = 1000; diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCreationOfVmsAndCloudletsExample.java b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCreationOfVmsAndCloudletsExample.java index cf31a9f..0dc4ce8 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCreationOfVmsAndCloudletsExample.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCreationOfVmsAndCloudletsExample.java @@ -45,24 +45,22 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to dynamically create VMs and Cloudlets during simulation - * executing using the exclusive CloudSim Plus {@link DatacenterBroker} implementations - * and Listener features. Using such features, it is not required to create DatacenterBrokers in runtime - * in order to allow dynamic submission of VMs and Cloudlets. - * - *

      This example uses CloudSim Plus Listener features to intercept when - * the first Cloudlet finishes its execution to then request - * the creation of new VMs and Cloudlets. It uses the Java 8+ Lambda Functions features - * to pass a listener to the mentioned Cloudlet, by means of the - * {@link Cloudlet#addOnFinishListener(EventListener)} method.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - * - * @see Cloudlet#addOnFinishListener(EventListener) - * @see EventListener - */ +/// An example showing how to dynamically create VMs and Cloudlets during simulation +/// executing using the exclusive CloudSim Plus [DatacenterBroker] implementations +/// and Listener features. Using such features, **it is not required to create DatacenterBrokers in runtime +/// in order to allow dynamic submission of VMs and Cloudlets.** +/// +/// This example uses CloudSim Plus Listener features to intercept when +/// the first Cloudlet finishes its execution to then request +/// the creation of new VMs and Cloudlets. It uses the Java 8+ Lambda Functions features +/// to pass a listener to the mentioned Cloudlet, by means of the +/// [Cloudlet#addOnFinishListener(EventListener)] method. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 +/// +/// @see Cloudlet#addOnFinishListener(EventListener) +/// @see EventListener public class DynamicCreationOfVmsAndCloudletsExample { private final CloudSimPlus simulation; private final DatacenterBrokerSimple broker0; @@ -75,9 +73,7 @@ public static void main(String[] args) { new DynamicCreationOfVmsAndCloudletsExample(); } - /** - * Default constructor that builds the simulation. - */ + /// Default constructor that builds the simulation. private DynamicCreationOfVmsAndCloudletsExample() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -132,11 +128,9 @@ private void createAndSubmitVmsAndCloudlets(int vmsToCreate, int cloudletsToCrea broker0.submitCloudletList(newCloudletList); } - /** - * Dynamically creates and submits a set of VMs to the broker when - * the first cloudlet finishes. - * @param eventInfo information about the fired event - */ + /// Dynamically creates and submits a set of VMs to the broker when + /// the first cloudlet finishes. + /// @param eventInfo information about the fired event private void submitNewVmsAndCloudletsToBroker(CloudletVmEventInfo eventInfo) { final int numberOfNewVms = 2; final int numberOfCloudletsByVm = 4; diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicHostCreation.java b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicHostCreation.java index 37c656c..f773ad0 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicHostCreation.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicHostCreation.java @@ -48,57 +48,50 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to create Hosts at simulation runtime, - * enabling to simulate the physical expansion of a Datacenter by - * the addition of new Hosts (PMs). - * The example starts by creating 2 hosts and 4 VMs (2 VMs for each Host). - * Then it creates 4 Cloudlets (1 for each VM). - * - *

      After the simulation starts and reaches 5 seconds (defined in {@link #SCHEDULING_INTERVAL}), - * it's created a new Host and VM. Two new Cloudlets are created for this new VM - * the Cloudlets and the VM is submitted by the broker to the Datacenter. - * Since the Hosts created before starting the simulation - * don't have enough PEs to place this new VM, the {@link VmAllocationPolicy} - * will chose the 5th Host (created dynamically) to place that VM - * and run the Cloudlets. - *

      - * - *

      Since these two new Cloudlets are running in the same VM, - * which is using a {@link CloudletSchedulerTimeShared}, and there aren't - * enough VM PEs for all the 2 Cloudlets, they will spend the double of the time to finish, - * because they will share the VM PEs. - * Realize that the start time of these 2 dynamically created Cloudlets is 5, - * showing they were submitted to the broker just that time. - *

      - * - *

      To allow track the simulation time and know when the clock is in 5 seconds, - * it is required to call {@link Datacenter#setSchedulingInterval(double)} - * to set the scheduling interval. Check the method documentation for more details. - * This example uses the CloudSim Plus Listener features to enable your simulation - * to be notified when some event happens. - * In this case, it's being used the {@link CloudSimPlus#addOnClockTickListener(EventListener)} - * to pass a {@link EventListener} object that will be notified - * when the simulation clock advances. - *

      - * - *

      In fact, this {@link EventListener} is a Java 8+ {@link FunctionalInterface} - * that enables using Lambda Expression - * or method references in order to provide a {@link FunctionalInterface}. - * This example uses a reference to the {@link #clockTickListener(EventInfo)} method - * as being the {@link EventListener} required by the {@link CloudSimPlus#addOnClockTickListener(EventListener)}.

      - * - *

      Lambda Expressions, method references and Functional Interfaces are Java 8+ features. - * If you don't know what these features are, I suggest checking out this - * tutorial

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.3.0 - */ +/// An example showing how to create Hosts at simulation runtime, +/// enabling to simulate the physical expansion of a Datacenter by +/// the addition of new Hosts (PMs). +/// The example starts by creating 2 hosts and 4 VMs (2 VMs for each Host). +/// Then it creates 4 Cloudlets (1 for each VM). +/// +/// After the simulation starts and reaches 5 seconds (defined in [#SCHEDULING_INTERVAL]), +/// it's created a new Host and VM. Two new Cloudlets are created for this new VM +/// the Cloudlets and the VM is submitted by the broker to the Datacenter. +/// Since the Hosts created before starting the simulation +/// don't have enough PEs to place this new VM, the [VmAllocationPolicy] +/// will chose the 5th Host (created dynamically) to place that VM +/// and run the Cloudlets. +/// +/// Since these two new Cloudlets are running in the same VM, +/// which is using a [CloudletSchedulerTimeShared], and there aren't +/// enough VM PEs for all the 2 Cloudlets, they will spend the double of the time to finish, +/// because they will share the VM PEs. +/// Realize that the start time of these 2 dynamically created Cloudlets is 5, +/// showing they were submitted to the broker just that time. +/// +/// To allow track the simulation time and know when the clock is in 5 seconds, +/// it is required to call [Datacenter#setSchedulingInterval(double)] +/// to set the scheduling interval. Check the method documentation for more details. +/// This example uses the CloudSim Plus Listener features to enable your simulation +/// to be notified when some event happens. +/// In this case, it's being used the [CloudSimPlus#addOnClockTickListener(EventListener)] +/// to pass a [EventListener] object that will be notified +/// when the simulation clock advances. +/// +/// In fact, this [EventListener] is a Java 8+ [FunctionalInterface] +/// that enables using Lambda Expression +/// or method references in order to provide a [FunctionalInterface]. +/// This example uses a reference to the [#clockTickListener(EventInfo)] method +/// as being the [EventListener] required by the [CloudSimPlus#addOnClockTickListener(EventListener)]. +/// +/// **Lambda Expressions, method references and Functional Interfaces are Java 8+ features.** +/// If you don't know what these features are, I suggest checking out this +/// [tutorial](http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html) +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.3.0 public class DynamicHostCreation { - /** - * @see Datacenter#getSchedulingInterval() - */ + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 5; private static final int HOSTS = 2; @@ -143,10 +136,8 @@ private DynamicHostCreation() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Event listener which is called every time the simulation clock advances. - * @param info information about the event happened. - */ + /// Event listener which is called every time the simulation clock advances. + /// @param info information about the event happened. private void clockTickListener(final EventInfo info) { final int time = (int)info.getTime(); @@ -173,9 +164,7 @@ private void clockTickListener(final EventInfo info) { } } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -204,9 +193,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms(final int count) { final var newVmList = new ArrayList(count); for (int i = 0; i < count; i++) { diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmAllocationPolicyBestFitExample.java b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmAllocationPolicyBestFitExample.java index 975d927..83348f8 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmAllocationPolicyBestFitExample.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmAllocationPolicyBestFitExample.java @@ -72,37 +72,34 @@ import java.util.Optional; import java.util.function.Function; -/** - * An example showing how to create 1 Datacenter with 5 hosts, - * 1 VM by host and 1 cloudlet by VM and perform VM allocation by - * using Java 8+ Functional Programming to change, at runtime, the - * policy used by a {@link VmAllocationPolicy}. - * - *

      VMs are allocated based on a Best Fit allocation policy, which - * selects the suitable Host with the lowest number of available PEs - * that is enough to run the VM. - * This policy is dynamically defined by changing the {@link Function} - * of the {@link VmAllocationPolicy}, without requiring to create - * a new class. The {@link VmAllocationPolicySimple} used in this example ignores power usage of - * Hosts. This way, it isn't required to set a PowerModel for Hosts. - *

      - * - * It is used some constants to create simulation objects such as - * {@link DatacenterSimple}, {@link Host} and {@link Vm}. - * The values of these constants were careful and accordingly chosen to allow - * migration of VMs due to either under and overloaded hosts and - * to allow one developer to know exactly how the simulation will run - * and what will be the final results. - * Several values impact the simulation results, such as - * hosts CPU capacity and number of PEs, VMs and cloudlets requirements - * and even VM bandwidth (that defines the VM migration time). - * - *

      This way, if you want to change these values, you must - * define new appropriated ones to allow the simulation - * to run correctly.

      - * - * @author Manoel Campos da Silva Filho - */ +/// An example showing how to create 1 Datacenter with 5 hosts, +/// 1 VM by host and 1 cloudlet by VM and perform VM allocation by +/// using Java 8+ Functional Programming to change, at runtime, the +/// policy used by a [VmAllocationPolicy]. +/// +/// VMs are allocated based on a **Best Fit allocation policy**, which +/// selects the suitable Host with the lowest number of available PEs +/// that is enough to run the VM. +/// This policy is dynamically defined by changing the [Function] +/// of the [VmAllocationPolicy], without requiring to create +/// a new class. The [VmAllocationPolicySimple] used in this example ignores power usage of +/// Hosts. This way, it isn't required to set a PowerModel for Hosts. +/// +/// It is used some constants to create simulation objects such as +/// [DatacenterSimple], [Host] and [Vm]. +/// The values of these constants were careful and accordingly chosen to allow +/// migration of VMs due to either under and overloaded hosts and +/// to allow one developer to know exactly how the simulation will run +/// and what will be the final results. +/// Several values impact the simulation results, such as +/// hosts CPU capacity and number of PEs, VMs and cloudlets requirements +/// and even VM bandwidth (that defines the VM migration time). +/// +/// This way, if you want to change these values, you must +/// define new appropriated ones to allow the simulation +/// to run correctly. +/// +/// @author Manoel Campos da Silva Filho public final class DynamicVmAllocationPolicyBestFitExample { private static final int SCHEDULE_INTERVAL = 5; @@ -127,9 +124,7 @@ public final class DynamicVmAllocationPolicyBestFitExample { private static final long CLOUDLET_FILESIZE = 300; private static final long CLOUDLET_OUTPUTSIZE = 300; - /** - * List of all created VMs. - */ + /// List of all created VMs. private final List vmList = new ArrayList<>(); private CloudSimPlus simulation; @@ -163,17 +158,15 @@ private DynamicVmAllocationPolicyBestFitExample(){ System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * A method that defines a Best Fit policy to select a suitable Host with the least - * available PEs to place a VM. - * Using Java 8+ Functional Programming, this method is given as parameter - * to the constructor of a {@link VmAllocationPolicySimple} - * - * @param allocationPolicy the {@link VmAllocationPolicy} that is trying to allocate a Host for the requesting VM - * @param vm the VM to find a host to - * @return an {@link Optional} which may contain a Host or an empty Optional if no suitable Host was found - * @see #createDatacenter() - */ + /// A method that defines a Best Fit policy to select a suitable Host with the least + /// available PEs to place a VM. + /// Using Java 8+ Functional Programming, this method is given as parameter + /// to the constructor of a [VmAllocationPolicySimple] + /// + /// @param allocationPolicy the [VmAllocationPolicy] that is trying to allocate a Host for the requesting VM + /// @param vm the VM to find a host to + /// @return an [`Optional`][java.util.Optional] which may contain a Host or an empty Optional if no suitable Host was found + /// @see #createDatacenter() private Optional bestFitHostSelectionPolicy(VmAllocationPolicy allocationPolicy, Vm vm) { return allocationPolicy .getHostList() @@ -191,13 +184,11 @@ public void createAndSubmitCloudlets(DatacenterBroker broker) { broker.submitCloudletList(newCloudletList); } - /** - * Creates a Cloudlet. - * - * @param vm the VM that will run the Cloudlets - * @param broker the broker that the created Cloudlets belong to - * @return the created Cloudlets - */ + /// Creates a Cloudlet. + /// + /// @param vm the VM that will run the Cloudlets + /// @param broker the broker that the created Cloudlets belong to + /// @return the created Cloudlets public Cloudlet createCloudlet(Vm vm, DatacenterBroker broker) { final var cloudlet = new CloudletSimple(CLOUDLET_LENGHT, (int)vm.getPesNumber()) @@ -227,12 +218,10 @@ public Vm createVm(int pes) { return vm; } - /** - * Creates a Datacenter with number of Hosts defined by {@link #HOSTS}, - * but only some of these Hosts will be active (powered on) initially. - * - * @return - */ + /// Creates a Datacenter with number of Hosts defined by [#HOSTS], + /// but only some of these Hosts will be active (powered on) initially. + /// + /// @return private Datacenter createDatacenter() { for(int i = 0; i < HOSTS; i++){ final int pes = HOST_INITIAL_PES + i; diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmsArrival.java b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmsArrival.java index 8993e49..d859c86 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmsArrival.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmsArrival.java @@ -44,48 +44,40 @@ import java.util.Comparator; import java.util.List; -/** - * An example showing how to delay the submission of VMs. - * The first VMs are created because there are enough resources to run them. - * The delayed VMs are created only after the first ones finish, - * so that there will be available resources to run them. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.3.1 - */ +/// An example showing how to delay the submission of VMs. +/// The first VMs are created because there are enough resources to run them. +/// The delayed VMs are created only after the first ones finish, +/// so that there will be available resources to run them. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.3.1 public class DynamicVmsArrival { private static final int HOSTS = 2; - /** Number of Processor Elements (CPU Cores) of each Host. */ + /// Number of Processor Elements (CPU Cores) of each Host. private static final int HOST_PES = 2; private static final double HOST_MIPS = 1000; - /** Number of Processor Elements (CPU Cores) of each VM and cloudlet. */ + /// Number of Processor Elements (CPU Cores) of each VM and cloudlet. private static final int VM_PES = 1; - /** - * Number of VMs to create. - * If you try to increase this number without increases Hosts, - * you'll see that the additional VMs won't be created because there are no - * suitable Hosts. - */ + /// Number of VMs to create. + /// If you try to increase this number without increases Hosts, + /// you'll see that the additional VMs won't be created because there are no + /// suitable Hosts. private static final int VMS = 4; - /** Number of Cloudlets to create simultaneously. */ + /// Number of Cloudlets to create simultaneously. private static final int CLOUDLETS = VMS; - /** The length of each Cloudlet in number of Million Instructions (MI) */ + /// The length of each Cloudlet in number of Million Instructions (MI) private static final int CLOUDLET_LENGTH = 10000; private static final int CLOUDLET_PES = 1; - /** - * The time to wait before destroying a VM after it becomes idle (in seconds). - */ + /// The time to wait before destroying a VM after it becomes idle (in seconds). public static final int IDLE_VM_DESTRUCTION_DELAY = 1; - /** - * The time the Cloudlets are expected to finish, - * when the creation of new VMs will be requested (in seconds). - * After at that time, there will be suitable Hosts available. - */ + /// The time the Cloudlets are expected to finish, + /// when the creation of new VMs will be requested (in seconds). + /// After at that time, there will be suitable Hosts available. private static final double EXPECTED_CLOUDLET_FINISH_TIME = CLOUDLET_LENGTH / HOST_MIPS + IDLE_VM_DESTRUCTION_DELAY + 1; private final List hostList; @@ -95,19 +87,15 @@ public class DynamicVmsArrival { private final Datacenter datacenter; private final CloudSimPlus simulation; - /** - * Starts the example execution, calling the class constructor\ - * to build and run the simulation. - * - * @param args command line parameters - */ + /// Starts the example execution, calling the class constructor\ + /// to build and run the simulation. + /// + /// @param args command line parameters public static void main(String[] args) { new DynamicVmsArrival(); } - /** - * Default constructor that builds and starts the simulation. - */ + /// Default constructor that builds and starts the simulation. private DynamicVmsArrival() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -132,13 +120,11 @@ private DynamicVmsArrival() { System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * Creates a broker defining that idle VMs will be destructed after some delay, - * instead of waiting the broker to shut down to destroy them. - * This enables freeing Hosts to place new VMs. - * - * @return - */ + /// Creates a broker defining that idle VMs will be destructed after some delay, + /// instead of waiting the broker to shut down to destroy them. + /// This enables freeing Hosts to place new VMs. + /// + /// @return private DatacenterBroker createBroker() { final var broker = new DatacenterBrokerSimple(simulation); broker.setVmDestructionDelay(IDLE_VM_DESTRUCTION_DELAY); @@ -152,11 +138,9 @@ private void runSimulationAndPrintResults() { new CloudletsTableBuilder(cloudletList).build(); } - /** - * Creates and submits a list of VMs and Cloudlets. - * - * @param submissionDelay the time to wait before requesting the VM creation - */ + /// Creates and submits a list of VMs and Cloudlets. + /// + /// @param submissionDelay the time to wait before requesting the VM creation private void createdAndSubmitVmsAndCloudlets(final double submissionDelay) { final var newVmList = createAndSubmitVms(submissionDelay); this.vmList.addAll(newVmList); @@ -172,12 +156,10 @@ private void createdAndSubmitVmsAndCloudlets(final double submissionDelay) { System.out.println(); } - /** - * Creates and submits a list of VMs. - * - * @param submissionDelay the time to wait before requesting the VM creation - * @return - */ + /// Creates and submits a list of VMs. + /// + /// @param submissionDelay the time to wait before requesting the VM creation + /// @return private List createAndSubmitVms(final double submissionDelay) { final var newVmList = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -188,12 +170,10 @@ private List createAndSubmitVms(final double submissionDelay) { return newVmList; } - /** - * Creates a VM with pre-defined configuration. - * - * @param submissionDelay the time to wait before requesting the VM creation - * @return the created VM - */ + /// Creates a VM with pre-defined configuration. + /// + /// @param submissionDelay the time to wait before requesting the VM creation + /// @return the created VM private Vm createVm(final double submissionDelay) { final int mips = 1000; final long size = 10000; // image size (Megabyte) @@ -208,12 +188,10 @@ private Vm createVm(final double submissionDelay) { return vm; } - /** - * Creates one Cloudlet for each VM in the given List. - * - * @param vms the List fo VMs to create Cloudlets to - * @return the List of Cloudlets - */ + /// Creates one Cloudlet for each VM in the given List. + /// + /// @param vms the List fo VMs to create Cloudlets to + /// @return the List of Cloudlets private List createAndSubmitCloudlets(final List vms) { final var newCloudletList = new ArrayList(CLOUDLETS); for (final Vm vm : vms) { @@ -224,12 +202,10 @@ private List createAndSubmitCloudlets(final List vms) { return newCloudletList; } - /** - * Creates a cloudlet with pre-defined configuration. - * - * @param vm vm to run the cloudlet - * @return the created cloudlet - */ + /// Creates a cloudlet with pre-defined configuration. + /// + /// @param vm vm to run the cloudlet + /// @return the created cloudlet private Cloudlet createCloudlet(final Vm vm) { final var utilizationModelFull = new UtilizationModelFull(); final var utilizationModelDynamic = new UtilizationModelDynamic(0.2); @@ -241,11 +217,9 @@ private Cloudlet createCloudlet(final Vm vm) { .setVm(vm); } - /** - * Creates a Datacenter with pre-defined configuration. - * - * @return the created Datacenter - */ + /// Creates a Datacenter with pre-defined configuration. + /// + /// @return the created Datacenter private Datacenter createDatacenter() { for (int i = 0; i < HOSTS; i++) { hostList.add(createHost()); @@ -254,11 +228,9 @@ private Datacenter createDatacenter() { return new DatacenterSimple(simulation, hostList); } - /** - * Creates a host with pre-defined configuration. - * - * @return the created host - */ + /// Creates a host with pre-defined configuration. + /// + /// @return the created host private Host createHost() { final var peList = new ArrayList(); for (int i = 0; i < HOST_PES; i++) { diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmsArrival2.java b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmsArrival2.java index a556907..4f43711 100644 --- a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmsArrival2.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmsArrival2.java @@ -42,39 +42,30 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to submit VMs to the broker with different delays. - * This way, Cloudlets bound to such delayed VMs just start - * executing after the respective VM is placed into some Host. - * Since submitted cloudlets are not explicitly delayed, you can see in results - * that, at the end, they are delayed due to VM delay. - * - *

      Finally, considering there aren't enough hosts for all VMs, this example shows - * how to make the broker to destroy idle VMs after a while to open room for new VMs. - * Check {@link #createBroker()} for details. - *

      - * - * @author Fabian Mastenbroek - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 7.2.1 - */ +/// An example showing how to submit VMs to the broker with different delays. +/// This way, Cloudlets bound to such delayed VMs just start +/// executing after the respective VM is placed into some Host. +/// Since submitted cloudlets are not explicitly delayed, you can see in results +/// that, at the end, they are delayed due to VM delay. +/// +/// Finally, considering there aren't enough hosts for all VMs, this example shows +/// how to make the broker to destroy idle VMs after a while to open room for new VMs. +/// Check [#createBroker()] for details. +/// +/// @author Fabian Mastenbroek +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 7.2.1 public class DynamicVmsArrival2 { private static final int HOSTS = 1; - /** - * Number of Processor Elements (CPU Cores) of each Host. - */ + /// Number of Processor Elements (CPU Cores) of each Host. private static final int HOST_PES_NUMBER = 4; - /** - * Number of Processor Elements (CPU Cores) of each VM and cloudlet. - */ + /// Number of Processor Elements (CPU Cores) of each VM and cloudlet. private static final int VM_PES_NUMBER = 4; - /** - * Number of Cloudlets to create simultaneously. - * Other cloudlets will be enqueued. - */ + /// Number of Cloudlets to create simultaneously. + /// Other cloudlets will be enqueued. private static final int CLOUDLETS_NUMBER = VM_PES_NUMBER; private final List hostList; @@ -84,19 +75,15 @@ public class DynamicVmsArrival2 { private final Datacenter datacenter; private final CloudSimPlus simulation; - /** - * Starts the example execution, calling the class constructor\ - * to build and run the simulation. - * - * @param args command line parameters - */ + /// Starts the example execution, calling the class constructor\ + /// to build and run the simulation. + /// + /// @param args command line parameters public static void main(String[] args) { new DynamicVmsArrival2(); } - /** - * Default constructor that builds and starts the simulation. - */ + /// Default constructor that builds and starts the simulation. private DynamicVmsArrival2() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -117,13 +104,11 @@ private DynamicVmsArrival2() { System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * Creates a broker that destroys idle VMs after a while. - * Since we aren't creating enough hosts for all VMs, - * we need to destroy idle VMs to open room for new ones. - * By default, VM destruction just happens when the broker shuts down. - * @return - */ + /// Creates a broker that destroys idle VMs after a while. + /// Since we aren't creating enough hosts for all VMs, + /// we need to destroy idle VMs to open room for new ones. + /// By default, VM destruction just happens when the broker shuts down. + /// @return private DatacenterBroker createBroker() { return new DatacenterBrokerSimple(simulation).setVmDestructionDelay(1.0); } @@ -154,12 +139,10 @@ private void createAndSubmitVmsAndCloudlets() { this.cloudletList.addAll(newCloudletList); } - /** - * Creates a VM with pre-defined configuration. - * - * @param id the VM id - * @return the created VM - */ + /// Creates a VM with pre-defined configuration. + /// + /// @param id the VM id + /// @return the created VM private Vm createVm(final int id) { final int mips = 1000; final long size = 10000; // image size (Megabyte) @@ -169,13 +152,11 @@ private Vm createVm(final int id) { return new VmSimple(id, mips, VM_PES_NUMBER).setRam(ram).setBw(bw).setSize(size); } - /** - * Creates a cloudlet with pre-defined configuration. - * - * @param id Cloudlet id - * @param vm vm to run the cloudlet - * @return the created cloudlet - */ + /// Creates a cloudlet with pre-defined configuration. + /// + /// @param id Cloudlet id + /// @param vm vm to run the cloudlet + /// @return the created cloudlet private Cloudlet createCloudlet(final int id, final Vm vm) { final long fileSize = 300; final long outputSize = 300; @@ -190,11 +171,9 @@ private Cloudlet createCloudlet(final int id, final Vm vm) { .setVm(vm); } - /** - * Creates a Datacenter with pre-defined configuration. - * - * @return the created Datacenter - */ + /// Creates a Datacenter with pre-defined configuration. + /// + /// @return the created Datacenter private Datacenter createDatacenter() { for (int i = 0; i < HOSTS; i++) { hostList.add(createHost()); @@ -203,11 +182,9 @@ private Datacenter createDatacenter() { return new DatacenterSimple(simulation, hostList); } - /** - * Creates a host with pre-defined configuration. - * - * @return the created host - */ + /// Creates a host with pre-defined configuration. + /// + /// @return the created host private Host createHost() { final var peList = new ArrayList(); final long mips = 1000; diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/IndefiniteLengthCloudlet.java b/src/main/java/org/cloudsimplus/examples/dynamic/IndefiniteLengthCloudlet.java index 73b913c..f12b388 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/IndefiniteLengthCloudlet.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/IndefiniteLengthCloudlet.java @@ -46,24 +46,21 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to create Cloudlets with an indefinite length, - * so that each Cloudlet stops running only if: - *
        - *
      • (i) it reaches {@link Long#MAX_VALUE} MI executed or
      • - *
      • (ii) a positive length is dynamically defined (the time or event when the length of such Cloudlets are set - * can be defined in uncountable ways, according to developer needs)
      • - *
      • (iii) {@link CloudSimTag#CLOUDLET_FINISH} message is sent to the {@link DatacenterBroker}.
      • - *
      • (iv) the simulation is terminated by defining a termination time.
      • - *
      - * - * In this example it is called the {@link CloudSimPlus#terminateAt(double)} - * method to define when the simulation must finish. - * At that moment, the length of the Cloudlets is set so that they can finish executing. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.0.0 - */ +/// An example showing how to create Cloudlets with an indefinite length, +/// so that each Cloudlet stops running only if: +/// +/// - (i) it reaches [Long#MAX_VALUE] MI executed or +/// - (ii) a positive length is dynamically defined (the time or event when the length of such Cloudlets are set +/// can be defined in uncountable ways, according to developer needs) +/// - (iii) [CloudSimTag#CLOUDLET_FINISH] message is sent to the [DatacenterBroker]. +/// - (iv) the simulation is terminated by defining a termination time. +/// +/// In this example it is called the [CloudSimPlus#terminateAt(double)] +/// method to define when the simulation must finish. +/// At that moment, the length of the Cloudlets is set so that they can finish executing. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.0.0 public class IndefiniteLengthCloudlet { private static final int HOSTS = 1; private static final int HOST_PES = 8; @@ -75,14 +72,12 @@ public class IndefiniteLengthCloudlet { private static final int CLOUDLETS = 2; private static final int CLOUDLET_PES = 2; - /** - * Defines a negative length for Cloudlets so that - * they keep running until explicitly requested to finish. - * In this example, Cloudlets are finished only when - * the simulation termination time is reached. - * - * @see CloudSimPlus#terminateAt(double) - */ + /// Defines a negative length for Cloudlets so that + /// they keep running until explicitly requested to finish. + /// In this example, Cloudlets are finished only when + /// the simulation termination time is reached. + /// + /// @see CloudSimPlus#terminateAt(double) private static final int CLOUDLET_LENGTH = -10000; private final CloudSimPlus simulation; @@ -121,9 +116,7 @@ private IndefiniteLengthCloudlet() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -149,9 +142,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var newVmList = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -166,11 +157,9 @@ private List createVms() { return newVmList; } - /** - * Creates Cloudlets with indefinite length by setting a negative value. - * This way, the Cloudlets keep running until one of the conditions explained - * in the documentation of this class is met. - */ + /// Creates Cloudlets with indefinite length by setting a negative value. + /// This way, the Cloudlets keep running until one of the conditions explained + /// in the documentation of this class is met. private List createCloudlets() { final var newCloudletList = new ArrayList(CLOUDLETS); final var utilizationFull = new UtilizationModelFull(); diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/KeepSimulationRunningExample.java b/src/main/java/org/cloudsimplus/examples/dynamic/KeepSimulationRunningExample.java index b99ac23..a940fc2 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/KeepSimulationRunningExample.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/KeepSimulationRunningExample.java @@ -49,64 +49,52 @@ import java.util.ArrayList; import java.util.List; -/** - * Shows how to keep the simulation running, even - * when there is no event to be processed anymore. - * It calls the {@link Simulation#terminateAt(double)} to define - * the time the simulation must be terminated. - * - *

      The example is useful when you want to run a simulation - * for a specific amount of time. - * For instance, if you want to run a simulation for 24 hours, - * you just need to call {@code simulation.terminateAt(60*60*24)} (realize the value is in seconds).

      - * - *

      It creates 4 Cloudlets and 2 VMs statically. - * These Cloudlets will take 10 seconds to finish, but - * the simulation is set to terminate - * only after the time defined in {@link #TIME_TO_TERMINATE_SIMULATION}. - * - * This way, the simulation keeps waiting for dynamically - * arrived events. Then, at a {@link #TIME_TO_CREATE_NEW_CLOUDLET defined time}, - * new Cloudlets are created. - *

      - * - *

      The example uses the CloudSim Plus {@link EventListener} feature - * to enable monitoring the simulation and dynamically creating Cloudlets and VMs at runtime. - * It relies on - * Java 8 Method References - * to set a method to be called for {@link Simulation#addOnClockTickListener(EventListener) onClockTick events}. - * It enables getting notifications when the simulation clock advances, then creating and submitting new cloudlets. - *

      - * - *

      Since the simulation was set to keep waiting for new events - * until a defined time, the clock will be updated - * even if no event arrives, to simulate time passing. - * Check the {@link Simulation#terminateAt(double)} for details. - *

      - * - *

      At the time defined in {@link #TIME_TO_CREATE_NEW_CLOUDLET}, - * 1 Cloudlet and 1 VM is created, so the results will show 5 Cloudlets. - * The simulation will just end at the specified time. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 2.3.0 - * @see RandomCloudletsArrivalExample - */ +/// Shows how to keep the simulation running, even +/// when there is no event to be processed anymore. +/// It calls the [Simulation#terminateAt(double)] to define +/// the time the simulation must be terminated. +/// +/// The example is useful when you want to run a simulation +/// for a specific amount of time. +/// For instance, if you want to run a simulation for 24 hours, +/// you just need to call `simulation.terminateAt(60*60*24)` (realize the value is in seconds). +/// +/// It creates 4 Cloudlets and 2 VMs statically. +/// These Cloudlets will take 10 seconds to finish, but +/// the simulation is set to terminate +/// only after the time defined in [#TIME_TO_TERMINATE_SIMULATION]. +/// +/// This way, the simulation keeps waiting for dynamically +/// arrived events. Then, at a [defined time][#TIME_TO_CREATE_NEW_CLOUDLET], +/// new Cloudlets are created. +/// +/// The example uses the CloudSim Plus [EventListener] feature +/// to enable monitoring the simulation and dynamically creating Cloudlets and VMs at runtime. +/// It relies on +/// [Java 8 Method References](https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html) +/// to set a method to be called for [onClockTick events][Simulation#addOnClockTickListener(EventListener)]. +/// It enables getting notifications when the simulation clock advances, then creating and submitting new cloudlets. +/// +/// Since the simulation was set to keep waiting for new events +/// until a defined time, the clock will be updated +/// even if no event arrives, to simulate time passing. +/// Check the [Simulation#terminateAt(double)] for details. +/// +/// At the time defined in [#TIME_TO_CREATE_NEW_CLOUDLET], +/// 1 Cloudlet and 1 VM is created, so the results will show 5 Cloudlets. +/// The simulation will just end at the specified time. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 2.3.0 +/// @see RandomCloudletsArrivalExample public class KeepSimulationRunningExample { - /** - * @see #createDynamicCloudletAndVm(EventInfo) - */ + /// @see #createDynamicCloudletAndVm(EventInfo) private static final double TIME_TO_CREATE_NEW_CLOUDLET = 15; - /** - * @see Simulation#terminateAt(double) - */ + /// @see Simulation#terminateAt(double) private static final double TIME_TO_TERMINATE_SIMULATION = TIME_TO_CREATE_NEW_CLOUDLET*2; - /** - * @see Datacenter#getSchedulingInterval() - */ + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 1; private static final int HOSTS = 3; @@ -158,9 +146,7 @@ private KeepSimulationRunningExample() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -191,9 +177,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private void createVms() { for (int i = 0; i < VMS; i++) { vmList.add(createVm(VM_PES)); @@ -206,9 +190,7 @@ private Vm createVm(final int pes) { .setCloudletScheduler(new CloudletSchedulerTimeShared()); } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private void createCloudlets() { for (int i = 0; i < CLOUDLETS; i++) { cloudletList.add(createCloudlet()); @@ -225,10 +207,8 @@ private Cloudlet createCloudlet() { .setUtilizationModelBw(um); } - /** - * Simulates the dynamic arrival of a Cloudlet and a VM during simulation runtime. - * @param evt - */ + /// Simulates the dynamic arrival of a Cloudlet and a VM during simulation runtime. + /// @param evt private void createDynamicCloudletAndVm(final EventInfo evt) { if((int)evt.getTime() == TIME_TO_CREATE_NEW_CLOUDLET){ System.out.printf("%n# Dynamically creating 1 Cloudlet and 1 VM at time %.2f%n", evt.getTime()); diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/RandomCloudletsArrivalExample.java b/src/main/java/org/cloudsimplus/examples/dynamic/RandomCloudletsArrivalExample.java index b20aef8..3b443da 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/RandomCloudletsArrivalExample.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/RandomCloudletsArrivalExample.java @@ -51,50 +51,42 @@ import java.util.ArrayList; import java.util.List; -/** - * Shows how to keep the simulation running, even - * when there is no event to be processed anymore. - * It calls the {@link Simulation#terminateAt(double)} to define - * the time the simulation must be terminated. - * - *

      The example is useful when you want to run a simulation - * for a specific amount of time, for instance, to wait random arrival - * or requests (such as Cloudlets and VMs). - * Lets say you want to run a simulation for 24 hours. - * This way, you just need to call {@code simulation.terminateAt(60*60*24)} (realize the value is in seconds).

      - * - *

      It creates Cloudlets randomly, according to a pseudo random number generator (PRNG) following the - * {@link UniformDistr uniform distribution}. You can change the PRNG as you wish, - * for instance, to use a {@link PoissonDistr} arrival process.

      - * - *

      The example uses the CloudSim Plus {@link EventListener} feature - * to enable monitoring the simulation and dynamically creating Cloudlets and VMs at runtime. - * It relies on - * Java 8 Method References - * to set a method to be called for {@link Simulation#addOnClockTickListener(EventListener) onClockTick events}. - * It enables getting notifications when the simulation clock advances, then creating and submitting new cloudlets. - *

      - * - *

      Since the simulation was set to keep waiting for new events - * until a defined time, the clock will be updated - * even if no event arrives, to simulate time passing. - * Check the {@link Simulation#terminateAt(double)} for details. - * The simulation will just end at the specified time. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.0.4 - * @see KeepSimulationRunningExample - */ +/// Shows how to keep the simulation running, even +/// when there is no event to be processed anymore. +/// It calls the [Simulation#terminateAt(double)] to define +/// the time the simulation must be terminated. +/// +/// The example is useful when you want to run a simulation +/// for a specific amount of time, for instance, to wait random arrival +/// or requests (such as Cloudlets and VMs). +/// Lets say you want to run a simulation for 24 hours. +/// This way, you just need to call `simulation.terminateAt(60*60*24)` (realize the value is in seconds). +/// +/// It creates Cloudlets randomly, according to a pseudo random number generator (PRNG) following the +/// [uniform distribution][UniformDistr]. You can change the PRNG as you wish, +/// for instance, to use a [PoissonDistr] arrival process. +/// +/// The example uses the CloudSim Plus [EventListener] feature +/// to enable monitoring the simulation and dynamically creating Cloudlets and VMs at runtime. +/// It relies on +/// [Java 8 Method References](https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html) +/// to set a method to be called for [onClockTick events][Simulation#addOnClockTickListener(EventListener)]. +/// It enables getting notifications when the simulation clock advances, then creating and submitting new cloudlets. +/// +/// Since the simulation was set to keep waiting for new events +/// until a defined time, the clock will be updated +/// even if no event arrives, to simulate time passing. +/// Check the [Simulation#terminateAt(double)] for details. +/// The simulation will just end at the specified time. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.0.4 +/// @see KeepSimulationRunningExample public class RandomCloudletsArrivalExample { - /** - * @see Simulation#terminateAt(double) - */ + /// @see Simulation#terminateAt(double) private static final double TIME_TO_TERMINATE_SIMULATION = 30; - /** - * @see Datacenter#getSchedulingInterval() - */ + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 1; private static final int HOSTS = 8; @@ -105,9 +97,7 @@ public class RandomCloudletsArrivalExample { private static final int CLOUDLET_PES = 2; private static final int CLOUDLET_LENGTH = 10000; - /** - * Number of Cloudlets to be statically created when the simulation starts. - */ + /// Number of Cloudlets to be statically created when the simulation starts. private static final int INITIAL_CLOUDLETS_NUMBER = 5; private final CloudSimPlus simulation; @@ -152,9 +142,7 @@ private RandomCloudletsArrivalExample() { randomCloudlets+" randomly created during simulation runtime)"); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -182,9 +170,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var newVmList = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -199,10 +185,8 @@ private Vm createVm(final int pes) { .setCloudletScheduler(new CloudletSchedulerTimeShared()); } - /** - * Creates a list of Cloudlets. - * @param count number of Cloudlets to create statically - */ + /// Creates a list of Cloudlets. + /// @param count number of Cloudlets to create statically private List createCloudlets(final int count) { final var newCloudletList = new ArrayList(count); for (int i = 0; i < count; i++) { @@ -222,13 +206,11 @@ private Cloudlet createCloudlet() { .setUtilizationModelBw(um); } - /** - * Simulates the dynamic arrival of Cloudlets, randomly during simulation runtime. - * At any time the simulation clock updates, a new Cloudlet will be - * created with a probability of 30%. - * - * @param evt - */ + /// Simulates the dynamic arrival of Cloudlets, randomly during simulation runtime. + /// At any time the simulation clock updates, a new Cloudlet will be + /// created with a probability of 30%. + /// + /// @param evt private void createRandomCloudlets(final EventInfo evt) { if(random.sample() <= 0.3){ System.out.printf("%n# Randomly creating 1 Cloudlet at time %.2f%n", evt.getTime()); diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/package-info.java b/src/main/java/org/cloudsimplus/examples/dynamic/package-info.java index bd27435..535352c 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/package-info.java @@ -21,13 +21,11 @@ * You should have received a copy of the GNU General Public License * along with CloudSim Plus. If not, see . */ -/** - * Examples showing how to implement dynamic behaviour for your simulations, - * such as the dynamic array of Cloudlet and VMs, and the creation - * of Hosts at runtime to simulate the physical expansion of a Datacenter. - * - * @author Manoel Campos da Silva Filho - */ +/// Examples showing how to implement dynamic behaviour for your simulations, +/// such as the dynamic array of Cloudlet and VMs, and the creation +/// of Hosts at runtime to simulate the physical expansion of a Datacenter. +/// +/// @author Manoel Campos da Silva Filho @NullMarked package org.cloudsimplus.examples.dynamic; diff --git a/src/main/java/org/cloudsimplus/examples/listeners/CloudletListenersExample1.java b/src/main/java/org/cloudsimplus/examples/listeners/CloudletListenersExample1.java index ba9c907..3cd6f94 100755 --- a/src/main/java/org/cloudsimplus/examples/listeners/CloudletListenersExample1.java +++ b/src/main/java/org/cloudsimplus/examples/listeners/CloudletListenersExample1.java @@ -47,32 +47,24 @@ import java.util.ArrayList; import java.util.List; -/** - * A simple example showing how to create a data center with 1 host and run - * cloudlets on it, and receive notifications when each cloudlet finishes executing. - * - *

      The example uses the new Cloudlet listeners to get these - * notifications while the simulation is running.

      - * - * @see Cloudlet#addOnFinishListener(EventListener) - * @see EventListener - * - * @author Manoel Campos da Silva Filho - */ +/// A simple example showing how to create a data center with 1 host and run +/// cloudlets on it, and receive notifications when each cloudlet finishes executing. +/// +/// The example uses the new Cloudlet listeners to get these +/// notifications while the simulation is running. +/// +/// @see Cloudlet#addOnFinishListener(EventListener) +/// @see EventListener +/// +/// @author Manoel Campos da Silva Filho public class CloudletListenersExample1 { - /** - * Number of Processor Elements (CPU Cores) of each Host. - */ + /// Number of Processor Elements (CPU Cores) of each Host. private static final int HOST_PES_NUMBER = 4; - /** - * Number of Processor Elements (CPU Cores) of each VM and cloudlet. - */ + /// Number of Processor Elements (CPU Cores) of each VM and cloudlet. private static final int VM_PES_NUMBER = 2; - /** - * Number of Cloudlets to create. - */ + /// Number of Cloudlets to create. private static final int NUMBER_OF_CLOUDLETS = 4; private final List hostList; @@ -82,19 +74,15 @@ public class CloudletListenersExample1 { private final Datacenter datacenter; private final CloudSimPlus simulation; - /** - * Starts the example execution, calling the class constructor\ - * to build and run the simulation. - * - * @param args command line parameters - */ + /// Starts the example execution, calling the class constructor\ + /// to build and run the simulation. + /// + /// @param args command line parameters public static void main(String[] args) { new CloudletListenersExample1(); } - /** - * Default constructor that builds and starts the simulation. - */ + /// Default constructor that builds and starts the simulation. private CloudletListenersExample1() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -116,26 +104,22 @@ private CloudletListenersExample1() { System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * A Listener function that will be called every time a cloudlet - * starts running into a VM. All cloudlets will use this same listener. - * - * @param eventInfo information about the happened event - * @see #createCloudlet(long, Vm, long) - */ + /// A Listener function that will be called every time a cloudlet + /// starts running into a VM. All cloudlets will use this same listener. + /// + /// @param eventInfo information about the happened event + /// @see #createCloudlet(long, Vm, long) private void onCloudletStartListener(CloudletVmEventInfo eventInfo) { System.out.printf( "%n\t#EventListener: Cloudlet %d just started running at Vm %d at time %.2f%n", eventInfo.getCloudlet().getId(), eventInfo.getVm().getId(), eventInfo.getTime()); } - /** - * A Listener function that will be called every time a cloudlet - * finishes running into a VM. All cloudlets will use this same listener. - * - * @param eventInfo information about the happened event - * @see #createCloudlet(long, Vm, long) - */ + /// A Listener function that will be called every time a cloudlet + /// finishes running into a VM. All cloudlets will use this same listener. + /// + /// @param eventInfo information about the happened event + /// @see #createCloudlet(long, Vm, long) private void onCloudletFinishListener(CloudletVmEventInfo eventInfo) { System.out.printf( "%n\t#EventListener: Cloudlet %d finished running at Vm %d at time %.2f%n", @@ -149,12 +133,10 @@ private void runSimulationAndPrintResults() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Creates cloudlets and submit them to the broker. - * @param vm Vm to run the cloudlets to be created - * - * @see #createCloudlet(long, Vm, long) - */ + /// Creates cloudlets and submit them to the broker. + /// @param vm Vm to run the cloudlets to be created + /// + /// @see #createCloudlet(long, Vm, long) private void createAndSubmitCloudlets(Vm vm) { long cloudletId; long length = 10000; @@ -167,21 +149,17 @@ private void createAndSubmitCloudlets(Vm vm) { this.broker.submitCloudletList(cloudletList); } - /** - * Creates VMs and submit them to the broker. - */ + /// Creates VMs and submit them to the broker. private void createAndSubmitVms() { final var vm0 = createVm(0); this.vmList.add(vm0); this.broker.submitVmList(vmList); } - /** - * Creates a VM with pre-defined configuration. - * - * @param id the VM id - * @return the created VM - */ + /// Creates a VM with pre-defined configuration. + /// + /// @param id the VM id + /// @return the created VM private Vm createVm(int id) { final int mips = 1000; final long size = 10000; // image size (Megabyte) @@ -195,14 +173,12 @@ private Vm createVm(int id) { return vm; } - /** - * Creates a cloudlet with pre-defined configuration. - * - * @param id Cloudlet id - * @param vm vm to run the cloudlet - * @param length the cloudlet length in number of Million Instructions (MI) - * @return the created cloudlet - */ + /// Creates a cloudlet with pre-defined configuration. + /// + /// @param id Cloudlet id + /// @param vm vm to run the cloudlet + /// @param length the cloudlet length in number of Million Instructions (MI) + /// @return the created cloudlet private Cloudlet createCloudlet(long id, Vm vm, long length) { final long fileSize = 300; final long outputSize = 300; @@ -221,23 +197,19 @@ private Cloudlet createCloudlet(long id, Vm vm, long length) { return cloudlet; } - /** - * Creates a Datacenter with pre-defined configuration. - * - * @return the created Datacenter - */ + /// Creates a Datacenter with pre-defined configuration. + /// + /// @return the created Datacenter private Datacenter createDatacenter() { final var host = createHost(0); hostList.add(host); return new DatacenterSimple(simulation, hostList); } - /** - * Creates a host with pre-defined configuration. - * - * @param id The Host id - * @return the created host - */ + /// Creates a host with pre-defined configuration. + /// + /// @param id The Host id + /// @return the created host private Host createHost(int id) { final var peList = new ArrayList(); final long mips = 1000; diff --git a/src/main/java/org/cloudsimplus/examples/listeners/CloudletListenersExample2_ResourceUsageAlongTime.java b/src/main/java/org/cloudsimplus/examples/listeners/CloudletListenersExample2_ResourceUsageAlongTime.java index 06147a8..d968150 100755 --- a/src/main/java/org/cloudsimplus/examples/listeners/CloudletListenersExample2_ResourceUsageAlongTime.java +++ b/src/main/java/org/cloudsimplus/examples/listeners/CloudletListenersExample2_ResourceUsageAlongTime.java @@ -47,36 +47,28 @@ import java.util.ArrayList; import java.util.List; -/** - * A simple example showing how to create a data center with 1 host and run - * 1 cloudlet on it. The example uses the new Cloudlet listeners - * to get notified every time a cloudlet has its processing updated - * inside a Vm and then, the current cloudlet resource usage is shown. - * The example uses the {@link UtilizationModelStochastic} - * to define that the usage of CPU, RAM and Bandwidth is random. - * - * @see Cloudlet#addOnUpdateProcessingListener(EventListener) - * @see EventListener - * - * @author Manoel Campos da Silva Filho - * - * @see org.cloudsimplus.examples.resourceusage.VmsCpuUsageExample - * @see VmsRamAndBwUsageExample - */ +/// A simple example showing how to create a data center with 1 host and run +/// 1 cloudlet on it. The example uses the new Cloudlet listeners +/// to get notified every time a cloudlet has its processing updated +/// inside a Vm and then, the current cloudlet resource usage is shown. +/// The example uses the [UtilizationModelStochastic] +/// to define that the usage of CPU, RAM and Bandwidth is random. +/// +/// @see Cloudlet#addOnUpdateProcessingListener(EventListener) +/// @see EventListener +/// +/// @author Manoel Campos da Silva Filho +/// +/// @see org.cloudsimplus.examples.resourceusage.VmsCpuUsageExample +/// @see VmsRamAndBwUsageExample public class CloudletListenersExample2_ResourceUsageAlongTime { - /** - * Number of Processor Elements (CPU Cores) of each Host. - */ + /// Number of Processor Elements (CPU Cores) of each Host. private static final int HOST_PES_NUMBER = 1; - /** - * Number of Processor Elements (CPU Cores) of each VM and cloudlet. - */ + /// Number of Processor Elements (CPU Cores) of each VM and cloudlet. private static final int VM_PES_NUMBER = HOST_PES_NUMBER; - /** - * Number of Cloudlets to create. - */ + /// Number of Cloudlets to create. private static final int NUMBER_OF_CLOUDLETS = 2; private static final double DATACENTER_SCHEDULING_INTERVAL = 1; @@ -88,19 +80,15 @@ public class CloudletListenersExample2_ResourceUsageAlongTime { private final Datacenter datacenter; private final CloudSimPlus simulation; - /** - * Starts the example execution, calling the class constructor\ - * to build and run the simulation. - * - * @param args command line parameters - */ + /// Starts the example execution, calling the class constructor\ + /// to build and run the simulation. + /// + /// @param args command line parameters public static void main(String[] args) { new CloudletListenersExample2_ResourceUsageAlongTime(); } - /** - * Default constructor that builds and starts the simulation. - */ + /// Default constructor that builds and starts the simulation. private CloudletListenersExample2_ResourceUsageAlongTime() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -122,13 +110,11 @@ private CloudletListenersExample2_ResourceUsageAlongTime() { System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * A Listener function that will be called everytime when a the processing of a cloudlet - * is updated into a VM. All cloudlets will use this same listener. - * - * @param eventInfo information about the happened event - * @see #createCloudlet(long, Vm, long) - */ + /// A Listener function that will be called everytime when a the processing of a cloudlet + /// is updated into a VM. All cloudlets will use this same listener. + /// + /// @param eventInfo information about the happened event + /// @see #createCloudlet(long, Vm, long) private void onUpdateCloudletProcessingListener(CloudletVmEventInfo eventInfo) { final var c = eventInfo.getCloudlet(); double cpuUsage = c.getUtilizationModelCpu().getUtilization(eventInfo.getTime())*100; @@ -149,12 +135,10 @@ private void runSimulationAndPrintResults() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Creates cloudlets and submit them to the broker. - * @param vm Vm to run the cloudlets to be created - * - * @see #createCloudlet(long, Vm, long) - */ + /// Creates cloudlets and submit them to the broker. + /// @param vm Vm to run the cloudlets to be created + /// + /// @see #createCloudlet(long, Vm, long) private void createAndSubmitCloudlets(Vm vm) { long cloudletId; long length = 10000; @@ -167,21 +151,17 @@ private void createAndSubmitCloudlets(Vm vm) { this.broker.submitCloudletList(cloudletList); } - /** - * Creates VMs and submit them to the broker. - */ + /// Creates VMs and submit them to the broker. private void createAndSubmitVms() { final var vm0 = createVm(0); this.vmList.add(vm0); this.broker.submitVmList(vmList); } - /** - * Creates a VM with pre-defined configuration. - * - * @param id the VM id - * @return the created VM - */ + /// Creates a VM with pre-defined configuration. + /// + /// @param id the VM id + /// @return the created VM private Vm createVm(int id) { final int mips = 1000; final long size = 10000; // image size (Megabyte) @@ -194,14 +174,12 @@ private Vm createVm(int id) { return vm; } - /** - * Creates a cloudlet with pre-defined configuration. - * - * @param id Cloudlet id - * @param vm vm to run the cloudlet - * @param length the cloudlet length in number of Million Instructions (MI) - * @return the created cloudlet - */ + /// Creates a cloudlet with pre-defined configuration. + /// + /// @param id Cloudlet id + /// @param vm vm to run the cloudlet + /// @param length the cloudlet length in number of Million Instructions (MI) + /// @return the created cloudlet private Cloudlet createCloudlet(long id, Vm vm, long length) { final long fileSize = 300; final long outputSize = 300; @@ -225,11 +203,9 @@ private Cloudlet createCloudlet(long id, Vm vm, long length) { return cloudlet; } - /** - * Creates a Datacenter with pre-defined configuration. - * - * @return the created Datacenter - */ + /// Creates a Datacenter with pre-defined configuration. + /// + /// @return the created Datacenter private Datacenter createDatacenter() { final var host = createHost(0); hostList.add(host); @@ -238,12 +214,10 @@ private Datacenter createDatacenter() { .setSchedulingInterval(DATACENTER_SCHEDULING_INTERVAL); } - /** - * Creates a host with pre-defined configuration. - * - * @param id The Host id - * @return the created host - */ + /// Creates a host with pre-defined configuration. + /// + /// @param id The Host id + /// @return the created host private Host createHost(int id) { final var peList = new ArrayList(); final long mips = 1000; diff --git a/src/main/java/org/cloudsimplus/examples/listeners/VmListenersExample1.java b/src/main/java/org/cloudsimplus/examples/listeners/VmListenersExample1.java index f3ed45e..d62f5b0 100755 --- a/src/main/java/org/cloudsimplus/examples/listeners/VmListenersExample1.java +++ b/src/main/java/org/cloudsimplus/examples/listeners/VmListenersExample1.java @@ -45,31 +45,25 @@ import java.util.ArrayList; import java.util.List; -/** - * A simple example showing how to create a data center with 1 host and run 1 - * cloudlet on it, and receive notifications when a Host is allocated or - * deallocated to each Vm. It is also show how to be notified when - * no suitable host is found to place a VM. - * - * The example uses the new Vm listeners to get these - * notifications while the simulation is running. - * - * @see Vm#addOnHostAllocationListener(EventListener) - * @see Vm#addOnHostDeallocationListener(EventListener) - * @see Vm#addOnCreationFailureListener(EventListener) - * @see EventListener - * - * @author Manoel Campos da Silva Filho - */ +/// A simple example showing how to create a data center with 1 host and run 1 +/// cloudlet on it, and receive notifications when a Host is allocated or +/// deallocated to each Vm. It is also show how to be notified when +/// no suitable host is found to place a VM. +/// +/// The example uses the new Vm listeners to get these +/// notifications while the simulation is running. +/// +/// @see Vm#addOnHostAllocationListener(EventListener) +/// @see Vm#addOnHostDeallocationListener(EventListener) +/// @see Vm#addOnCreationFailureListener(EventListener) +/// @see EventListener +/// +/// @author Manoel Campos da Silva Filho public class VmListenersExample1 { - /** - * Number of Processor Elements (CPU Cores) of each Host. - */ + /// Number of Processor Elements (CPU Cores) of each Host. private static final int HOST_PES_NUMBER = 1; - /** - * Number of Processor Elements (CPU Cores) of each VM and cloudlet. - */ + /// Number of Processor Elements (CPU Cores) of each VM and cloudlet. private static final int VM_PES_NUMBER = HOST_PES_NUMBER; private final List hostList; @@ -79,19 +73,15 @@ public class VmListenersExample1 { private final Datacenter datacenter; private final CloudSimPlus simulation; - /** - * Starts the example execution, calling the class constructor\ - * to build and run the simulation. - * - * @param args command line parameters - */ + /// Starts the example execution, calling the class constructor\ + /// to build and run the simulation. + /// + /// @param args command line parameters public static void main(String[] args) { new VmListenersExample1(); } - /** - * Default constructor that builds and starts the simulation. - */ + /// Default constructor that builds and starts the simulation. private VmListenersExample1() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -120,9 +110,7 @@ private void runSimulationAndPrintResults() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Create cloudlets and submit them to the broker. - */ + /// Create cloudlets and submit them to the broker. private void createAndSubmitCloudlets() { final var cloudlet0 = createCloudlet(0, vmList.get(0)); this.cloudletList.add(cloudlet0); @@ -135,9 +123,7 @@ private void createAndSubmitCloudlets() { this.broker.submitCloudletList(cloudletList); } - /** - * Creates VMs and submit them to the broker. - */ + /// Creates VMs and submit them to the broker. private void createAndSubmitVms() { final var vm0 = createVm(0); @@ -168,12 +154,10 @@ private void createAndSubmitVms() { this.broker.submitVmList(vmList); } - /** - * Creates a VM with pre-defined configuration. - * - * @param id the VM id - * @return the created VM - */ + /// Creates a VM with pre-defined configuration. + /// + /// @param id the VM id + /// @return the created VM private Vm createVm(int id) { final int mips = 1000; final long size = 10000; // image size (Megabyte) @@ -185,13 +169,11 @@ private Vm createVm(int id) { .setCloudletScheduler(new CloudletSchedulerTimeShared()); } - /** - * Creates a cloudlet with pre-defined configuration. - * - * @param id Cloudlet id - * @param vm vm to run the cloudlet - * @return the created cloudlet - */ + /// Creates a cloudlet with pre-defined configuration. + /// + /// @param id Cloudlet id + /// @param vm vm to run the cloudlet + /// @return the created cloudlet private Cloudlet createCloudlet(int id, Vm vm) { final long length = 400000; //in MI (Million Instructions) final long fileSize = 300; @@ -204,11 +186,9 @@ private Cloudlet createCloudlet(int id, Vm vm) { .setVm(vm); } - /** - * Creates a Datacenter with pre-defined configuration. - * - * @return the created Datacenter - */ + /// Creates a Datacenter with pre-defined configuration. + /// + /// @return the created Datacenter private Datacenter createDatacenter() { final var host = createHost(0); hostList.add(host); @@ -216,12 +196,10 @@ private Datacenter createDatacenter() { return new DatacenterSimple(simulation, hostList); } - /** - * Creates a host with pre-defined configuration. - * - * @param id The Host id - * @return the created host - */ + /// Creates a host with pre-defined configuration. + /// + /// @param id The Host id + /// @return the created host private Host createHost(int id) { final var peList = new ArrayList(); final long mips = 1000; diff --git a/src/main/java/org/cloudsimplus/examples/listeners/VmListenersExample2.java b/src/main/java/org/cloudsimplus/examples/listeners/VmListenersExample2.java index 14387dd..e562278 100755 --- a/src/main/java/org/cloudsimplus/examples/listeners/VmListenersExample2.java +++ b/src/main/java/org/cloudsimplus/examples/listeners/VmListenersExample2.java @@ -46,35 +46,27 @@ import java.util.ArrayList; import java.util.List; -/** - * A simple example showing how to create a data center with 1 host and place 2 VMs - * to run 1 cloudlet each one, and receive notifications when a Host is allocated or - * deallocated to each Vm. - * - * The example uses the new Vm listeners to get these - * notifications while the simulation is running. It also shows how to - * reuse the same listener object to different VMs. - * - * @see Vm#addOnHostAllocationListener(EventListener) - * @see Vm#addOnHostDeallocationListener(EventListener) - * @see EventListener - * - * @author Manoel Campos da Silva Filho - */ +/// A simple example showing how to create a data center with 1 host and place 2 VMs +/// to run 1 cloudlet each one, and receive notifications when a Host is allocated or +/// deallocated to each Vm. +/// +/// The example uses the new Vm listeners to get these +/// notifications while the simulation is running. It also shows how to +/// reuse the same listener object to different VMs. +/// +/// @see Vm#addOnHostAllocationListener(EventListener) +/// @see Vm#addOnHostDeallocationListener(EventListener) +/// @see EventListener +/// +/// @author Manoel Campos da Silva Filho public class VmListenersExample2 { - /** - * Number of VMs to create. - */ + /// Number of VMs to create. private static final int NUMBER_OF_VMS = 4; - /** - * Number of Processor Elements (CPU Cores) of each Host. - */ + /// Number of Processor Elements (CPU Cores) of each Host. private static final int HOST_PES_NUMBER = NUMBER_OF_VMS; - /** - * Number of Processor Elements (CPU Cores) of each VM and cloudlet. - */ + /// Number of Processor Elements (CPU Cores) of each VM and cloudlet. private static final int VM_PES_NUMBER = 1; private final List hostList; @@ -84,33 +76,25 @@ public class VmListenersExample2 { private final Datacenter datacenter; private final CloudSimPlus simulation; - /** - * The listener object that will be created in order to be notified when - * a host is allocated for a VM. The same listener is used for all created VMs. - * @see #createVmListeners() - */ + /// The listener object that will be created in order to be notified when + /// a host is allocated for a VM. The same listener is used for all created VMs. + /// @see #createVmListeners() private EventListener onHostAllocationListener; - /** - * The listener object that will be created in order to be notified when - * a host is deallocated for a VM. The same listener is used for all created VMs. - * @see #createVmListeners() - */ + /// The listener object that will be created in order to be notified when + /// a host is deallocated for a VM. The same listener is used for all created VMs. + /// @see #createVmListeners() private EventListener onHostDeallocationListener; - /** - * Starts the example execution, calling the class constructor\ - * to build and run the simulation. - * - * @param args command line parameters - */ + /// Starts the example execution, calling the class constructor\ + /// to build and run the simulation. + /// + /// @param args command line parameters public static void main(String[] args) { new VmListenersExample2(); } - /** - * Default constructor that builds and starts the simulation. - */ + /// Default constructor that builds and starts the simulation. private VmListenersExample2() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -131,12 +115,10 @@ private VmListenersExample2() { System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * Creates VMs and the cloudlets for each one, submitting - * the list of VMs and Cloudlets to the broker. - * - * @see #createVm(int) - */ + /// Creates VMs and the cloudlets for each one, submitting + /// the list of VMs and Cloudlets to the broker. + /// + /// @see #createVm(int) private void createAndSubmitVmsAndCloudlets() { for(int i = 0; i < NUMBER_OF_VMS; i++){ final var vm = createVm(i); @@ -150,11 +132,9 @@ private void createAndSubmitVmsAndCloudlets() { this.broker.submitCloudletList(cloudletList); } - /** - * Creates all VM listeners to be used by every VM created. - * - * @see #createVm(int) - */ + /// Creates all VM listeners to be used by every VM created. + /// + /// @see #createVm(int) private void createVmListeners() { /* Creates the listener object that will be notified when a host is allocated to a VM. @@ -175,12 +155,10 @@ private void createVmListeners() { evt.getVm().getId(), evt.getHost().getId(), evt.getTime()); } - /** - * Creates a VM with pre-defined configuration. - * - * @param id the VM id - * @return the created VM - */ + /// Creates a VM with pre-defined configuration. + /// + /// @param id the VM id + /// @return the created VM private Vm createVm(int id) { final int mips = 1000; final long size = 10000; // image size (Megabyte) @@ -200,13 +178,11 @@ private Vm createVm(int id) { return vm; } - /** - * Creates a cloudlet with pre-defined configuration. - * - * @param id Cloudlet id - * @param vm vm to run the cloudlet - * @return the created cloudlet - */ + /// Creates a cloudlet with pre-defined configuration. + /// + /// @param id Cloudlet id + /// @param vm vm to run the cloudlet + /// @return the created cloudlet private Cloudlet createCloudlet(int id, Vm vm) { final long length = 400000; //in MI (Million Instructions) final long fileSize = 300; @@ -219,11 +195,9 @@ private Cloudlet createCloudlet(int id, Vm vm) { .setVm(vm); } - /** - * Creates a Datacenter with pre-defined configuration. - * - * @return the created Datacenter - */ + /// Creates a Datacenter with pre-defined configuration. + /// + /// @return the created Datacenter private Datacenter createDatacenter() { final var host = createHost(0); hostList.add(host); @@ -231,12 +205,10 @@ private Datacenter createDatacenter() { return new DatacenterSimple(simulation, hostList); } - /** - * Creates a host with pre-defined configuration. - * - * @param id The Host id - * @return the created host - */ + /// Creates a host with pre-defined configuration. + /// + /// @param id The Host id + /// @return the created host private Host createHost(int id) { final var peList = new ArrayList(); long mips = 1000; diff --git a/src/main/java/org/cloudsimplus/examples/listeners/VmListenersExample3_DynamicVmCreation.java b/src/main/java/org/cloudsimplus/examples/listeners/VmListenersExample3_DynamicVmCreation.java index b4a9146..c6f872f 100755 --- a/src/main/java/org/cloudsimplus/examples/listeners/VmListenersExample3_DynamicVmCreation.java +++ b/src/main/java/org/cloudsimplus/examples/listeners/VmListenersExample3_DynamicVmCreation.java @@ -47,41 +47,31 @@ import java.util.ArrayList; import java.util.List; -/** - * A simple example showing how to create a data center with 1 host that has - * capacity to run just one Vm at a time. The example thus shows - * how to parallelize the execution of multiple VMs. - * By this way, it creates one Vm a time and enqueue the creation of - * the next VMs. - * It uses the new VM listeners to be notified when a host - * is deallocated for a VM (in this case meaning that the VM has finished - * executing) in order to place the next VM to run inside the host. - * - * @see Vm#addOnHostDeallocationListener(EventListener) - * @see EventListener - * - * @author Manoel Campos da Silva Filho - */ +/// A simple example showing how to create a data center with 1 host that has +/// capacity to run just one Vm at a time. The example thus shows +/// how to parallelize the execution of multiple VMs. +/// By this way, it creates one Vm a time and enqueue the creation of +/// the next VMs. +/// It uses the new VM listeners to be notified when a host +/// is deallocated for a VM (in this case meaning that the VM has finished +/// executing) in order to place the next VM to run inside the host. +/// +/// @see Vm#addOnHostDeallocationListener(EventListener) +/// @see EventListener +/// +/// @author Manoel Campos da Silva Filho public class VmListenersExample3_DynamicVmCreation { - /** - * Number of Processor Elements (CPU Cores) of each Host. - */ + /// Number of Processor Elements (CPU Cores) of each Host. private static final int HOST_PES_NUMBER = 2; - /** - * Number of Processor Elements (CPU Cores) of each VM and cloudlet. - */ + /// Number of Processor Elements (CPU Cores) of each VM and cloudlet. private static final int VM_PES_NUMBER = HOST_PES_NUMBER; - /** - * Number of Cloudlets to create simultaneously. - * Other cloudlets will be enqueued. - */ + /// Number of Cloudlets to create simultaneously. + /// Other cloudlets will be enqueued. private static final int NUMBER_OF_CLOUDLETS = VM_PES_NUMBER; - /** - * Total number of VMs to create along the simulation. - */ + /// Total number of VMs to create along the simulation. private static final int TOTAL_NUMBER_OF_VMS = 3; private final List hostList; @@ -91,24 +81,18 @@ public class VmListenersExample3_DynamicVmCreation { private final Datacenter datacenter; private final CloudSimPlus simulation; - /** - * Number of VMs that have finished executing all their cloudlets. - */ + /// Number of VMs that have finished executing all their cloudlets. private int numberOfFinishedVms = 0; - /** - * Starts the example execution, calling the class constructor\ - * to build and run the simulation. - * - * @param args command line parameters - */ + /// Starts the example execution, calling the class constructor\ + /// to build and run the simulation. + /// + /// @param args command line parameters public static void main(String[] args) { new VmListenersExample3_DynamicVmCreation(); } - /** - * Default constructor that builds and starts the simulation. - */ + /// Default constructor that builds and starts the simulation. private VmListenersExample3_DynamicVmCreation() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -137,15 +121,13 @@ the deallocation of a host to a VM (that means the VM has finished executing).*/ System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * A handler method that will be called when a VM - * is removed from a host (in this case meaning that it has finished executing - * its cloudlets). All VMs will use this same listener. - * - * @param eventInfo information about the happened event - * - * @see #createVm(int, DatacenterBroker) - */ + /// A handler method that will be called when a VM + /// is removed from a host (in this case meaning that it has finished executing + /// its cloudlets). All VMs will use this same listener. + /// + /// @param eventInfo information about the happened event + /// + /// @see #createVm(int, DatacenterBroker) private void onHostDeallocationListener(VmHostEventInfo eventInfo) { numberOfFinishedVms++; System.out.printf( @@ -156,12 +138,10 @@ private void onHostDeallocationListener(VmHostEventInfo eventInfo) { createNextVmIfNotReachedMaxNumberOfVms(); } - /** - * After a VM finishes executing, creates another one - * if the number of created VMs is less than {@link #TOTAL_NUMBER_OF_VMS}. - * By this way, it allows the sequential execution of several VMs into a host - * that doesn't have enough PEs to execute them all simultaneously. - */ + /// After a VM finishes executing, creates another one + /// if the number of created VMs is less than [#TOTAL_NUMBER_OF_VMS]. + /// By this way, it allows the sequential execution of several VMs into a host + /// that doesn't have enough PEs to execute them all simultaneously. private void createNextVmIfNotReachedMaxNumberOfVms() { if(numberOfFinishedVms < TOTAL_NUMBER_OF_VMS) { final var vm = createAndSubmitVmForNewBroker(); @@ -181,13 +161,11 @@ private void runSimulationAndPrintResults() { } } - /** - * Creates cloudlets and submit them to the broker. - * @param broker The DatacenterBroker that will submit the cloudlets - * @param vm Vm to run the cloudlets to be created - * - * @see #createCloudlet(int, Vm, DatacenterBroker) - */ + /// Creates cloudlets and submit them to the broker. + /// @param broker The DatacenterBroker that will submit the cloudlets + /// @param vm Vm to run the cloudlets to be created + /// + /// @see #createCloudlet(int, Vm, DatacenterBroker) private void createAndSubmitCloudlets(DatacenterBroker broker, Vm vm) { int cloudletId = cloudletList.size(); final var newCloudletList = new ArrayList(NUMBER_OF_CLOUDLETS); @@ -200,12 +178,10 @@ private void createAndSubmitCloudlets(DatacenterBroker broker, Vm vm) { cloudletList.addAll(newCloudletList); } - /** - * Creates one Vm and a group of cloudlets to run inside it, - * and submit the Vm and its cloudlets to a new broker. - * @return the created VM - * @see #createVm(int, DatacenterBroker) - */ + /// Creates one Vm and a group of cloudlets to run inside it, + /// and submit the Vm and its cloudlets to a new broker. + /// @return the created VM + /// @see #createVm(int, DatacenterBroker) private Vm createAndSubmitVmForNewBroker() { final var newVmList = new ArrayList(); final var broker = new DatacenterBrokerSimple(simulation); @@ -220,15 +196,13 @@ private Vm createAndSubmitVmForNewBroker() { return vm; } - /** - * Creates a VM with pre-defined configuration. - * - * @param id the VM id - * @param broker the broker that will be submit the VM - * @return the created VM - * - * @see #onHostDeallocationListener(VmHostEventInfo) - */ + /// Creates a VM with pre-defined configuration. + /// + /// @param id the VM id + /// @param broker the broker that will be submit the VM + /// @return the created VM + /// + /// @see #onHostDeallocationListener(VmHostEventInfo) private Vm createVm(int id, DatacenterBroker broker) { final int mips = 1000; final long size = 10000; // image size (Megabyte) @@ -241,14 +215,12 @@ private Vm createVm(int id, DatacenterBroker broker) { .addOnHostDeallocationListener(this::onHostDeallocationListener); } - /** - * Creates a cloudlet with pre-defined configuration. - * - * @param id Cloudlet id - * @param vm vm to run the cloudlet - * @param broker the broker that will submit the cloudlets - * @return the created cloudlet - */ + /// Creates a cloudlet with pre-defined configuration. + /// + /// @param id Cloudlet id + /// @param vm vm to run the cloudlet + /// @param broker the broker that will submit the cloudlets + /// @return the created cloudlet private Cloudlet createCloudlet(int id, Vm vm, DatacenterBroker broker) { final long fileSize = 300; final long outputSize = 300; @@ -263,23 +235,19 @@ private Cloudlet createCloudlet(int id, Vm vm, DatacenterBroker broker) { .setVm(vm); } - /** - * Creates a Datacenter with pre-defined configuration. - * - * @return the created Datacenter - */ + /// Creates a Datacenter with pre-defined configuration. + /// + /// @return the created Datacenter private Datacenter createDatacenter() { final var host = createHost(0); hostList.add(host); return new DatacenterSimple(simulation, hostList); } - /** - * Creates a host with pre-defined configuration. - * - * @param id The Host id - * @return the created host - */ + /// Creates a host with pre-defined configuration. + /// + /// @param id The Host id + /// @return the created host private Host createHost(int id) { final var peList = new ArrayList(); long mips = 1000; diff --git a/src/main/java/org/cloudsimplus/examples/listeners/package-info.java b/src/main/java/org/cloudsimplus/examples/listeners/package-info.java index 807b65b..a701b4d 100755 --- a/src/main/java/org/cloudsimplus/examples/listeners/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/listeners/package-info.java @@ -21,15 +21,13 @@ * You should have received a copy of the GNU General Public License * along with CloudSim Plus. If not, see . */ -/** - * Examples showing how to use the CloudSim Plus {@link org.cloudsimplus.listeners.EventListener} - * features to track simulation events and perform some actions in response. - * These Listeners enable all sorts of features to be implemented, such as logging - * resource usage along simulation execution, creation of Cloudlets and VMs - * at defined simulation intervals, etc. - * - * @author Manoel Campos da Silva Filho - */ +/// Examples showing how to use the CloudSim Plus [org.cloudsimplus.listeners.EventListener] +/// features to track simulation events and perform some actions in response. +/// These Listeners enable all sorts of features to be implemented, such as logging +/// resource usage along simulation execution, creation of Cloudlets and VMs +/// at defined simulation intervals, etc. +/// +/// @author Manoel Campos da Silva Filho @NullMarked package org.cloudsimplus.examples.listeners; diff --git a/src/main/java/org/cloudsimplus/examples/migration/InterDatacenterMigration1.java b/src/main/java/org/cloudsimplus/examples/migration/InterDatacenterMigration1.java index 31fd271..c08438b 100755 --- a/src/main/java/org/cloudsimplus/examples/migration/InterDatacenterMigration1.java +++ b/src/main/java/org/cloudsimplus/examples/migration/InterDatacenterMigration1.java @@ -61,132 +61,113 @@ import static java.util.Comparator.comparingLong; import static java.util.stream.Collectors.joining; -/** - * An example showing how to create 2 Datacenters having different - * number of Hosts and VMs with heterogeneous capacity/requirements. - * - *

      - * Despite there isn't the concept of multi-cloud environments on CloudSim Plus, - * this example can be used to simulate that. - * Lets say you have 2 or more datacenters where some of them belong to a cloud provider - * and other ones belong to another provider. - * Since the example is performing VM migration between those datacenters, - * we can consider in that case we are performing VM migration between - * cloud providers. - *

      - * - *

      Realize the example is creating datacenters in private and public clouds. - * This way, when migrating VMs from/to a public cloud, non-live migration will be performed, - * where the VM is shutdown and restarted on the target datacenter. - * Check {@link DatacenterCharacteristics#getDistribution()} for details.

      - * - *

      The example performs VM migration using - * a {@link VmAllocationPolicyMigrationFirstFitStaticThreshold}. - * Such a policy migrates VMs based on - * a static host CPU utilization threshold. - * The VmAllocationPolicy used in this example ignores power consumption of Hosts. - * This way, it isn't required to set a PowerModel for Hosts.

      - * - *

      A Host from Datacenter 1 will become overloaded, - * however, there will be no other suitable Host from the same datacenter - * to migrate VMs to. - * Therefore, intra-datacenter migration is not possible - * and the next datacenter available will be tried next time.

      - * - *

      The {@link VmAllocationPolicyMigrationFirstFitStaticThreshold} - * allows setting static under/over CPU utilization thresholds to - * enable VM migration. - * The example uses a {@link UtilizationModelDynamic} to define that CPU usage of cloudlets - * increases along simulation time. - *

      - * - *

      Some constants are used to create simulation objects such as - * {@link DatacenterSimple}, {@link Host} and {@link Vm}. - * The values of these constants were careful and accordingly chosen to allow: - * (i) migration of VMs due to either under and overloaded hosts; and - * (ii) the researcher to know exactly how the simulation will run - * and what will be the final results. - *

      - * - *

      - * Several values impact simulation results, such as - * (i) hosts CPU capacity and number of PEs, - * (ii) VMs and cloudlets requirements and - * (iii) even VM bandwidth (which defines the VM migration time). - * - * This way, if you want to change these values, you must - * define new appropriated ones to allow the simulation - * to run correctly.

      - * - *

      Realize that Host State History is just collected - * if you enable that by calling {@link Host#setStateHistoryEnabled(boolean)}.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 7.2.0 - */ +/// An example showing how to create 2 Datacenters having different +/// number of Hosts and VMs with heterogeneous capacity/requirements. +/// +/// Despite there isn't the concept of multi-cloud environments on CloudSim Plus, +/// this example can be used to simulate that. +/// Lets say you have 2 or more datacenters where some of them belong to a cloud provider +/// and other ones belong to another provider. +/// Since the example is performing VM migration between those datacenters, +/// we can consider in that case we are performing VM migration between +/// cloud providers. +/// +/// Realize the example is creating datacenters in private and public clouds. +/// This way, when migrating VMs from/to a public cloud, non-live migration will be performed, +/// where the VM is shutdown and restarted on the target datacenter. +/// Check [DatacenterCharacteristics#getDistribution()] for details. +/// +/// The example performs VM migration using +/// a [VmAllocationPolicyMigrationFirstFitStaticThreshold]. +/// Such a policy migrates VMs based on +/// a static host CPU utilization threshold. +/// The VmAllocationPolicy used in this example ignores power consumption of Hosts. +/// This way, it isn't required to set a PowerModel for Hosts. +/// +/// A Host from Datacenter 1 will become overloaded, +/// however, there will be no other suitable Host from the same datacenter +/// to migrate VMs to. +/// Therefore, intra-datacenter migration is not possible +/// and the next datacenter available will be tried next time. +/// +/// The [VmAllocationPolicyMigrationFirstFitStaticThreshold] +/// allows setting static under/over CPU utilization thresholds to +/// enable VM migration. +/// The example uses a [UtilizationModelDynamic] to define that CPU usage of cloudlets +/// increases along simulation time. +/// +/// Some constants are used to create simulation objects such as +/// [DatacenterSimple], [Host] and [Vm]. +/// The values of these constants were careful and accordingly chosen to allow: +/// (i) migration of VMs due to either under and overloaded hosts; and +/// (ii) the researcher to know exactly how the simulation will run +/// and what will be the final results. +/// +/// Several values impact simulation results, such as +/// (i) hosts CPU capacity and number of PEs, +/// (ii) VMs and cloudlets requirements and +/// (iii) even VM bandwidth (which defines the VM migration time). +/// +/// This way, if you want to change these values, you must +/// define new appropriated ones to allow the simulation +/// to run correctly. +/// +/// Realize that Host State History is just collected +/// if you enable that by calling [Host#setStateHistoryEnabled(boolean)]. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 7.2.0 public final class InterDatacenterMigration1 { - /** @see Datacenter#getSchedulingInterval() */ + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 2; - /** - * A matrix where each row defines the PEs capacity for hosts in one Datacenter. - * Each item is the number of PEs for a Host. - * The number of rows (length of the matrix) define the number of Datacenters to create. - * The number of cols (length of each row) define the number of Hosts for each Datacenter. - * - *

      The total number of items define the number of Hosts to create.

      - */ + /// A matrix where each row defines the PEs capacity for hosts in one Datacenter. + /// Each item is the number of PEs for a Host. + /// The number of rows (length of the matrix) define the number of Datacenters to create. + /// The number of cols (length of each row) define the number of Hosts for each Datacenter. + /// + /// The total number of items define the number of Hosts to create. private static final int[][] DC_HOST_PES = {{4, 5}, {8, 8, 8, 16}}; - /** - * The percentage of host CPU usage that trigger VM migration - * due to under utilization (in scale from 0 to 1, where 1 is 100%). - */ + /// The percentage of host CPU usage that trigger VM migration + /// due to under utilization (in scale from 0 to 1, where 1 is 100%). private static final double HOST_UNDER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION = 0.1; - /** - * The percentage of host CPU usage that trigger VM migration - * due to over utilization (in scale from 0 to 1, where 1 is 100%). - */ + /// The percentage of host CPU usage that trigger VM migration + /// due to over utilization (in scale from 0 to 1, where 1 is 100%). private static final double HOST_OVER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION = 0.78; - /** @see Datacenter#setHostSearchRetryDelay(double) */ + /// @see Datacenter#setHostSearchRetryDelay(double) private static final int HOST_SEARCH_RETRY_DELAY = 10; - /** - * The time spent during VM migration depend on the - * bandwidth of the target Host. - * By default, a {@link Datacenter} - * uses only 50% of the BW to migrate VMs, while the - * remaining capacity is used for VM communication. - * This can be changed by calling - * {@link DatacenterSimple#setBandwidthPercentForMigration(double)}. - * - *

      The 16000 Mb/s is the same as 2000 MB/s. Since just half of this capacity - * is used for VM migration, only 1000 MB/s will be available for this process. - * The time that takes to migrate a Vm depend on the VM RAM capacity. - * Since VMs in this example are created with 2000 MB of RAM, any migration - * will take 2 seconds to finish, as can be seen in the logs. - */ + /// The time spent during VM migration depend on the + /// bandwidth of the target Host. + /// By default, a [Datacenter] + /// uses only 50% of the BW to migrate VMs, while the + /// remaining capacity is used for VM communication. + /// This can be changed by calling + /// [DatacenterSimple#setBandwidthPercentForMigration(double)]. + /// + /// The 16000 Mb/s is the same as 2000 MB/s. Since just half of this capacity + /// is used for VM migration, only 1000 MB/s will be available for this process. + /// The time that takes to migrate a Vm depend on the VM RAM capacity. + /// Since VMs in this example are created with 2000 MB of RAM, any migration + /// will take 2 seconds to finish, as can be seen in the logs. private static final long HOST_BW = 16_000L; //Mbps private static final int HOST_MIPS = 1000; //for each PE - /** - * RAM capacity for created Hosts. - * The length of this array must be the length of the largest row on {@link #DC_HOST_PES} matrix. - */ + /// RAM capacity for created Hosts. + /// The length of this array must be the length of the largest row on [#DC_HOST_PES] matrix. private static final long[] HOST_RAM = {50_000, 50_000, 50_000, 50_000}; //host memory (MB) private static final long HOST_STORAGE = 1_000_000; //host storage (MB) - /** - * A matrix where each row defines the number of PEs required by each VM in one Datacenter. - * The total number of items define the number of VMs to create. - * - *

      The length of this matrix (number of rows) must be equal to the number of datacenters, - * defined by the length of {@link #DC_HOST_PES}.

      - */ + /// A matrix where each row defines the number of PEs required by each VM in one Datacenter. + /// The total number of items define the number of VMs to create. + /// + /// The length of this matrix (number of rows) must be equal to the number of datacenters, + /// defined by the length of [#DC_HOST_PES]. private static final int[][] VM_PES = {{3, 2, 2}, {4, 4, 4}}; private static final int VM_MIPS = 1000; //for each PE @@ -198,21 +179,17 @@ public final class InterDatacenterMigration1 { private static final long CLOUDLET_FILESIZE = 300; private static final long CLOUDLET_OUTPUT_SIZE = 300; - /** - * The percentage of CPU that a cloudlet will use when - * it starts executing (in scale from 0 to 1, where 1 is 100%). - * For each cloudlet create, this value is used - * as a base to define CPU usage. - * @see #createAndSubmitCloudlets(DatacenterBroker) - */ + /// The percentage of CPU that a cloudlet will use when + /// it starts executing (in scale from 0 to 1, where 1 is 100%). + /// For each cloudlet create, this value is used + /// as a base to define CPU usage. + /// @see #createAndSubmitCloudlets(DatacenterBroker) private static final double CLOUDLET_INITIAL_CPU_PERCENTAGE = 0.5; - /** - * Defines the speed (in percentage) that CPU usage of a cloudlet - * will increase during the simulation execution. - * (in scale from 0 to 1, where 1 is 100%). - * @see #createCpuUtilizationModel(double, double) - */ + /// Defines the speed (in percentage) that CPU usage of a cloudlet + /// will increase during the simulation execution. + /// (in scale from 0 to 1, where 1 is 100%). + /// @see #createCpuUtilizationModel(double, double) private static final double CLOUDLET_CPU_INCREMENT_PER_SECOND = 0.05; private final List brokerList; @@ -264,16 +241,14 @@ private void validateConfiguration() { } } - /** - * Creates an VmAllocationPolicy and sets an upper utilization threshold higher than the - * {@link #HOST_OVER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION} - * to enable placing VMs which will use more CPU than - * defined by the value in the mentioned constant. - * After VMs are all submitted to Hosts, the threshold is changed - * to the value of the constant. - * This is used to place VMs into a Host which will - * become overloaded in order to trigger the migration. - */ + /// Creates an VmAllocationPolicy and sets an upper utilization threshold higher than the + /// [#HOST_OVER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION] + /// to enable placing VMs which will use more CPU than + /// defined by the value in the mentioned constant. + /// After VMs are all submitted to Hosts, the threshold is changed + /// to the value of the constant. + /// This is used to place VMs into a Host which will + /// become overloaded in order to trigger the migration. private VmAllocationPolicyMigration createVmAllocationPolicy() { final var vmSelection = new VmSelectionPolicyMinimumUtilization(); final var vmAllocation = new VmAllocationPolicyMigrationFirstFitStaticThreshold(vmSelection, 0.9); @@ -282,10 +257,8 @@ private VmAllocationPolicyMigration createVmAllocationPolicy() { return vmAllocation; } - /** - * Creates one {@link DatacenterBroker} for each Datacenter. - * @return - */ + /// Creates one [DatacenterBroker] for each Datacenter. + /// @return private List createBrokers() { return datacenterList.stream().map(dc -> new DatacenterBrokerSimple(simulation)).toList(); } @@ -317,9 +290,7 @@ private void printHostStateHistory(final Host host) { new HostHistoryTableBuilder(host).setTitle(host.toString()).build(); } - /** - * Creates VMs and Cloudlets for each broker. - */ + /// Creates VMs and Cloudlets for each broker. private void createVmsAndCloudlets() { int i = 0; for (final DatacenterBroker broker : brokerList) { @@ -329,14 +300,12 @@ private void createVmsAndCloudlets() { } } - /** - * A listener that is called after all VMs from a broker are created, - * setting the allocation policy to the default value - * so that some Hosts will be overloaded with the placed VMs and migration will be fired. - * - *

      The listener is removed after finishing, so that it's called just once, - * even if new VMs are submitted and created later on.

      - */ + /// A listener that is called after all VMs from a broker are created, + /// setting the allocation policy to the default value + /// so that some Hosts will be overloaded with the placed VMs and migration will be fired. + /// + /// The listener is removed after finishing, so that it's called just once, + /// even if new VMs are submitted and created later on. private void onVmsCreatedListener(final DatacenterBrokerEventInfo info) { final var broker = info.getDatacenterBroker(); final String vmIds = broker.getVmCreatedList() @@ -363,13 +332,11 @@ public void createAndSubmitCloudlets(final DatacenterBroker broker) { broker.submitCloudletList(cloudletList); } - /** - * Creates a Cloudlet. - * - * @param vm the VM that will run the Cloudlets - * @param cpuUtilizationModel the CPU UtilizationModel for the Cloudlet - * @return the created Cloudlets - */ + /// Creates a Cloudlet. + /// + /// @param vm the VM that will run the Cloudlets + /// @param cpuUtilizationModel the CPU UtilizationModel for the Cloudlet + /// @return the created Cloudlets public Cloudlet createCloudlet(final Vm vm, final UtilizationModel cpuUtilizationModel) { final var broker = vm.getBroker(); final var cloudlet = @@ -390,12 +357,10 @@ public void createAndSubmitVms(final DatacenterBroker broker, final int[] vmPesA vmList.forEach(vm -> vm.addOnMigrationStartListener(this::startMigration)); } - /** - * A listener method that is called when a VM migration starts. - * @param info information about the happened event - * - * @see Vm#addOnMigrationFinishListener(EventListener) - */ + /// A listener method that is called when a VM migration starts. + /// @param info information about the happened event + /// + /// @see Vm#addOnMigrationFinishListener(EventListener) private void startMigration(final VmHostEventInfo info) { migrationsNumber++; } @@ -407,23 +372,21 @@ public Vm createVm(final int pes) { .setSize(VM_SIZE); } - /** - * Creates a CPU UtilizationModel for a Cloudlet. - * If the initial usage is lower than the max usage, the usage will - * be dynamically incremented along the time, according to the - * {@link #getCpuUsageIncrement(UtilizationModelDynamic)} - * function. Otherwise, the CPU usage will be static, according to the - * defined initial usage. - * - * @param initialCpuUsagePercent the percentage of CPU utilization - * that created Cloudlets will use when they start to execute. - * If this value is greater than 1 (100%), it will be changed to 1. - * @param maxCpuUsagePercentage the maximum percentage of - * CPU utilization that created Cloudlets are allowed to use. - * If this value is greater than 1 (100%), it will be changed to 1. - * It must be equal or greater than the initial CPU usage. - * @return - */ + /// Creates a CPU UtilizationModel for a Cloudlet. + /// If the initial usage is lower than the max usage, the usage will + /// be dynamically incremented along the time, according to the + /// [#getCpuUsageIncrement(UtilizationModelDynamic)] + /// function. Otherwise, the CPU usage will be static, according to the + /// defined initial usage. + /// + /// @param initialCpuUsagePercent the percentage of CPU utilization + /// that created Cloudlets will use when they start to execute. + /// If this value is greater than 1 (100%), it will be changed to 1. + /// @param maxCpuUsagePercentage the maximum percentage of + /// CPU utilization that created Cloudlets are allowed to use. + /// If this value is greater than 1 (100%), it will be changed to 1. + /// It must be equal or greater than the initial CPU usage. + /// @return private UtilizationModelDynamic createCpuUtilizationModel(double initialCpuUsagePercent, double maxCpuUsagePercentage) { if(maxCpuUsagePercentage < initialCpuUsagePercent){ throw new IllegalArgumentException("Max CPU usage must be equal or greater than the initial CPU usage."); @@ -442,10 +405,8 @@ private UtilizationModelDynamic createCpuUtilizationModel(double initialCpuUsage return um; } - /** - * Increments the CPU resource utilization, that is defined in percentage values. - * @return the new resource utilization after the increment - */ + /// Increments the CPU resource utilization, that is defined in percentage values. + /// @return the new resource utilization after the increment private double getCpuUsageIncrement(final UtilizationModelDynamic um){ return um.getUtilization() + um.getTimeSpan()*CLOUDLET_CPU_INCREMENT_PER_SECOND; } @@ -455,12 +416,10 @@ private List createDatacenters() { return IntStream.range(0, datacentersNumber).mapToObj(this::createDatacenter).toList(); } - /** - * Create a private-cloud Datacenter for even indexes and public-cloud one for odd indexes. - * @param index the Datacenter index - * @return the created Datacenter - * @see DatacenterCharacteristics.Distribution - */ + /// Create a private-cloud Datacenter for even indexes and public-cloud one for odd indexes. + /// @param index the Datacenter index + /// @return the created Datacenter + /// @see DatacenterCharacteristics.Distribution private Datacenter createDatacenter(final int index) { final var distribution = index % 2 == 0 ? Distribution.PRIVATE : Distribution.PUBLIC; final var hostList = createHosts(DC_HOST_PES[index]); diff --git a/src/main/java/org/cloudsimplus/examples/migration/ManualMigrationExample1.java b/src/main/java/org/cloudsimplus/examples/migration/ManualMigrationExample1.java index afd611a..e6ff1f5 100755 --- a/src/main/java/org/cloudsimplus/examples/migration/ManualMigrationExample1.java +++ b/src/main/java/org/cloudsimplus/examples/migration/ManualMigrationExample1.java @@ -54,44 +54,38 @@ import java.util.Comparator; import java.util.List; -/** - * An example showing how perform a manual VM migration - * according to any desired condition, such as - * when the simulation reaches specific times. - * - *

      This is a manual migration, different when using some - * {@link VmAllocationPolicyMigration} implementation. - * Such a policy automatically migrates VMs based on - * a static host CPU utilization threshold. - * In this example, such an implementation is not used - * and therefore, automatic VM migration based on CPU utilization threshold is not triggered. - * If you want to implement a VM migration policy, you should - * create a subclass from some of the existing ones. - * Usually the starting point is the {@link VmAllocationPolicyMigrationAbstract} - * but concrete implementations such as the {@link VmAllocationPolicyMigrationBestFitStaticThreshold} - * can be used as an example. - *

      - * - *

      VMs are initially placed into Hosts following the - * {@link VmAllocationPolicyFirstFit} policy, which doesn't implement automatic VM - * migration based on CPU utilization threshold. We call this VM as "manual migration" - * exactly because we are not using a {@link VmAllocationPolicyMigration} implementation - * and the migration is defined by the simulation class itself.

      - * - *

      When the simulation clock reaches a specific time, - * an arbitrary VM is migrated to an arbitrary Host. - * The clock advance is tracked by the {@link #clockTickListener(EventInfo)}, - * that actually fires the manual migration request. - *

      - * - * @author Manoel Campos da Silva Filho - * @see MigrationExample1 - * @since CloudSim Plus 5.0.4 - */ +/// An example showing how perform a manual VM migration +/// according to any desired condition, such as +/// when the simulation reaches specific times. +/// +/// This is a manual migration, different when using some +/// [VmAllocationPolicyMigration] implementation. +/// Such a policy automatically migrates VMs based on +/// a static host CPU utilization threshold. +/// In this example, such an implementation is not used +/// and therefore, automatic VM migration based on CPU utilization threshold is not triggered. +/// If you want to implement a VM migration policy, you should +/// create a subclass from some of the existing ones. +/// Usually the starting point is the [VmAllocationPolicyMigrationAbstract] +/// but concrete implementations such as the [VmAllocationPolicyMigrationBestFitStaticThreshold] +/// can be used as an example. +/// +/// VMs are initially placed into Hosts following the +/// [VmAllocationPolicyFirstFit] policy, which doesn't implement automatic VM +/// migration based on CPU utilization threshold. We call this VM as "manual migration" +/// exactly because we are not using a [VmAllocationPolicyMigration] implementation +/// and the migration is defined by the simulation class itself. +/// +/// When the simulation clock reaches a specific time, +/// an arbitrary VM is migrated to an arbitrary Host. +/// The clock advance is tracked by the [#clockTickListener(EventInfo)], +/// that actually fires the manual migration request. +/// +/// @author Manoel Campos da Silva Filho +/// @see MigrationExample1 +/// @since CloudSim Plus 5.0.4 public final class ManualMigrationExample1 { - /** - * @see Datacenter#getSchedulingInterval() - */ + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 1; private static final int HOSTS = 5; private static final int VMS = 3; @@ -100,21 +94,19 @@ public final class ManualMigrationExample1 { private static final long HOST_RAM = 500000; //host memory (MB) private static final long HOST_STORAGE = 1000000; //host storage - /** - * The time spent during VM migration depend on the - * bandwidth of the target Host. - * By default, a {@link Datacenter} - * uses only 50% of the BW to migrate VMs, while the - * remaining capacity is used for VM communication. - * This can be changed by calling - * {@link DatacenterSimple#setBandwidthPercentForMigration(double)}. - * - *

      The 16000 Mb/s is the same as 2000 MB/s. Since just half of this capacity - * is used for VM migration, only 1000 MB/s will be available for this process. - * The time that takes to migrate a Vm depend on the VM RAM capacity. - * Since VMs in this example are created with 2000 MB of RAM, any migration - * will take 2 seconds to finish, as can be seen in the logs. - */ + /// The time spent during VM migration depend on the + /// bandwidth of the target Host. + /// By default, a [Datacenter] + /// uses only 50% of the BW to migrate VMs, while the + /// remaining capacity is used for VM communication. + /// This can be changed by calling + /// [DatacenterSimple#setBandwidthPercentForMigration(double)]. + /// + /// The 16000 Mb/s is the same as 2000 MB/s. Since just half of this capacity + /// is used for VM migration, only 1000 MB/s will be available for this process. + /// The time that takes to migrate a Vm depend on the VM RAM capacity. + /// Since VMs in this example are created with 2000 MB of RAM, any migration + /// will take 2 seconds to finish, as can be seen in the logs. private static final long HOST_BW = 16000L; //Mb/s private static final int VM_MIPS = 1000; //for each PE @@ -127,9 +119,7 @@ public final class ManualMigrationExample1 { private static final long CLOUDLET_FILESIZE = 300; private static final long CLOUDLET_OUTPUTSIZE = 300; - /** - * List of all created VMs. - */ + /// List of all created VMs. private final List vmList = new ArrayList<>(); private final DatacenterBrokerSimple broker; private final Datacenter datacenter0; @@ -171,14 +161,12 @@ private ManualMigrationExample1(){ System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * Event listener which is called every time the simulation clock advances. - * When the simulation clock reaches 10 seconds, it migrates an arbitrary VM to - * an arbitrary Host. - * - * @param info information about the event happened. - * @see CloudSimPlus#addOnClockTickListener(EventListener) - */ + /// Event listener which is called every time the simulation clock advances. + /// When the simulation clock reaches 10 seconds, it migrates an arbitrary VM to + /// an arbitrary Host. + /// + /// @param info information about the event happened. + /// @see CloudSimPlus#addOnClockTickListener(EventListener) private void clockTickListener(EventInfo info) { if(!migrationRequested && info.getTime() >= 10){ final var sourceVm = vmList.get(0); @@ -189,14 +177,13 @@ private void clockTickListener(EventInfo info) { } } - /** - * Prints the state of a Host along the simulation time. - *

      Realize that the Host State History is just collected - * if {@link Host#isStateHistoryEnabled() history is enabled} - * by calling {@link Host#setStateHistoryEnabled(boolean)}.

      - * - * @param host - */ + /// Prints the state of a Host along the simulation time. + /// + /// Realize that the Host State History is just collected + /// if [history is enabled][Host#isStateHistoryEnabled()] + /// by calling [Host#setStateHistoryEnabled(boolean)]. + /// + /// @param host private void printHostHistory(Host host) { final boolean cpuUtilizationNotZero = host.getStateHistory() @@ -218,13 +205,11 @@ public void createAndSubmitCloudlets(DatacenterBroker broker) { broker.submitCloudletList(newCloudletList); } - /** - * Creates a Cloudlet. - * - * @param vm the VM that will run the Cloudlets - * @param broker the broker that the created Cloudlets belong to - * @return the created Cloudlets - */ + /// Creates a Cloudlet. + /// + /// @param vm the VM that will run the Cloudlets + /// @param broker the broker that the created Cloudlets belong to + /// @return the created Cloudlets public Cloudlet createCloudlet(Vm vm, DatacenterBroker broker) { final var cloudlet = new CloudletSimple(CLOUDLET_LENGHT, (int)vm.getPesNumber()) @@ -248,13 +233,11 @@ public void createAndSubmitVms(DatacenterBroker broker) { vmList.forEach(vm -> vm.addOnMigrationStartListener(this::startMigration)); } - /** - * A listener method that is called when a VM migration starts. - * @param info information about the happened event - * - * @see #createAndSubmitVms(DatacenterBroker) - * @see Vm#addOnMigrationFinishListener(EventListener) - */ + /// A listener method that is called when a VM migration starts. + /// @param info information about the happened event + /// + /// @see #createAndSubmitVms(DatacenterBroker) + /// @see Vm#addOnMigrationFinishListener(EventListener) private void startMigration(final VmHostEventInfo info) { final Vm vm = info.getVm(); final Host targetHost = info.getHost(); @@ -273,12 +256,10 @@ public Vm createVm(int pes) { return vm; } - /** - * Creates a Datacenter with number of Hosts defined by {@link #HOSTS}, - * but only some of these Hosts will be active (powered on) initially. - * - * @return - */ + /// Creates a Datacenter with number of Hosts defined by [#HOSTS], + /// but only some of these Hosts will be active (powered on) initially. + /// + /// @return private Datacenter createDatacenter() { for(int i = 0; i < HOSTS; i++){ final int pes = HOST_INITIAL_PES + i; diff --git a/src/main/java/org/cloudsimplus/examples/migration/MigrationExample1.java b/src/main/java/org/cloudsimplus/examples/migration/MigrationExample1.java index 7356aff..5ba6691 100755 --- a/src/main/java/org/cloudsimplus/examples/migration/MigrationExample1.java +++ b/src/main/java/org/cloudsimplus/examples/migration/MigrationExample1.java @@ -58,114 +58,94 @@ import static java.util.Comparator.comparingLong; -/** - * An example showing how to create 1 Datacenter having: 5 hosts - * with increasing number of PEs (starting at 4 PEs for the 1st host); - * 3 VMs with 2 PEs each one; - * and 1 cloudlet by VM, each one having the same number of PEs from its VM. - * - *

      The example then performs VM migration using - * a {@link VmAllocationPolicyMigrationBestFitStaticThreshold}. - * Such a policy migrates VMs based on - * a static host CPU utilization threshold. - * The VmAllocationPolicy used in this example ignores power consumption of Hosts. - * This way, it isn't required to set a PowerModel for Hosts.

      - * - *

      According to the allocation policy, VM 0 will be allocated to Host 0. - * Since Host 0 has just 4 PEs, allocating a second VM into it - * would cause overload. - * Each cloudlet will start using 80% of its VM CPU. - * As the VM 0 will run one Cloudlet and requires just 2 PEs from Host 0 (which has 4 PEs), - * the initial Host CPU usage will be just 40% (1 VM using 80% of 2 PEs from a total of 4 Host PEs = 0.8*2 / 4). - *

      - * - *

      - * Allocating a second VM into Host 0 would double the Host CPU utilization, - * overreaching its upper utilization threshold (defined as 70%). - * This way, VMs 1 and 2 are allocated to Host 1 which has 5 PEs. - *

      - * - *

      The {@link VmAllocationPolicyMigrationBestFitStaticThreshold} - * allows setting static under/over CPU utilization thresholds to - * enable VM migration. - * The example uses a {@link UtilizationModelDynamic} to define that CPU usage of cloudlets - * increases along simulation time. - * The first 2 Cloudlets start with a usage of 80% of CPU, - * which increases along the time (see {@link #CLOUDLET_CPU_INCREMENT_PER_SECOND}). - * The third Cloudlet starts at a lower CPU usage and increases in the same way. - *

      - * - *

      Some constants are used to create simulation objects such as - * {@link DatacenterSimple}, {@link Host} and {@link Vm}. - * The values of these constants were careful and accordingly chosen to allow: - * (i) migration of VMs due to either under and overloaded hosts; - * and (ii) the researcher to know exactly how the simulation will run - * and what will be the final results. - *

      - * - *

      - * Several values impact simulation results, such as - * (i) hosts CPU capacity and number of PEs, - * (ii) VMs and cloudlets requirements and - * (iii) even VM bandwidth (which defines the VM migration time). - *

      - * - *

      - * This way, if you want to change these values, you must - * define new appropriated ones to allow the simulation - * to run correctly.

      - * - *

      Realize that Host State History is just collected - * if you enable that by calling {@link Host#setStateHistoryEnabled(boolean)}.

      - * - * @author Manoel Campos da Silva Filho - */ +/// An example showing how to create 1 Datacenter having: 5 hosts +/// with increasing number of PEs (starting at 4 PEs for the 1st host); +/// 3 VMs with 2 PEs each one; +/// and 1 cloudlet by VM, each one having the same number of PEs from its VM. +/// +/// The example then performs VM migration using +/// a [VmAllocationPolicyMigrationBestFitStaticThreshold]. +/// Such a policy migrates VMs based on +/// a static host CPU utilization threshold. +/// The VmAllocationPolicy used in this example ignores power consumption of Hosts. +/// This way, it isn't required to set a PowerModel for Hosts. +/// +/// According to the allocation policy, VM 0 will be allocated to Host 0. +/// Since Host 0 has just 4 PEs, allocating a second VM into it +/// would cause overload. +/// Each cloudlet will start using 80% of its VM CPU. +/// As the VM 0 will run one Cloudlet and requires just 2 PEs from Host 0 (which has 4 PEs), +/// the initial Host CPU usage will be just 40% (1 VM using 80% of 2 PEs from a total of 4 Host PEs = 0.8*2 / 4). +/// +/// Allocating a second VM into Host 0 would double the Host CPU utilization, +/// overreaching its upper utilization threshold (defined as 70%). +/// This way, VMs 1 and 2 are allocated to Host 1 which has 5 PEs. +/// +/// The [VmAllocationPolicyMigrationBestFitStaticThreshold] +/// allows setting static under/over CPU utilization thresholds to +/// enable VM migration. +/// The example uses a [UtilizationModelDynamic] to define that CPU usage of cloudlets +/// increases along simulation time. +/// The first 2 Cloudlets start with a usage of 80% of CPU, +/// which increases along the time (see [#CLOUDLET_CPU_INCREMENT_PER_SECOND]). +/// The third Cloudlet starts at a lower CPU usage and increases in the same way. +/// +/// Some constants are used to create simulation objects such as +/// [DatacenterSimple], [Host] and [Vm]. +/// The values of these constants were careful and accordingly chosen to allow: +/// (i) migration of VMs due to either under and overloaded hosts; +/// and (ii) the researcher to know exactly how the simulation will run +/// and what will be the final results. +/// +/// Several values impact simulation results, such as +/// (i) hosts CPU capacity and number of PEs, +/// (ii) VMs and cloudlets requirements and +/// (iii) even VM bandwidth (which defines the VM migration time). +/// +/// This way, if you want to change these values, you must +/// define new appropriated ones to allow the simulation +/// to run correctly. +/// +/// Realize that Host State History is just collected +/// if you enable that by calling [Host#setStateHistoryEnabled(boolean)]. +/// +/// @author Manoel Campos da Silva Filho public final class MigrationExample1 { - /** - * @see Datacenter#getSchedulingInterval() - */ + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 1; - /** - * The percentage of host CPU usage that trigger VM migration - * due to under utilization (in scale from 0 to 1, where 1 is 100%). - */ + /// The percentage of host CPU usage that trigger VM migration + /// due to under utilization (in scale from 0 to 1, where 1 is 100%). private static final double HOST_UNDER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION = 0.1; - /** - * The percentage of host CPU usage that trigger VM migration - * due to over utilization (in scale from 0 to 1, where 1 is 100%). - */ + /// The percentage of host CPU usage that trigger VM migration + /// due to over utilization (in scale from 0 to 1, where 1 is 100%). private static final double HOST_OVER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION = 0.7; - /** @see Datacenter#setHostSearchRetryDelay(double) */ + /// @see Datacenter#setHostSearchRetryDelay(double) private static final int HOST_SEARCH_RETRY_DELAY = 60; - /** - * The time spent during VM migration depend on the - * bandwidth of the target Host. - * By default, a {@link Datacenter} - * uses only 50% of the BW to migrate VMs, while the - * remaining capacity is used for VM communication. - * This can be changed by calling - * {@link DatacenterSimple#setBandwidthPercentForMigration(double)}. - * - *

      The 16000 Mb/s is the same as 2000 MB/s. Since just half of this capacity - * is used for VM migration, only 1000 MB/s will be available for this process. - * The time that takes to migrate a Vm depend on the VM RAM capacity. - * Since VMs in this example are created with 2000 MB of RAM, any migration - * will take 2 seconds to finish, as can be seen in the logs. - */ + /// The time spent during VM migration depend on the + /// bandwidth of the target Host. + /// By default, a [Datacenter] + /// uses only 50% of the BW to migrate VMs, while the + /// remaining capacity is used for VM communication. + /// This can be changed by calling + /// [DatacenterSimple#setBandwidthPercentForMigration(double)]. + /// + /// The 16000 Mb/s is the same as 2000 MB/s. Since just half of this capacity + /// is used for VM migration, only 1000 MB/s will be available for this process. + /// The time that takes to migrate a Vm depend on the VM RAM capacity. + /// Since VMs in this example are created with 2000 MB of RAM, any migration + /// will take 2 seconds to finish, as can be seen in the logs. private static final long HOST_BW = 16_000L; //Mb/s private static final int HOST_MIPS = 1000; //for each PE private static final long HOST_RAM[] = {15_000, 500_000, 25_000}; //host memory (MB) private static final long HOST_STORAGE = 1_000_000; //host storage - /** - * An array where each item defines the number of PEs for each Host to be created. - * The length of the array represents the number of Hosts. - */ + /// An array where each item defines the number of PEs for each Host to be created. + /// The length of the array represents the number of Hosts. private static final int HOST_PES[] = {4, 5, 5}; private static final int VM_PES[] = {2, 2, 2, 1}; @@ -178,26 +158,20 @@ public final class MigrationExample1 { private static final long CLOUDLET_FILESIZE = 300; private static final long CLOUDLET_OUTPUTSIZE = 300; - /** - * The percentage of CPU that a cloudlet will use when - * it starts executing (in scale from 0 to 1, where 1 is 100%). - * For each cloudlet create, this value is used - * as a base to define CPU usage. - * @see #createAndSubmitCloudlets(DatacenterBroker) - */ + /// The percentage of CPU that a cloudlet will use when + /// it starts executing (in scale from 0 to 1, where 1 is 100%). + /// For each cloudlet create, this value is used + /// as a base to define CPU usage. + /// @see #createAndSubmitCloudlets(DatacenterBroker) private static final double CLOUDLET_INITIAL_CPU_PERCENTAGE = 0.8; - /** - * Defines the speed (in percentage) that CPU usage of a cloudlet - * will increase during the simulation execution. - * (in scale from 0 to 1, where 1 is 100%). - * @see #createCpuUtilizationModel(double, double) - */ + /// Defines the speed (in percentage) that CPU usage of a cloudlet + /// will increase during the simulation execution. + /// (in scale from 0 to 1, where 1 is 100%). + /// @see #createCpuUtilizationModel(double, double) private static final double CLOUDLET_CPU_INCREMENT_PER_SECOND = 0.04; - /** - * List of all created VMs. - */ + /// List of all created VMs. private final List vmList = new ArrayList<>(); private final DatacenterBrokerSimple broker; @@ -254,13 +228,11 @@ private void printHosts() { } } - /** - * A listener method that is called when a VM migration starts. - * @param info information about the happened event - * - * @see #createAndSubmitVms(DatacenterBroker) - * @see Vm#addOnMigrationFinishListener(EventListener) - */ + /// A listener method that is called when a VM migration starts. + /// @param info information about the happened event + /// + /// @see #createAndSubmitVms(DatacenterBroker) + /// @see Vm#addOnMigrationFinishListener(EventListener) private void startMigration(final VmHostEventInfo info) { final Vm vm = info.getVm(); final Host targetHost = info.getHost(); @@ -293,13 +265,11 @@ private void showVmAllocatedMips(final Vm vm, final Host targetHost, final doubl System.out.printf("%s %.0f MIPs (divided by %d PEs)%s\n", msg, allocatedMips.totalMips(), allocatedMips.pes(), msg2); } - /** - * A listener method that is called when a VM migration finishes. - * @param info information about the happened event - * - * @see #createAndSubmitVms(DatacenterBroker) - * @see Vm#addOnMigrationStartListener(EventListener) - */ + /// A listener method that is called when a VM migration finishes. + /// @param info information about the happened event + /// + /// @see #createAndSubmitVms(DatacenterBroker) + /// @see Vm#addOnMigrationStartListener(EventListener) private void finishMigration(final VmHostEventInfo info) { final var host = info.getHost(); System.out.printf( @@ -332,14 +302,12 @@ public void createAndSubmitCloudlets(DatacenterBroker broker) { broker.submitCloudletList(newCloudletList); } - /** - * Creates a Cloudlet. - * - * @param vm the VM that will run the Cloudlets - * @param broker the broker that the created Cloudlets belong to - * @param cpuUtilizationModel the CPU UtilizationModel for the Cloudlet - * @return the created Cloudlets - */ + /// Creates a Cloudlet. + /// + /// @param vm the VM that will run the Cloudlets + /// @param broker the broker that the created Cloudlets belong to + /// @param cpuUtilizationModel the CPU UtilizationModel for the Cloudlet + /// @return the created Cloudlets public Cloudlet createCloudlet(Vm vm, DatacenterBroker broker, UtilizationModel cpuUtilizationModel) { final var utilizationModelFull = new UtilizationModelFull(); @@ -376,23 +344,21 @@ public Vm createVm(final int pes) { return vm; } - /** - * Creates a CPU UtilizationModel for a Cloudlet. - * If the initial usage is lower than the max usage, the usage will - * be dynamically incremented along the time, according to the - * {@link #getCpuUsageIncrement(UtilizationModelDynamic)} - * function. Otherwise, the CPU usage will be static, according to the - * defined initial usage. - * - * @param initialCpuUsagePercent the percentage of CPU utilization - * that created Cloudlets will use when they start to execute. - * If this value is greater than 1 (100%), it will be changed to 1. - * @param maxCpuUsagePercentage the maximum percentage of - * CPU utilization that created Cloudlets are allowed to use. - * If this value is greater than 1 (100%), it will be changed to 1. - * It must be equal or greater than the initial CPU usage. - * @return - */ + /// Creates a CPU UtilizationModel for a Cloudlet. + /// If the initial usage is lower than the max usage, the usage will + /// be dynamically incremented along the time, according to the + /// [#getCpuUsageIncrement(UtilizationModelDynamic)] + /// function. Otherwise, the CPU usage will be static, according to the + /// defined initial usage. + /// + /// @param initialCpuUsagePercent the percentage of CPU utilization + /// that created Cloudlets will use when they start to execute. + /// If this value is greater than 1 (100%), it will be changed to 1. + /// @param maxCpuUsagePercentage the maximum percentage of + /// CPU utilization that created Cloudlets are allowed to use. + /// If this value is greater than 1 (100%), it will be changed to 1. + /// It must be equal or greater than the initial CPU usage. + /// @return private UtilizationModelDynamic createCpuUtilizationModel(double initialCpuUsagePercent, double maxCpuUsagePercentage) { if(maxCpuUsagePercentage < initialCpuUsagePercent){ throw new IllegalArgumentException("Max CPU usage must be equal or greater than the initial CPU usage."); @@ -411,20 +377,16 @@ private UtilizationModelDynamic createCpuUtilizationModel(double initialCpuUsage return um; } - /** - * Increments the CPU resource utilization, that is defined in percentage values. - * @return the new resource utilization after the increment - */ + /// Increments the CPU resource utilization, that is defined in percentage values. + /// @return the new resource utilization after the increment private double getCpuUsageIncrement(final UtilizationModelDynamic um){ return um.getUtilization() + um.getTimeSpan()*CLOUDLET_CPU_INCREMENT_PER_SECOND; } - /** - * Creates a Datacenter with number of Hosts defined by the length of {@link #HOST_PES}, - * but only some of these Hosts will be active (powered on) initially. - * - * @return - */ + /// Creates a Datacenter with number of Hosts defined by the length of [#HOST_PES], + /// but only some of these Hosts will be active (powered on) initially. + /// + /// @return private Datacenter createDatacenter() { System.out.println(); final var dc = new DatacenterSimple(simulation, hostList, allocationPolicy); @@ -438,17 +400,15 @@ private Datacenter createDatacenter() { return dc; } - /** - * Creates a VmAllocationPolicy that - * sets an upper utilization threshold higher than the - * {@link #HOST_OVER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION} - * to enable placing VMs which will use more CPU than - * defined by the value in the mentioned constant. - * After VMs are all submitted to Hosts, the threshold is changed - * to the value of the constant. - * This is used to place VMs into a Host which will - * become overloaded in order to trigger the migration. - */ + /// Creates a VmAllocationPolicy that + /// sets an upper utilization threshold higher than the + /// [#HOST_OVER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION] + /// to enable placing VMs which will use more CPU than + /// defined by the value in the mentioned constant. + /// After VMs are all submitted to Hosts, the threshold is changed + /// to the value of the constant. + /// This is used to place VMs into a Host which will + /// become overloaded in order to trigger the migration. private VmAllocationPolicyMigrationStaticThreshold createAllocationPolicy() { final var policy = new VmAllocationPolicyMigrationBestFitStaticThreshold( @@ -486,14 +446,12 @@ public List createPeList(final int pesNumber) { return peList; } - /** - * A listener that is called after all VMs from a broker are created, - * setting the allocation policy to the default value - * so that some Hosts will be overloaded with the placed VMs and migration will be fired. - * - *

      The listener is removed after finishing, so that it's called just once, - * even if new VMs are submitted and created latter on.

      - */ + /// A listener that is called after all VMs from a broker are created, + /// setting the allocation policy to the default value + /// so that some Hosts will be overloaded with the placed VMs and migration will be fired. + /// + /// The listener is removed after finishing, so that it's called just once, + /// even if new VMs are submitted and created latter on. private void onVmsCreatedListener(final DatacenterBrokerEventInfo info) { System.out.printf("# All %d VMs submitted to the broker have been created.%n", broker.getVmCreatedList().size()); allocationPolicy.setOverUtilizationThreshold(HOST_OVER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION); diff --git a/src/main/java/org/cloudsimplus/examples/migration/package-info.java b/src/main/java/org/cloudsimplus/examples/migration/package-info.java index a48ede5..9dc6246 100755 --- a/src/main/java/org/cloudsimplus/examples/migration/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/migration/package-info.java @@ -21,13 +21,11 @@ * You should have received a copy of the GNU General Public License * along with CloudSim Plus. If not, see . */ -/** - * Examples showing how to enable VM migration - * using a {@link org.cloudsimplus.allocationpolicies.migration.VmAllocationPolicyMigration}. - * Such policies define the conditions when VM migration should be fired. - * - * @author Manoel Campos da Silva Filho - */ +/// Examples showing how to enable VM migration +/// using a [org.cloudsimplus.allocationpolicies.migration.VmAllocationPolicyMigration]. +/// Such policies define the conditions when VM migration should be fired. +/// +/// @author Manoel Campos da Silva Filho @NullMarked package org.cloudsimplus.examples.migration; diff --git a/src/main/java/org/cloudsimplus/examples/performance/PerformanceExample1.java b/src/main/java/org/cloudsimplus/examples/performance/PerformanceExample1.java index 6a66502..5520cbc 100755 --- a/src/main/java/org/cloudsimplus/examples/performance/PerformanceExample1.java +++ b/src/main/java/org/cloudsimplus/examples/performance/PerformanceExample1.java @@ -55,25 +55,21 @@ import static java.util.stream.Collectors.toCollection; import static org.cloudsimplus.util.TimeUtil.secondsToStr; -/** - * An example that enables you to play with different parameters to - * check how they may drastically impact simulation performance. - * That includes the constants provided in this example - * (mainly the {@link #SCHEDULING_INTERVAL}), - * and the type of {@link VmAllocationPolicy} and {@link CloudletScheduler} - * created. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 6.5.0 - */ +/// An example that enables you to play with different parameters to +/// check how they may drastically impact simulation performance. +/// That includes the constants provided in this example +/// (mainly the [#SCHEDULING_INTERVAL]), +/// and the type of [VmAllocationPolicy] and [CloudletScheduler] +/// created. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 6.5.0 public class PerformanceExample1 { - /** - * Setting the scheduling interval as -1 drastically reduces simulation time, - * but cloudlets processing is just updated when a cloudlet finishes, - * which may reduce simulation accuracy. - * This parameter is a trade-off between performance and accuracy. - * @see Datacenter#getSchedulingInterval() - */ + /// Setting the scheduling interval as -1 drastically reduces simulation time, + /// but cloudlets processing is just updated when a cloudlet finishes, + /// which may reduce simulation accuracy. + /// This parameter is a trade-off between performance and accuracy. + /// @see Datacenter#getSchedulingInterval() private static final double SCHEDULING_INTERVAL = TimeUtil.hoursToSeconds(1); private static final int HOSTS = 50_000; private static final int HOST_PES = 64; @@ -84,15 +80,11 @@ public class PerformanceExample1 { private static final int CLOUDLET_PES = 2; private static final long CLOUDLET_LENGTH = 10_000_000_000L; - /** - * The percentage of RAM and BW each Cloudlet will request during all simulation execution - * (in scale from 0 to 1). - */ + /// The percentage of RAM and BW each Cloudlet will request during all simulation execution + /// (in scale from 0 to 1). private static final double RAM_BW_RESOURCE_UTILIZATION_PERCENT = 0.2; - /** - * A {@link Supplier} Function that returns a new instance of a specific {@link CloudletScheduler}. - */ + /// A [Supplier] Function that returns a new instance of a specific [CloudletScheduler]. private final Supplier cloudletSchedulerSupplier = CloudletSchedulerTimeShared::new; private final VmAllocationPolicyFirstFit vmAllocationPolicy = new VmAllocationPolicyFirstFit(); diff --git a/src/main/java/org/cloudsimplus/examples/performance/UtilizationModelFullPerformance.java b/src/main/java/org/cloudsimplus/examples/performance/UtilizationModelFullPerformance.java index b3305c8..f913a78 100755 --- a/src/main/java/org/cloudsimplus/examples/performance/UtilizationModelFullPerformance.java +++ b/src/main/java/org/cloudsimplus/examples/performance/UtilizationModelFullPerformance.java @@ -55,18 +55,16 @@ import static java.util.stream.Collectors.toCollection; -/** - * An example showing how the {@link UtilizationModelFull} increases simulation performance - * and reduces memory utilization. - * - *

      There are a set of constants you can change to see how the simulation - * is impacted. The most impacting ones are {@link #CLOUDLETS}, - * {@link #CLOUDLET_LENGTH} and {@link #SCHEDULING_INTERVAL}. - * Just play with these values to see the results.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.4.1 - */ +/// An example showing how the [UtilizationModelFull] increases simulation performance +/// and reduces memory utilization. +/// +/// There are a set of constants you can change to see how the simulation +/// is impacted. The most impacting ones are [#CLOUDLETS], +/// [#CLOUDLET_LENGTH] and [#SCHEDULING_INTERVAL]. +/// Just play with these values to see the results. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.4.1 public class UtilizationModelFullPerformance { private static final int HOSTS = 20_000; private static final int HOST_PES = 16; @@ -122,11 +120,9 @@ private UtilizationModelFullPerformance() { HOSTS, VMS, CLOUDLETS, CLOUDLET_LENGTH, SCHEDULING_INTERVAL); } - /** - * Gets the maximum number of GB ever used by the application's heap. - * @return the max heap utilization in GB - * @see Java Garbage Collection Basics (for information about heap space) - */ + /// Gets the maximum number of GB ever used by the application's heap. + /// @return the max heap utilization in GB + /// @see Java Garbage Collection Basics (for information about heap space) private double getMaxHeapUtilizationGB() { final double memoryBytes = ManagementFactory.getMemoryPoolMXBeans() diff --git a/src/main/java/org/cloudsimplus/examples/performance/UtilizationModelStochasticPerformance.java b/src/main/java/org/cloudsimplus/examples/performance/UtilizationModelStochasticPerformance.java index 02d6e6b..e9b4f04 100755 --- a/src/main/java/org/cloudsimplus/examples/performance/UtilizationModelStochasticPerformance.java +++ b/src/main/java/org/cloudsimplus/examples/performance/UtilizationModelStochasticPerformance.java @@ -56,31 +56,28 @@ import static java.util.stream.Collectors.toCollection; -/** - * An example showing how the {@link UtilizationModelStochastic} can affect - * the simulation time and memory utilization in large scale simulations. - * - *

      There are a set of constants you can change to see how the simulation - * is impacted. The most impacting ones are {@link #CLOUDLETS}, - * {@link #CLOUDLET_LENGTH}, {@link #SCHEDULING_INTERVAL}, - * {@link #MULTIPLE_UTILIZATION_MODELS} - * and {@link #STORE_CLOUDLETS_CPU_UTILIZATION_HISTORY}. - * Just play with these values to see the results.

      - * - *

      Since the utilization history Map stored by the {@link UtilizationModelStochastic} - * is commonly not used after the simulation finishes, - * maintaining such history is a time and memory expensive operation. - * This way, if you don't need such a history, you can - * disable it by setting {@link #STORE_CLOUDLETS_CPU_UTILIZATION_HISTORY} to false. - * However, keep in mind it is a trade-off between performance and memory consumption, - * as it's explained in {@link UtilizationModelStochastic#setHistoryEnabled(boolean)} - * documentation. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.3.6 - * @see Issue #197 for more details - */ +/// An example showing how the [UtilizationModelStochastic] can affect +/// the simulation time and memory utilization in large scale simulations. +/// +/// There are a set of constants you can change to see how the simulation +/// is impacted. The most impacting ones are [#CLOUDLETS], +/// [#CLOUDLET_LENGTH], [#SCHEDULING_INTERVAL], +/// [#MULTIPLE_UTILIZATION_MODELS] +/// and [#STORE_CLOUDLETS_CPU_UTILIZATION_HISTORY]. +/// Just play with these values to see the results. +/// +/// Since the utilization history Map stored by the [UtilizationModelStochastic] +/// is commonly not used after the simulation finishes, +/// maintaining such history is a time and memory expensive operation. +/// This way, if you don't need such a history, you can +/// disable it by setting [#STORE_CLOUDLETS_CPU_UTILIZATION_HISTORY] to false. +/// However, keep in mind it is a trade-off between performance and memory consumption, +/// as it's explained in [UtilizationModelStochastic#setHistoryEnabled(boolean)] +/// documentation. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.3.6 +/// @see Issue #197 for more details public class UtilizationModelStochasticPerformance { private static final int HOSTS = 20_000; private static final int HOST_PES = 16; @@ -93,31 +90,25 @@ public class UtilizationModelStochasticPerformance { private static final int CLOUDLET_LENGTH = 10_000; private static final int SCHEDULING_INTERVAL = 10; - /** - * Defines if one {@link UtilizationModel} must be instantiated - * for each Cloudlet or a single instance used by all Cloudlets. - * - *

      Realize that if you use a single {@link UtilizationModel} for all - * Cloudlets, the resource utilization will usually be the same - * for all of them. - * Using the {@link UtilizationModelStochastic}, if two Cloudlets - * consecutively request the current resource utilization for the same time, - * it will be returned the same value. If they send consecutive requests for different times, - * probably it will be returned distinct randomly generated values.

      - */ + /// Defines if one [UtilizationModel] must be instantiated + /// for each Cloudlet or a single instance used by all Cloudlets. + /// + /// Realize that if you use a single [UtilizationModel] for all + /// Cloudlets, the resource utilization will usually be the same + /// for all of them. + /// Using the [UtilizationModelStochastic], if two Cloudlets + /// consecutively request the current resource utilization for the same time, + /// it will be returned the same value. If they send consecutive requests for different times, + /// probably it will be returned distinct randomly generated values. private static final boolean MULTIPLE_UTILIZATION_MODELS = false; - /** - * See {@link UtilizationModelStochastic#isAlwaysGenNewRandUtilization()} - * for details. - */ + /// See [UtilizationModelStochastic#isAlwaysGenNewRandUtilization()] + /// for details. private static final boolean ALWAYS_GENERATE_NEW_RANDOM_UTILIZATION = false; - /** - * Indicates if the {@link UtilizationModelStochastic} instances - * will keep a map that stores the resource utilization along simulation - * execution. Disabling this flag reduces simulation time and memory consumption. - */ + /// Indicates if the [UtilizationModelStochastic] instances + /// will keep a map that stores the resource utilization along simulation + /// execution. Disabling this flag reduces simulation time and memory consumption. private static final boolean STORE_CLOUDLETS_CPU_UTILIZATION_HISTORY = true; private static final VmAllocationPolicy VM_ALLOCATION_POLICY = new VmAllocationPolicyFirstFit(); @@ -128,11 +119,9 @@ public class UtilizationModelStochasticPerformance { private List vmList; private List cloudletList; private Datacenter datacenter0; - /** - * The utilization model shared by all Cloudlets - * (when {@link #MULTIPLE_UTILIZATION_MODELS} is false). - * It's null until the first Cloudlet is created. - */ + /// The utilization model shared by all Cloudlets + /// (when [#MULTIPLE_UTILIZATION_MODELS] is false). + /// It's null until the first Cloudlet is created. private @Nullable UtilizationModelStochastic um; public static void main(String[] args) { @@ -171,11 +160,9 @@ private UtilizationModelStochasticPerformance() { HOSTS, VMS, CLOUDLETS, CLOUDLET_LENGTH, SCHEDULING_INTERVAL); } - /** - * Gets the maximum number of GB ever used by the application's heap. - * @return the max heap utilization in GB - * @see Java Garbage Collection Basics (for information about heap space) - */ + /// Gets the maximum number of GB ever used by the application's heap. + /// @return the max heap utilization in GB + /// @see Java Garbage Collection Basics (for information about heap space) private double getMaxHeapUtilizationGB() { final double memoryBytes = ManagementFactory.getMemoryPoolMXBeans() diff --git a/src/main/java/org/cloudsimplus/examples/power/HostActivationExample.java b/src/main/java/org/cloudsimplus/examples/power/HostActivationExample.java index ec031f1..29f8624 100755 --- a/src/main/java/org/cloudsimplus/examples/power/HostActivationExample.java +++ b/src/main/java/org/cloudsimplus/examples/power/HostActivationExample.java @@ -52,68 +52,60 @@ import java.util.List; import java.util.function.Function; -/** - * An example showing how to create a Datacenter with all Hosts powered off - * and let the {@link VmAllocationPolicy} to power Hosts on and off according to demand. - * For this simulation, the {@link VmAllocationPolicyBestFit} is used. - * - *

      The dynamic demand for Hosts is simulated - * by creating VMs during simulation runtime. - * To enable this, it's required to define - * a {@link Datacenter#setSchedulingInterval(double)} scheduling interval}. - * It's also used a Event Listener to track the simulation clock. - * This way, when the clock increases according to the scheduling interval, - * a new VM is created, up to the total VMs defined in {@link #MAX_VMS}.

      - * - *

      It creates one Cloudlet for each VM and the Cloudlets are created with different lengths. - * This enables VMs to become idle in different times. - * To ensure idle VMs are destroyed as soon as they become idle - * (so that we can quickly check that the number of VMs into a Host has reduced), - * a {@link DatacenterBroker#setVmDestructionDelayFunction(Function)} is - * set. Check the {@link #createBroker()} method for details. - * - *

      Since the total number of PEs requested by all VMs is equal to 24 - * and each Host has 8 PEs, it's only used 3 Hosts to meet the demand.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.2.0 - */ +/// An example showing how to create a Datacenter with all Hosts powered off +/// and let the [VmAllocationPolicy] to power Hosts on and off according to demand. +/// For this simulation, the [VmAllocationPolicyBestFit] is used. +/// +/// The dynamic demand for Hosts is simulated +/// by creating VMs during simulation runtime. +/// To enable this, it's required to define +/// a [Datacenter#setSchedulingInterval(double)] scheduling interval}. +/// It's also used a Event Listener to track the simulation clock. +/// This way, when the clock increases according to the scheduling interval, +/// a new VM is created, up to the total VMs defined in [#MAX_VMS]. +/// +/// It creates one Cloudlet for each VM and the Cloudlets are created with different lengths. +/// This enables VMs to become idle in different times. +/// To ensure idle VMs are destroyed as soon as they become idle +/// (so that we can quickly check that the number of VMs into a Host has reduced), +/// a [DatacenterBroker#setVmDestructionDelayFunction(Function)] is +/// set. Check the [#createBroker()] method for details. +/// +/// Since the total number of PEs requested by all VMs is equal to 24 +/// and each Host has 8 PEs, it's only used 3 Hosts to meet the demand. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.2.0 public class HostActivationExample { - /** - * Defines, between other things, the time intervals - * to keep Hosts CPU utilization history records. - */ + /// Defines, between other things, the time intervals + /// to keep Hosts CPU utilization history records. private static final int SCHEDULING_INTERVAL = 2; private static final int HOSTS = 5; private static final int HOST_PES = 8; - /** - * Defines the power a Host uses, even if it's idle (in Watts). - */ + /// Defines the power a Host uses, even if it's idle (in Watts). private static final double STATIC_POWER = 35; - /** - * The max power a Host uses (in Watts). - */ + /// The max power a Host uses (in Watts). private static final int MAX_POWER = 50; - /** Indicates the time (in seconds) the Host takes to start up. - * Setting a value larger than 0 makes the VM placement to wait for the Host initialization. */ + /// Indicates the time (in seconds) the Host takes to start up. + /// Setting a value larger than 0 makes the VM placement to wait for the Host initialization. private static final double HOST_START_UP_DELAY = 20; - /** Indicates the time (in seconds) the Host takes to shut down. */ + /// Indicates the time (in seconds) the Host takes to shut down. private static final double HOST_SHUT_DOWN_DELAY = 10; - /** Indicates the power (in watts) the Host consumes for starting up. */ + /// Indicates the power (in watts) the Host consumes for starting up. private static final double HOST_START_UP_POWER = 40; - /** Indicates the power (in watts) the Host consumes for shutting up. */ + /// Indicates the power (in watts) the Host consumes for shutting up. private static final double HOST_SHUT_DOWN_POWER = 15; - /** The deadline (in seconds) after the Host becoming idle that it will be shutdown - * automatically. - * @see Host#setIdleShutdownDeadline(double) */ + /// The deadline (in seconds) after the Host becoming idle that it will be shutdown + /// automatically. + /// @see Host#setIdleShutdownDeadline(double) private static final int HOST_IDLE_SECONDS_TO_SHUTDOWN = 5; private static final int HOST_MIPS = 1000; @@ -162,12 +154,10 @@ private HostActivationExample() { printHostsUpTime(); } - /** - * After a Host is shutdown, send new VMs to force a new Host activation. - * This way, we can see the total power consumed during host startup and shutdown - * is larger for those Hosts which have started more than once. - * @param info - */ + /// After a Host is shutdown, send new VMs to force a new Host activation. + /// This way, we can see the total power consumed during host startup and shutdown + /// is larger for those Hosts which have started more than once. + /// @param info private void hostShutdownListener(final HostEventInfo info) { final var createVmList = createAndSubmitVmsAndCloudlets(MIN_VMS*2); final var host = info.getHost(); @@ -213,13 +203,11 @@ private DatacenterBroker createBroker() { return broker; } - /** - * Event listener which is called every time the simulation clock advances. - * Then, if the time defined in the {@link #SCHEDULING_INTERVAL} has passed, - * it created another VM. - * - * @param info information about the event happened. - */ + /// Event listener which is called every time the simulation clock advances. + /// Then, if the time defined in the [#SCHEDULING_INTERVAL] has passed, + /// it created another VM. + /// + /// @param info information about the event happened. private void clockTickListener(final EventInfo info) { final double time = Math.floor(info.getTime()); final double retryDelay = broker0.getVmCreation().getRetryDelay(); @@ -263,11 +251,9 @@ private Datacenter createDatacenter() { return dc; } - /** - * Creates a Host and doesn't power it on (it will be powered on according to demand). - * @return a new powered-off Host - * @param id - */ + /// Creates a Host and doesn't power it on (it will be powered on according to demand). + /// @return a new powered-off Host + /// @param id private Host createHost(final long id) { final var peList = new ArrayList(HOST_PES); //List of Host's CPUs (Processing Elements, PEs) @@ -292,11 +278,9 @@ private Host createHost(final long id) { return host; } - /** - * Creates a Cloudlet - * @param vm the VM to run the Cloudlet - * @return - */ + /// Creates a Cloudlet + /// @param vm the VM to run the Cloudlet + /// @return private Cloudlet createCloudlet(Vm vm) { final var utilizationModel = new UtilizationModelDynamic(0.4); /* Reduces the length to let the firstly created Cloudlets to run longer, diff --git a/src/main/java/org/cloudsimplus/examples/power/PowerExample.java b/src/main/java/org/cloudsimplus/examples/power/PowerExample.java index e4cc4ff..84ee72c 100755 --- a/src/main/java/org/cloudsimplus/examples/power/PowerExample.java +++ b/src/main/java/org/cloudsimplus/examples/power/PowerExample.java @@ -52,64 +52,59 @@ import static java.util.Comparator.comparingLong; -/** - * An example to show power consumption of Hosts and VMs. - * Realize that for this goal, you define a {@link PowerModel} - * for each Host by calling {@code host.setPowerModel(powerModel)}. - * - *

      It creates the number of cloudlets defined in - * {@link #CLOUDLETS}. All cloudlets will require 100% of PEs they are using all the time. - * Half of these cloudlets are created with the length defined by {@link #CLOUDLET_LENGTH} - * and the other half will have the double of this length. - * This way, it's possible to see that for the last half of the - * simulation time, a Host doesn't use the entire CPU capacity, - * and therefore doesn't consume the maximum power.

      - * - *

      However, you may notice in this case that the power usage isn't - * half of the maximum consumption, because there is a static minimum - * amount of power to use, even if the Host is idle, - * which is defined by {@link #STATIC_POWER}. - * Check {@link PowerModelHostSimple#PowerModelHostSimple(double, double)}. - *

      - * - *

      Realize that the Host CPU Utilization History is only stored - * if VMs utilization history is enabled by calling - * {@code vm.getUtilizationHistory().enable()}

      - * - *

      Each line in the table with CPU utilization and power consumption shows - * the data from the time specified in the line, up to the time before the value in the next line. - * For instance, consider the scheduling interval is 10, the time in the first line is 1 and - * it shows 100% CPU utilization and 100 W of power consumption. - * Then, the next line contains data for time 10. - * It means that for any point between time 1 to time 10, - * the CPU utilization and power consumption is the one provided in that first line.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.2.4 - * - * @see PowerSpecFileExample - * @see VmsRamAndBwUsageExample - * @see org.cloudsimplus.examples.resourceusage.VmsCpuUsageExample - */ +/// An example to show power consumption of Hosts and VMs. +/// Realize that for this goal, you define a [PowerModel] +/// for each Host by calling `host.setPowerModel(powerModel)`. +/// +/// It creates the number of cloudlets defined in +/// [#CLOUDLETS]. All cloudlets will require 100% of PEs they are using all the time. +/// Half of these cloudlets are created with the length defined by [#CLOUDLET_LENGTH] +/// and the other half will have the double of this length. +/// This way, it's possible to see that for the last half of the +/// simulation time, a Host doesn't use the entire CPU capacity, +/// and therefore doesn't consume the maximum power. +/// +/// However, you may notice in this case that the power usage isn't +/// half of the maximum consumption, because there is a static minimum +/// amount of power to use, even if the Host is idle, +/// which is defined by [#STATIC_POWER]. +/// Check [PowerModelHostSimple#PowerModelHostSimple(double,double)]. +/// +/// Realize that the Host CPU Utilization History is only stored +/// if VMs utilization history is enabled by calling +/// `vm.getUtilizationHistory().enable()` +/// +/// Each line in the table with CPU utilization and power consumption shows +/// the data from the time specified in the line, up to the time before the value in the next line. +/// For instance, consider the scheduling interval is 10, the time in the first line is 1 and +/// it shows 100% CPU utilization and 100 W of power consumption. +/// Then, the next line contains data for time 10. +/// It means that for any point between time 1 to time 10, +/// the CPU utilization and power consumption is the one provided in that first line. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.2.4 +/// +/// @see PowerSpecFileExample +/// @see VmsRamAndBwUsageExample +/// @see org.cloudsimplus.examples.resourceusage.VmsCpuUsageExample public class PowerExample { - /** - * Defines, between other things, the time intervals - * to keep Hosts CPU utilization history records. - */ + /// Defines, between other things, the time intervals + /// to keep Hosts CPU utilization history records. private static final int SCHEDULING_INTERVAL = 10; private static final int HOSTS = 2; private static final int HOST_PES = 8; - /** Indicates the time (in seconds) the Host takes to start up. */ + /// Indicates the time (in seconds) the Host takes to start up. private static final double HOST_START_UP_DELAY = 5; - /** Indicates the time (in seconds) the Host takes to shut down. */ + /// Indicates the time (in seconds) the Host takes to shut down. private static final double HOST_SHUT_DOWN_DELAY = 3; - /** Indicates Host power consumption (in Watts) during startup. */ + /// Indicates Host power consumption (in Watts) during startup. private static final double HOST_START_UP_POWER = 5; - /** Indicates Host power consumption (in Watts) during shutdown. */ + /// Indicates Host power consumption (in Watts) during shutdown. private static final double HOST_SHUT_DOWN_POWER = 3; private static final int VMS = 4; @@ -119,14 +114,10 @@ public class PowerExample { private static final int CLOUDLET_PES = 2; private static final int CLOUDLET_LENGTH = 50000; - /** - * Defines the power a Host uses, even if it's idle (in Watts). - */ + /// Defines the power a Host uses, even if it's idle (in Watts). private static final double STATIC_POWER = 35; - /** - * The max power a Host uses (in Watts). - */ + /// The max power a Host uses (in Watts). private static final int MAX_POWER = 50; private final CloudSimPlus simulation; @@ -168,38 +159,31 @@ private PowerExample() { printVmsCpuUtilizationAndPowerConsumption(); } - /** - * Prints the following information from VM's utilization stats: - *
        - *
      • VM's mean CPU utilization relative to the total Host's CPU utilization. - * For instance, if the CPU utilization mean of two equal VMs is 100% of their CPU, the utilization - * of each one corresponds to 50% of the Host's CPU utilization.
      • - *
      • VM's power consumption relative to the total Host's power consumption.
      • - *
      - * - *

      A Host, even if idle, may consume a static amount of power. - * Lets say it consumes 20 W in idle state and that for each 1% of CPU use it consumes 1 W more. - * For the 2 VMs of the example above, each one using 50% of CPU will consume 50 W. - * That is 100 W for the 2 VMs, plus the 20 W that is static. - * Therefore we have a total Host power consumption of 120 W. - *

      - * - *

      - * If we computer the power consumption for a single VM by - * calling {@code vm.getHost().getPowerModel().getPower(hostCpuUsage)}, - * we get the 50 W consumed by the VM, plus the 20 W of static power. - * This adds up to 70 W. If the two VMs are equal and using the same amount of CPU, - * their power consumption would be the half of the total Host's power consumption. - * This would be 60 W, not 70. - *

      - * - *

      This way, we have to compute VM power consumption by sharing a supposed Host static power - * consumption with each VM, as it's being shown here. - * Not all {@link PowerModel} have this static power consumption. - * However, the way the VM power consumption - * is computed here, that detail is abstracted. - *

      - */ + /// Prints the following information from VM's utilization stats: + /// + /// - VM's mean CPU utilization relative to the total Host's CPU utilization. + /// For instance, if the CPU utilization mean of two equal VMs is 100% of their CPU, the utilization + /// of each one corresponds to 50% of the Host's CPU utilization. + /// - VM's power consumption relative to the total Host's power consumption. + /// + /// A Host, even if idle, may consume a static amount of power. + /// Lets say it consumes 20 W in idle state and that for each 1% of CPU use it consumes 1 W more. + /// For the 2 VMs of the example above, each one using 50% of CPU will consume 50 W. + /// That is 100 W for the 2 VMs, plus the 20 W that is static. + /// Therefore we have a total Host power consumption of 120 W. + /// + /// If we computer the power consumption for a single VM by + /// calling `vm.getHost().getPowerModel().getPower(hostCpuUsage)`, + /// we get the 50 W consumed by the VM, plus the 20 W of static power. + /// This adds up to 70 W. If the two VMs are equal and using the same amount of CPU, + /// their power consumption would be the half of the total Host's power consumption. + /// This would be 60 W, not 70. + /// + /// This way, we have to compute VM power consumption by sharing a supposed Host static power + /// consumption with each VM, as it's being shown here. + /// Not all [PowerModel] have this static power consumption. + /// However, the way the VM power consumption + /// is computed here, that detail is abstracted. private void printVmsCpuUtilizationAndPowerConsumption() { vmList.sort(comparingLong(vm -> vm.getHost().getId())); for (Vm vm : vmList) { @@ -217,11 +201,9 @@ private void printVmsCpuUtilizationAndPowerConsumption() { } } - /** - * The Host CPU Utilization History is only computed - * if VMs utilization history is enabled by calling - * {@code vm.getUtilizationHistory().enable()}. - */ + /// The Host CPU Utilization History is only computed + /// if VMs utilization history is enabled by calling + /// `vm.getUtilizationHistory().enable()`. private void printHostsCpuUtilizationAndPowerConsumption() { System.out.println(); for (final Host host : hostList) { @@ -241,9 +223,7 @@ private void printHostCpuUtilizationAndPowerConsumption(final Host host) { host.getId(), utilizationPercentMean * 100, watts); } - /** - * Creates a {@link Datacenter} and its {@link Host}s. - */ + /// Creates a [Datacenter] and its [Host]s. private Datacenter createDatacenter() { for(int i = 0; i < HOSTS; i++) { @@ -285,9 +265,7 @@ private Host createPowerHost(final int id) { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var list = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -299,9 +277,7 @@ private List createVms() { return list; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var cloudletList = new ArrayList(CLOUDLETS); final var utilization = new UtilizationModelDynamic(0.2); diff --git a/src/main/java/org/cloudsimplus/examples/power/PowerExampleSchedulingInterval.java b/src/main/java/org/cloudsimplus/examples/power/PowerExampleSchedulingInterval.java index fa7af1a..ff432ce 100755 --- a/src/main/java/org/cloudsimplus/examples/power/PowerExampleSchedulingInterval.java +++ b/src/main/java/org/cloudsimplus/examples/power/PowerExampleSchedulingInterval.java @@ -48,23 +48,21 @@ import java.util.ArrayList; import java.util.List; -/** - * An example to show how the accuracy of power consumption may change - * according to different Datacenter scheduling intervals. - * As lower is its value, higher is the power consumption accuracy - * because power consumption data will be collected in smaller intervals. - * - *

      CloudSim Plus has a very accurate and consistent power consumption computation. - * This way, you can see in this example that results just change - * when a scheduling interval is set with a value equals to the time the last - * Cloudlet finishes. - * - *

      You are strongly encouraged to firstly check the {@link PowerExample} to understand the details.

      - * - * @author Manoel Campos da Silva Filho - * @author Alexandre Henrique Teixeira Dias - * @since CloudSim Plus 4.0.0 - */ +/// An example to show how the accuracy of power consumption may change +/// according to different Datacenter scheduling intervals. +/// As lower is its value, higher is the power consumption accuracy +/// because power consumption data will be collected in smaller intervals. +/// +/// CloudSim Plus has a very accurate and consistent power consumption computation. +/// This way, you can see in this example that results just change +/// when a scheduling interval is set with a value equals to the time the last +/// Cloudlet finishes. +/// +/// You are strongly encouraged to firstly check the [PowerExample] to understand the details. +/// +/// @author Manoel Campos da Silva Filho +/// @author Alexandre Henrique Teixeira Dias +/// @since CloudSim Plus 4.0.0 public class PowerExampleSchedulingInterval { private static final int HOSTS = 2; private static final int HOST_PES = 8; @@ -76,14 +74,10 @@ public class PowerExampleSchedulingInterval { private static final int CLOUDLET_PES = 2; private static final int CLOUDLET_LENGTH = 50000; - /** - * Defines the power a Host uses, even if it's idle (in Watts). - */ + /// Defines the power a Host uses, even if it's idle (in Watts). private static final double STATIC_POWER = 35; - /** - * The max power a Host uses (in Watts). - */ + /// The max power a Host uses (in Watts). private static final int MAX_POWER = 50; private final int schedulingInterval; @@ -103,11 +97,8 @@ public static void main(String[] args) { } } - /** - * Instantiates and run the example with a specific configuration. - * @param schedulingInterval the {@link Datacenter#getSchedulingInterval()} (in seconds) - * - */ + /// Instantiates and run the example with a specific configuration. + /// @param schedulingInterval the [Datacenter#getSchedulingInterval()] (in seconds) private PowerExampleSchedulingInterval(final int schedulingInterval) { simulation = new CloudSimPlus(); hostList = new ArrayList<>(HOSTS); diff --git a/src/main/java/org/cloudsimplus/examples/power/PowerSpecFileExample.java b/src/main/java/org/cloudsimplus/examples/power/PowerSpecFileExample.java index 30e9393..7d18f17 100755 --- a/src/main/java/org/cloudsimplus/examples/power/PowerSpecFileExample.java +++ b/src/main/java/org/cloudsimplus/examples/power/PowerSpecFileExample.java @@ -50,39 +50,35 @@ import static java.util.Comparator.comparingLong; -/** - * An example to show power consumption of Hosts - * using the specifications from a file created based on - * www.specs.org website public data. - * Realize that for this goal, you define a {@link PowerModelHostSpec} - * for each Host by calling {@code host.setPowerModel(powerModel)}. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 8.1.0 - * - * @see #POWER_SPEC_FILE - * @see #createPowerHost(int) - * @see PowerExample - */ +/// An example to show power consumption of Hosts +/// using the specifications from a file created based on +/// [www.specs.org](https://www.specs.org) website public data. +/// Realize that for this goal, you define a [PowerModelHostSpec] +/// for each Host by calling `host.setPowerModel(powerModel)`. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 8.1.0 +/// +/// @see #POWER_SPEC_FILE +/// @see #createPowerHost(int) +/// @see PowerExample public class PowerSpecFileExample { - /** - * Defines, between other things, the time intervals - * to keep Hosts CPU utilization history records. - */ + /// Defines, between other things, the time intervals + /// to keep Hosts CPU utilization history records. private static final int SCHEDULING_INTERVAL = 10; private static final int HOSTS = 2; private static final int HOST_PES = 8; - /** Indicates the time (in seconds) the Host takes to start up. */ + /// Indicates the time (in seconds) the Host takes to start up. private static final double HOST_START_UP_DELAY = 5; - /** Indicates the time (in seconds) the Host takes to shut down. */ + /// Indicates the time (in seconds) the Host takes to shut down. private static final double HOST_SHUT_DOWN_DELAY = 3; - /** Indicates Host power consumption (in Watts) during startup. */ + /// Indicates Host power consumption (in Watts) during startup. private static final double HOST_START_UP_POWER = 5; - /** Indicates Host power consumption (in Watts) during shutdown. */ + /// Indicates Host power consumption (in Watts) during shutdown. private static final double HOST_SHUT_DOWN_POWER = 3; private static final int VMS = 4; @@ -92,9 +88,7 @@ public class PowerSpecFileExample { private static final int CLOUDLET_PES = 2; private static final int CLOUDLET_LENGTH = 50000; - /** - * The path to the file containing host power utilization specs. - */ + /// The path to the file containing host power utilization specs. private static final String POWER_SPEC_FILE = "power-specs/PowerModelSpecPowerHpProLiantMl110G3PentiumD930.txt"; private final CloudSimPlus simulation; @@ -104,12 +98,10 @@ public class PowerSpecFileExample { private Datacenter datacenter0; private final List hostList; - /** - * Indicates how hosts consume power according to CPU utilization percentage - * (based on data from a power spec file). - * This attribute is used just to ensure the same data will be read just once - * and used for all created Hosts. - */ + /// Indicates how hosts consume power according to CPU utilization percentage + /// (based on data from a power spec file). + /// This attribute is used just to ensure the same data will be read just once + /// and used for all created Hosts. private final PowerModelHostSpec DEF_POWER_MODEL = PowerModelHostSpec.getInstance(POWER_SPEC_FILE); public static void main(String[] args) { @@ -143,11 +135,9 @@ private PowerSpecFileExample() { printHostsCpuUtilizationAndPowerConsumption(); } - /** - * The Host CPU Utilization History is only computed - * if VMs utilization history is enabled by calling - * {@code vm.getUtilizationHistory().enable()}. - */ + /// The Host CPU Utilization History is only computed + /// if VMs utilization history is enabled by calling + /// `vm.getUtilizationHistory().enable()`. private void printHostsCpuUtilizationAndPowerConsumption() { System.out.println(); for (final Host host : hostList) { @@ -167,9 +157,7 @@ private void printHostCpuUtilizationAndPowerConsumption(final Host host) { host.getId(), utilizationPercentMean * 100, watts); } - /** - * Creates a {@link Datacenter} and its {@link Host}s. - */ + /// Creates a [Datacenter] and its [Host]s. private Datacenter createDatacenter() { for(int i = 0; i < HOSTS; i++) { final var host = createPowerHost(i); @@ -211,9 +199,7 @@ private Host createPowerHost(final int id) { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var list = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -225,9 +211,7 @@ private List createVms() { return list; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var cloudletList = new ArrayList(CLOUDLETS); final var utilization = new UtilizationModelDynamic(0.2); diff --git a/src/main/java/org/cloudsimplus/examples/resourceusage/HostsCpuUsageExample.java b/src/main/java/org/cloudsimplus/examples/resourceusage/HostsCpuUsageExample.java index b1ab6c3..45487b8 100755 --- a/src/main/java/org/cloudsimplus/examples/resourceusage/HostsCpuUsageExample.java +++ b/src/main/java/org/cloudsimplus/examples/resourceusage/HostsCpuUsageExample.java @@ -45,19 +45,17 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to create a Datacenter with two hosts, - * with one Vm in each one, and run 1 cloudlet in each Vm. - * At the end, it shows the total CPU utilization of hosts - * into a Datacenter. - * - *

      Cloudlets run in VMs with different MIPS requirements and will - * take different times to complete the execution, depending on the requested VM - * performance.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - */ +/// An example showing how to create a Datacenter with two hosts, +/// with one Vm in each one, and run 1 cloudlet in each Vm. +/// At the end, it shows the total CPU utilization of hosts +/// into a Datacenter. +/// +/// Cloudlets run in VMs with different MIPS requirements and will +/// take different times to complete the execution, depending on the requested VM +/// performance. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 public class HostsCpuUsageExample { private List cloudletList; private List vmlist; @@ -132,13 +130,11 @@ private Cloudlet createCloudlet(final int pesNumber) { .setUtilizationModel(utilizationModel); } - /** - * Creates a VM enabling the collection of CPU utilization history. - * This way, hosts can get the CPU utilization based on VM utilization. - * @param pesNumber - * @param mips - * @return - */ + /// Creates a VM enabling the collection of CPU utilization history. + /// This way, hosts can get the CPU utilization based on VM utilization. + /// @param pesNumber + /// @param mips + /// @return private Vm createVm(final int pesNumber, final long mips) { final long size = 10000; //image size (Megabyte) final int ram = 2048; //vm memory (Megabyte) @@ -150,9 +146,7 @@ private Vm createVm(final int pesNumber, final long mips) { return vm; } - /** - * Shows CPU utilization mean of all hosts into a given Datacenter. - */ + /// Shows CPU utilization mean of all hosts into a given Datacenter. private void printCpuUtilizationForAllHosts() { for (final var host : hostList) { final double mipsByPe = host.getTotalMipsCapacity() / (double)host.getPesNumber(); @@ -171,13 +165,11 @@ private void printCpuUtilizationForAllVms() { } } - /** - * Creates a datacenter setting the scheduling interval - * that, between other things, defines the times to collect - * VM CPU utilization. - * - * @return - */ + /// Creates a datacenter setting the scheduling interval + /// that, between other things, defines the times to collect + /// VM CPU utilization. + /// + /// @return private Datacenter createDatacenter() { hostList = new ArrayList<>(NUMBER_OF_HOSTS); final int pesNumber = 1; diff --git a/src/main/java/org/cloudsimplus/examples/resourceusage/UtilizationModelDynamicExample.java b/src/main/java/org/cloudsimplus/examples/resourceusage/UtilizationModelDynamicExample.java index fe3dbf7..2aa1ebf 100755 --- a/src/main/java/org/cloudsimplus/examples/resourceusage/UtilizationModelDynamicExample.java +++ b/src/main/java/org/cloudsimplus/examples/resourceusage/UtilizationModelDynamicExample.java @@ -44,15 +44,13 @@ import java.util.ArrayList; import java.util.List; -/** - * An example that uses a {@link UtilizationModelDynamic} to define how a Cloudlet - * uses the VM CPU in order to use just 50% of CPU capacity (MIPS) - * all the time. That makes the Cloudlet spend the double of the expected - * time to finish. - * - * @author raysaoliveira - * @since CloudSim Plus 1.0 - */ +/// An example that uses a [UtilizationModelDynamic] to define how a Cloudlet +/// uses the VM CPU in order to use just 50% of CPU capacity (MIPS) +/// all the time. That makes the Cloudlet spend the double of the expected +/// time to finish. +/// +/// @author raysaoliveira +/// @since CloudSim Plus 1.0 public class UtilizationModelDynamicExample { private static final int HOSTS = 1; private static final int VMS = 1; @@ -66,9 +64,7 @@ public static void main(String[] args) { new UtilizationModelDynamicExample(); } - /** - * Default constructor that builds the simulation. - */ + /// Default constructor that builds the simulation. private UtilizationModelDynamicExample() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -86,9 +82,7 @@ on behalf of a given cloud user (customer).*/ this.vmList = new ArrayList<>(VMS); this.cloudletList = new ArrayList<>(VMS); - /** - * Creates VMs and one Cloudlet for each VM. - */ + /// Creates VMs and one Cloudlet for each VM. for (int i = 0; i < VMS; i++) { final var vm = createVm(broker0); this.vmList.add(vm); diff --git a/src/main/java/org/cloudsimplus/examples/resourceusage/VirtualMemoryForRequestedRamHigherThanAvailableExample.java b/src/main/java/org/cloudsimplus/examples/resourceusage/VirtualMemoryForRequestedRamHigherThanAvailableExample.java index 8746ef0..2e833dd 100755 --- a/src/main/java/org/cloudsimplus/examples/resourceusage/VirtualMemoryForRequestedRamHigherThanAvailableExample.java +++ b/src/main/java/org/cloudsimplus/examples/resourceusage/VirtualMemoryForRequestedRamHigherThanAvailableExample.java @@ -51,62 +51,51 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -/** - * An example showing how the processing of some Cloudlets is delayed - * due to lack of available RAM and BW. - * - *

      The example creates VMs with different number of Cloudlets. - * Those Cloudlets have different {@link UtilizationModel}s for RAM. - * Some Cloudlets inside a given VM will require more RAM than the VM has available. - * For instance, two Cloudlets inside a VM always require 60% of the VM capacity at the same time. - * Since that total will be 120% of the RAM capacity, there is no way to fulfill the request - * for one of those Cloudlets. - * This way, one Cloudlet will use 60% of the VM RAM, while the other one will use only 40%. - * The 20% of RAM the second Cloudlets is requiring has to rely on Virtual Memory. - * In this scenario, CloudSim Plus will simulate the swap of memory data belonging - * to other processes (Cloudlets) between the RAM and the disk. - * Since the latter is way slower than the former, that will impose a processing - * delay for the requesting Cloudlets, which will take longer than expected to finish. - *

      - * - *

      - * Realize that VM storage depends on Host storage. This way, for this example, - * we have to create Hosts with a {@link HarddriveStorage} that has - * configured parameters such as {@link HarddriveStorage#getMaxTransferRate()}. - *

      - * - *

      For a Cloudlet, it will require more BW than there will be available. - * This way, the allocated BW will be reduced, causing more delay. - * When some BW cannot be allocated to the Cloudlet (due to over-subscription), - * the delay is computed based on the time needed to use - * the required bandwidth after the reduced allocation. - * For instance, if the required bandwidth is 10mbps, that means - * the cloudlet is willing to transfer 10 mbits in one second. - * If just 8 mbps is allocated to the cloudlet, - * to transfer the same 10 mbits it will take 0,25 second more. - *

      - * - * Check the following docs for specific implementation details you may be aware of: - *
        - *
      • {@link CloudletSchedulerAbstract#getVirtualMemoryDelay(CloudletExecution, double)}
      • - *
      • {@link CloudletSchedulerAbstract#getBandwidthOverSubscriptionDelay(CloudletExecution, double)}
      • - *
      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 6.3.0 - */ +/// An example showing how the processing of some Cloudlets is delayed +/// due to lack of available RAM and BW. +/// +/// The example creates VMs with different number of Cloudlets. +/// Those Cloudlets have different [UtilizationModel]s for RAM. +/// Some Cloudlets inside a given VM will require more RAM than the VM has available. +/// For instance, two Cloudlets inside a VM always require 60% of the VM capacity at the same time. +/// Since that total will be 120% of the RAM capacity, there is no way to fulfill the request +/// for one of those Cloudlets. +/// This way, one Cloudlet will use 60% of the VM RAM, while the other one will use only 40%. +/// The 20% of RAM the second Cloudlets is requiring has to rely on Virtual Memory. +/// In this scenario, CloudSim Plus will simulate the swap of memory data belonging +/// to other processes (Cloudlets) between the RAM and the disk. +/// Since the latter is way slower than the former, that will impose a processing +/// delay for the requesting Cloudlets, which will take longer than expected to finish. +/// +/// Realize that VM storage depends on Host storage. This way, for this example, +/// we have to create Hosts with a [HarddriveStorage] that has +/// configured parameters such as [HarddriveStorage#getMaxTransferRate()]. +/// +/// For a Cloudlet, it will require more BW than there will be available. +/// This way, the allocated BW will be reduced, causing more delay. +/// When some BW cannot be allocated to the Cloudlet (due to over-subscription), +/// the delay is computed based on the time needed to use +/// the required bandwidth after the reduced allocation. +/// For instance, if the required bandwidth is 10mbps, that means +/// the cloudlet is willing to transfer 10 mbits in one second. +/// If just 8 mbps is allocated to the cloudlet, +/// to transfer the same 10 mbits it will take 0,25 second more. +/// +/// Check the following docs for specific implementation details you may be aware of: +/// +/// - [CloudletSchedulerAbstract#getVirtualMemoryDelay(CloudletExecution,double)] +/// - [CloudletSchedulerAbstract#getBandwidthOverSubscriptionDelay(CloudletExecution,double)] +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 6.3.0 public class VirtualMemoryForRequestedRamHigherThanAvailableExample { - /** - * @see Datacenter#getSchedulingInterval() - */ + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 2; - /** - * The reading speed (in mbps) for Hosts {@link HarddriveStorage}, - * that impact processing delay when cloudlets use Virtual Memory. - * As slower is the reading speed, higher is the memory swapping overhead - * and the increase in cloudlet processing (exec) time. - */ + /// The reading speed (in mbps) for Hosts [HarddriveStorage], + /// that impact processing delay when cloudlets use Virtual Memory. + /// As slower is the reading speed, higher is the memory swapping overhead + /// and the increase in cloudlet processing (exec) time. private static final int HOSTS_MAX_TRANSFER_RATE = 1_600; private static final long HOST_RAM = 20_480; //in Megabytes @@ -118,9 +107,7 @@ public class VirtualMemoryForRequestedRamHigherThanAvailableExample { private static final int VMS = 3; private static final int VM_PES = 2; private static final int VM_MIPS = 1_000; - /** - * VM RAM capacity (in MB) - */ + /// VM RAM capacity (in MB) private static final int VM_RAM = 10_000; private static final int CLOUDLET_PES = 1; @@ -199,9 +186,7 @@ private void createCloudlets() { cloudletList.add(createCloudlet(vmList.get(2), new UtilizationModelFull())); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -215,12 +200,10 @@ private Datacenter createDatacenter() { return dc; } - /** - * Creates a Host with a {@link HarddriveStorage} configured - * to indicate delay in read operations, - * that impact the delay imposed for Cloudlets using Virtual Memory. - * @return - */ + /// Creates a Host with a [HarddriveStorage] configured + /// to indicate delay in read operations, + /// that impact the delay imposed for Cloudlets using Virtual Memory. + /// @return private Host createHost() { final var peList = new ArrayList(HOST_PES); //List of Host's CPUs (Processing Elements, PEs) @@ -241,9 +224,7 @@ private Host createHost() { return new HostSimple(HOST_RAM, bw, hardDrive, peList); } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var newVmList = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -256,12 +237,10 @@ private List createVms() { return newVmList; } - /** - * Creates a list of Cloudlets using the same {@link UtilizationModel} for RAM and BW. - * @param vm VM to run the Cloudlets - * @param cloudlets number of cloudlets to create - * @param utilizationModelRamBw {@link UtilizationModel} to be used for cloudlet RAM and BW. - */ + /// Creates a list of Cloudlets using the same [UtilizationModel] for RAM and BW. + /// @param vm VM to run the Cloudlets + /// @param cloudlets number of cloudlets to create + /// @param utilizationModelRamBw [UtilizationModel] to be used for cloudlet RAM and BW. private List createCloudlets(final Vm vm, final int cloudlets, final UtilizationModel utilizationModelRamBw) { //Creates a List with the same UtilizationModel BW for all cloudlets final var utilizationModelBwList = IntStream @@ -272,13 +251,11 @@ private List createCloudlets(final Vm vm, final int cloudlets, final U return createCloudlets(vm, utilizationModelRamBw, utilizationModelBwList); } - /** - * Creates one cloudlet for each BW {@link UtilizationModel} provided. - * @param vm - * @param utilizationModelRam - * @param utilizationModelBwList BW {@link UtilizationModel} list to be used for each created cloudlet - * @return - */ + /// Creates one cloudlet for each BW [UtilizationModel] provided. + /// @param vm + /// @param utilizationModelRam + /// @param utilizationModelBwList BW [UtilizationModel] list to be used for each created cloudlet + /// @return private List createCloudlets( final Vm vm, final UtilizationModel utilizationModelRam, diff --git a/src/main/java/org/cloudsimplus/examples/resourceusage/VmRelativeHostResourceUtilizationExample.java b/src/main/java/org/cloudsimplus/examples/resourceusage/VmRelativeHostResourceUtilizationExample.java index 5d0740d..8f14e70 100755 --- a/src/main/java/org/cloudsimplus/examples/resourceusage/VmRelativeHostResourceUtilizationExample.java +++ b/src/main/java/org/cloudsimplus/examples/resourceusage/VmRelativeHostResourceUtilizationExample.java @@ -45,17 +45,13 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing the relative percentage of each resource - * every VM is using from its Host. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.4.2 - */ +/// An example showing the relative percentage of each resource +/// every VM is using from its Host. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.4.2 public class VmRelativeHostResourceUtilizationExample { - /** - * @see Datacenter#getSchedulingInterval() - */ + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 2; private static final int HOSTS = 1; diff --git a/src/main/java/org/cloudsimplus/examples/resourceusage/VmsCpuUsageExample.java b/src/main/java/org/cloudsimplus/examples/resourceusage/VmsCpuUsageExample.java index 8f4fdaa..c5f2ba5 100755 --- a/src/main/java/org/cloudsimplus/examples/resourceusage/VmsCpuUsageExample.java +++ b/src/main/java/org/cloudsimplus/examples/resourceusage/VmsCpuUsageExample.java @@ -46,23 +46,19 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to create a Datacenter with two hosts and run - * two cloudlets on it. At the end, it shows the total CPU utilization of VMs - * into a Datacenter. - * - *

      - * Cloudlets run in VMs with different MIPS requirements and will - * take different times to complete the execution, depending on the requested VM - * performance. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - * - * @see VmsRamAndBwUsageExample - * @see org.cloudsimplus.examples.power.PowerExample - */ +/// An example showing how to create a Datacenter with two hosts and run +/// two cloudlets on it. At the end, it shows the total CPU utilization of VMs +/// into a Datacenter. +/// +/// Cloudlets run in VMs with different MIPS requirements and will +/// take different times to complete the execution, depending on the requested VM +/// performance. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 +/// +/// @see VmsRamAndBwUsageExample +/// @see org.cloudsimplus.examples.power.PowerExample public class VmsCpuUsageExample { private List cloudletList; private List vmlist; @@ -131,13 +127,11 @@ private Cloudlet createCloudlet(final int pesNumber) { return cloudlet; } - /** - * Creates a VM enabling the collection of CPU utilization history. - * @param pesNumber - * @param mips - * @param id - * @return - */ + /// Creates a VM enabling the collection of CPU utilization history. + /// @param pesNumber + /// @param mips + /// @param id + /// @return private Vm createVm(final int pesNumber, final int mips, final int id) { final long size = 10000; //image size (Megabyte) final int ram = 2048; //vm memory (Megabyte) @@ -160,14 +154,12 @@ private void printCpuUtilizationForAllVms() { } } - /** - * Creates a datacenter setting the scheduling interval - * that, between other things, defines the times to collect - * VM CPU utilization. - * - * @param simulation - * @return - */ + /// Creates a datacenter setting the scheduling interval + /// that, between other things, defines the times to collect + /// VM CPU utilization. + /// + /// @param simulation + /// @return private static Datacenter createDatacenter(CloudSimPlus simulation) { final var hostList = new ArrayList(HOSTS); final int pesNumber = 4; diff --git a/src/main/java/org/cloudsimplus/examples/resourceusage/VmsRamAndBwUsageExample.java b/src/main/java/org/cloudsimplus/examples/resourceusage/VmsRamAndBwUsageExample.java index 1a6f194..6d64119 100755 --- a/src/main/java/org/cloudsimplus/examples/resourceusage/VmsRamAndBwUsageExample.java +++ b/src/main/java/org/cloudsimplus/examples/resourceusage/VmsRamAndBwUsageExample.java @@ -47,30 +47,25 @@ import java.util.*; -/** - * Shows how to use the {@link Simulation#addOnClockTickListener(EventListener) onClockTick Listener} - * to keep track os simulation clock and store VM's RAM and BW utilization along the time. - * CloudSim Plus already has built-in features to obtain VM's CPU utilization. - * Check {@link org.cloudsimplus.examples.power.PowerExample}. - * - *

      The example uses the CloudSim Plus {@link EventListener} feature - * to enable monitoring the simulation and dynamically collect RAM and BW usage. - * It relies on - * Java 8 Method References - * to set a method to be called for {@link Simulation#addOnClockTickListener(EventListener) onClockTick events}. - * It enables getting notifications when the simulation clock advances, then creating and submitting new cloudlets. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.1.2 - * - * @see VmsCpuUsageExample - * @see org.cloudsimplus.examples.power.PowerExample - */ +/// Shows how to use the [onClockTick Listener][Simulation#addOnClockTickListener(EventListener)] +/// to keep track os simulation clock and store VM's RAM and BW utilization along the time. +/// CloudSim Plus already has built-in features to obtain VM's CPU utilization. +/// Check [org.cloudsimplus.examples.power.PowerExample]. +/// +/// The example uses the CloudSim Plus [EventListener] feature +/// to enable monitoring the simulation and dynamically collect RAM and BW usage. +/// It relies on +/// [Java 8 Method References](https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html) +/// to set a method to be called for [onClockTick events][Simulation#addOnClockTickListener(EventListener)]. +/// It enables getting notifications when the simulation clock advances, then creating and submitting new cloudlets. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.1.2 +/// +/// @see VmsCpuUsageExample +/// @see org.cloudsimplus.examples.power.PowerExample public class VmsRamAndBwUsageExample { - /** - * @see Datacenter#getSchedulingInterval() - */ + /// @see Datacenter#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 1; private static final int HOSTS = 4; @@ -89,18 +84,16 @@ public class VmsRamAndBwUsageExample { private final List cloudletList; private final Datacenter datacenter0; - /** - * A map to store RAM utilization history for every VM. - * Each key is a VM and each value is another map. - * This entire data structure is usually called a multimap. - * - *

      Such an internal map stores RAM utilization for a VM. - * The keys of this internal map are the time the utilization was collected (in seconds) - * and the value the utilization percentage (from 0 to 1).

      - */ + /// A map to store RAM utilization history for every VM. + /// Each key is a VM and each value is another map. + /// This entire data structure is usually called a multimap. + /// + /// Such an internal map stores RAM utilization for a VM. + /// The keys of this internal map are the time the utilization was collected (in seconds) + /// and the value the utilization percentage (from 0 to 1). private final Map> allVmsRamUtilizationHistory; - /** @see #allVmsRamUtilizationHistory */ + /// @see #allVmsRamUtilizationHistory private final Map> allVmsBwUtilizationHistory; public static void main(String[] args) { @@ -134,9 +127,7 @@ private VmsRamAndBwUsageExample() { printVmListResourceUtilizationHistory(); } - /** - * Prints the RAM and BW utilization history of every Vm. - */ + /// Prints the RAM and BW utilization history of every Vm. private void printVmListResourceUtilizationHistory() { System.out.println(); for (final var vm : vmList) { @@ -144,9 +135,7 @@ private void printVmListResourceUtilizationHistory() { } } - /** - * Prints the RAM and BW utilization history of a given Vm. - */ + /// Prints the RAM and BW utilization history of a given Vm. private void printVmUtilizationHistory(Vm vm) { System.out.println(vm + " RAM and BW utilization history"); System.out.println("----------------------------------------------------------------------------------"); @@ -169,14 +158,12 @@ private void printVmUtilizationHistory(Vm vm) { } - /** - * Initializes a map that will store utilization history for - * some resource (such as RAM or BW) of every VM. - * It also creates an empty internal map to store - * the resource utilization for every VM along the simulation execution. - * The internal map for every VM will be empty. - * They are filled inside the {@link #onClockTickListener(EventInfo)}. - */ + /// Initializes a map that will store utilization history for + /// some resource (such as RAM or BW) of every VM. + /// It also creates an empty internal map to store + /// the resource utilization for every VM along the simulation execution. + /// The internal map for every VM will be empty. + /// They are filled inside the [#onClockTickListener(EventInfo)]. private Map> initializeUtilizationHistory() { //TreeMap sorts entries based on the key final Map> map = new HashMap<>(VMS); @@ -188,28 +175,24 @@ private Map> initializeUtilizationHistory() { return map; } - /** - * Keeps track of simulation clock. - * Every time the clock changes, this method is called. - * To enable this method to be called at a defined - * interval, you need to set the {@link Datacenter#setSchedulingInterval(double) scheduling interval}. - * - * @param evt information about the clock tick event - * @see #SCHEDULING_INTERVAL - */ + /// Keeps track of simulation clock. + /// Every time the clock changes, this method is called. + /// To enable this method to be called at a defined + /// interval, you need to set the [scheduling interval][Datacenter#setSchedulingInterval(double)]. + /// + /// @param evt information about the clock tick event + /// @see #SCHEDULING_INTERVAL private void onClockTickListener(final EventInfo evt) { collectVmResourceUtilization(this.allVmsRamUtilizationHistory, Ram.class); collectVmResourceUtilization(this.allVmsBwUtilizationHistory, Bandwidth.class); } - /** - * Collects the utilization percentage of a given VM resource for every VM. - * CloudSim Plus already has built-in features to obtain VM's CPU utilization. - * Check {@link org.cloudsimplus.examples.power.PowerExample}. - * - * @param allVmsUtilizationHistory the map where the collected utilization for every VM will be stored - * @param resourceClass the kind of resource to collect its utilization (usually {@link Ram} or {@link Bandwidth}). - */ + /// Collects the utilization percentage of a given VM resource for every VM. + /// CloudSim Plus already has built-in features to obtain VM's CPU utilization. + /// Check [org.cloudsimplus.examples.power.PowerExample]. + /// + /// @param allVmsUtilizationHistory the map where the collected utilization for every VM will be stored + /// @param resourceClass the kind of resource to collect its utilization (usually [Ram] or [Bandwidth]). private void collectVmResourceUtilization(final Map> allVmsUtilizationHistory, Class resourceClass) { for (final var vm : vmList) { /*Gets the internal resource utilization map for the current VM. @@ -220,9 +203,7 @@ private void collectVmResourceUtilization(final Map> all } } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -250,9 +231,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var newVmList = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -267,9 +246,7 @@ private Vm createVm(final int pes) { .setCloudletScheduler(new CloudletSchedulerTimeShared()); } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var newCloudletList = new ArrayList(CLOUDLETS); for (int i = 0; i < CLOUDLETS; i++) { @@ -279,11 +256,9 @@ private List createCloudlets() { return newCloudletList; } - /** - * Creates a Cloudlet with specific {@link UtilizationModel} for RAM, BW and CPU. - * You can change the method to use any {@link UtilizationModel} you want. - * @return - */ + /// Creates a Cloudlet with specific [UtilizationModel] for RAM, BW and CPU. + /// You can change the method to use any [UtilizationModel] you want. + /// @return private Cloudlet createCloudlet() { final var ramUtilizationModel = new UtilizationModelDynamic(0.2); final var bwUtilizationModel = new UtilizationModelDynamic(0.1); @@ -299,11 +274,9 @@ private Cloudlet createCloudlet() { .setUtilizationModelBw(bwUtilizationModel); } - /** - * Defines how the Cloudlet's utilization of RAM and BW will increase along the simulation time. - * @return the updated utilization for RAM or BW - * @see #createCloudlet() - */ + /// Defines how the Cloudlet's utilization of RAM and BW will increase along the simulation time. + /// @return the updated utilization for RAM or BW + /// @see #createCloudlet() private double utilizationUpdate(UtilizationModelDynamic utilizationModel) { return utilizationModel.getUtilization() + utilizationModel.getTimeSpan() * 0.01; } diff --git a/src/main/java/org/cloudsimplus/examples/resourceusage/package-info.java b/src/main/java/org/cloudsimplus/examples/resourceusage/package-info.java index 98e068b..b5f88e2 100755 --- a/src/main/java/org/cloudsimplus/examples/resourceusage/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/resourceusage/package-info.java @@ -21,16 +21,14 @@ * You should have received a copy of the GNU General Public License * along with CloudSim Plus. If not, see . */ -/** - * Examples showing how to track resource usage for different elements - * such as Cloudlets, VMs and Hosts. - * Some examples also show how to use the - * {@link org.cloudsimplus.utilizationmodels.UtilizationModelDynamic} - * to dynamically define how a Cloudlet uses a specific resource - * without requiring to subclass a {@link org.cloudsimplus.utilizationmodels.UtilizationModel}. - * - * @author Manoel Campos da Silva Filho - */ +/// Examples showing how to track resource usage for different elements +/// such as Cloudlets, VMs and Hosts. +/// Some examples also show how to use the +/// [org.cloudsimplus.utilizationmodels.UtilizationModelDynamic] +/// to dynamically define how a Cloudlet uses a specific resource +/// without requiring to subclass a [org.cloudsimplus.utilizationmodels.UtilizationModel]. +/// +/// @author Manoel Campos da Silva Filho @NullMarked package org.cloudsimplus.examples.resourceusage; diff --git a/src/main/java/org/cloudsimplus/examples/schedulers/CloudletSchedulerSpaceSharedExample1.java b/src/main/java/org/cloudsimplus/examples/schedulers/CloudletSchedulerSpaceSharedExample1.java index 6a1f63a..7a7df40 100755 --- a/src/main/java/org/cloudsimplus/examples/schedulers/CloudletSchedulerSpaceSharedExample1.java +++ b/src/main/java/org/cloudsimplus/examples/schedulers/CloudletSchedulerSpaceSharedExample1.java @@ -47,19 +47,17 @@ import java.util.ArrayList; import java.util.List; -/** - * An example that runs 4 Cloudlets into a VM where its number - * of PEs is just half of the total PEs required by all Cloudlets. - * The Vm uses a {@link CloudletSchedulerSpaceShared}, which - * makes half of the Cloudlets to run first, while the other half - * waits their finalization. - * This way, the execution time of all cloudlets is the same, - * but the start time of the second half is equal to - * the finish time of the first half. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.2.1 - */ +/// An example that runs 4 Cloudlets into a VM where its number +/// of PEs is just half of the total PEs required by all Cloudlets. +/// The Vm uses a [CloudletSchedulerSpaceShared], which +/// makes half of the Cloudlets to run first, while the other half +/// waits their finalization. +/// This way, the execution time of all cloudlets is the same, +/// but the start time of the second half is equal to +/// the finish time of the first half. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.2.1 public class CloudletSchedulerSpaceSharedExample1 { private static final int HOSTS = 1; private static final int HOST_PES = 4; @@ -103,9 +101,7 @@ private CloudletSchedulerSpaceSharedExample1() { new CloudletsTableBuilder(cloudletFinishedListList).build(); } - /** - * Creates a Datacenter that uses a {@link VmAllocationPolicySimple} by default. - */ + /// Creates a Datacenter that uses a [VmAllocationPolicySimple] by default. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int h = 0; h < HOSTS; h++) { @@ -116,8 +112,8 @@ private Datacenter createDatacenter() { return new DatacenterSimple(simulation, hostList); } - /** Creates a Host that uses a {@link ResourceProvisionerSimple} by default - * for RAM and BW. */ + /// Creates a Host that uses a [ResourceProvisionerSimple] by default + /// for RAM and BW. private Host createHost() { final var peList = new ArrayList(HOST_PES); //List of Host's CPUs (Processing Elements, PEs) @@ -133,9 +129,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var vmList = new ArrayList(VMS); final int mips = 1000; @@ -151,9 +145,7 @@ private List createVms() { return vmList; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var cloudletList = new ArrayList(CLOUDLETS); final var utilizationModelFull = new UtilizationModelFull(); diff --git a/src/main/java/org/cloudsimplus/examples/schedulers/CloudletSchedulerTimeSharedExample1.java b/src/main/java/org/cloudsimplus/examples/schedulers/CloudletSchedulerTimeSharedExample1.java index 3a51bdb..fc2e3f6 100755 --- a/src/main/java/org/cloudsimplus/examples/schedulers/CloudletSchedulerTimeSharedExample1.java +++ b/src/main/java/org/cloudsimplus/examples/schedulers/CloudletSchedulerTimeSharedExample1.java @@ -45,21 +45,19 @@ import java.util.ArrayList; import java.util.List; -/** - * An example that runs 2 Cloudlets into a VM where its number - * of PEs is just half of the total PEs required by all Cloudlets. - * The Vm uses a {@link CloudletSchedulerTimeShared}. - * Since there are enough PEs for all Cloudlets, this scheduler - * shares existing PEs among all Cloudlets, so that there aren't - * waiting Cloudlets. - * They start at the same time and also considering they have the same length, - * they finish together too. - * However, each Cloudlet will take the double of the time - * it would take if there were enough PEs for all of them. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.2.1 - */ +/// An example that runs 2 Cloudlets into a VM where its number +/// of PEs is just half of the total PEs required by all Cloudlets. +/// The Vm uses a [CloudletSchedulerTimeShared]. +/// Since there are enough PEs for all Cloudlets, this scheduler +/// shares existing PEs among all Cloudlets, so that there aren't +/// waiting Cloudlets. +/// They start at the same time and also considering they have the same length, +/// they finish together too. +/// However, each Cloudlet will take the double of the time +/// it would take if there were enough PEs for all of them. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.2.1 public class CloudletSchedulerTimeSharedExample1 { private static final int HOSTS = 1; private static final int HOST_PES = 4; @@ -103,9 +101,7 @@ private CloudletSchedulerTimeSharedExample1() { new CloudletsTableBuilder(cloudletFinishedList).build(); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int h = 0; h < HOSTS; h++) { @@ -132,9 +128,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var newVmList = new ArrayList(VMS); for (int v = 0; v < VMS; v++) { @@ -149,9 +143,7 @@ private List createVms() { return newVmList; } - /** - * Creates a list of Cloudlets. - */ + /// Creates a list of Cloudlets. private List createCloudlets() { final var newCloudletList = new ArrayList(CLOUDLETS); for (int c = 0; c < CLOUDLETS; c++) { diff --git a/src/main/java/org/cloudsimplus/examples/schedulers/LinuxCompletelyFairSchedulerExample.java b/src/main/java/org/cloudsimplus/examples/schedulers/LinuxCompletelyFairSchedulerExample.java index 3a145b8..73d7cd1 100755 --- a/src/main/java/org/cloudsimplus/examples/schedulers/LinuxCompletelyFairSchedulerExample.java +++ b/src/main/java/org/cloudsimplus/examples/schedulers/LinuxCompletelyFairSchedulerExample.java @@ -46,20 +46,17 @@ import java.util.ArrayList; import java.util.List; -/** - * An example that uses an implementation of the {@link CloudletSchedulerCompletelyFair Completely Fair Scheduler} - * used in the Linux Kernel for scheduling of Cloudlets execution inside a Vm. - * It defines priority for some Cloudlets, so that they will have more time to use the CPU - * than other Cloudlets. - * - *

      It is strongly recommended to read the {@link CloudletSchedulerCompletelyFair} class documentation - * to understand how this scheduler works.

      - * - * @author Manoel Campos da Silva Filho - * @see Completely Fair Scheduler (CFS) - * @since CloudSim Plus 1.0 - * - */ +/// An example that uses an implementation of the [Completely Fair Scheduler][CloudletSchedulerCompletelyFair] +/// used in the Linux Kernel for scheduling of Cloudlets execution inside a Vm. +/// It defines priority for some Cloudlets, so that they will have more time to use the CPU +/// than other Cloudlets. +/// +/// It is strongly recommended to read the [CloudletSchedulerCompletelyFair] class documentation +/// to understand how this scheduler works. +/// +/// @author Manoel Campos da Silva Filho +/// @see Completely Fair Scheduler (CFS) +/// @since CloudSim Plus 1.0 public class LinuxCompletelyFairSchedulerExample { private static final int HOSTS_NUMBER = 1; private static final long HOST_MIPS = 1000; @@ -82,9 +79,7 @@ public static void main(String[] args) { new LinuxCompletelyFairSchedulerExample(); } - /** - * Default constructor which builds and runs the simulation. - */ + /// Default constructor which builds and runs the simulation. private LinuxCompletelyFairSchedulerExample() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ diff --git a/src/main/java/org/cloudsimplus/examples/schedulers/SharingHostPEsUsingVmSchedulerSpaceSharedExample.java b/src/main/java/org/cloudsimplus/examples/schedulers/SharingHostPEsUsingVmSchedulerSpaceSharedExample.java index 6f46af4..16c32f5 100755 --- a/src/main/java/org/cloudsimplus/examples/schedulers/SharingHostPEsUsingVmSchedulerSpaceSharedExample.java +++ b/src/main/java/org/cloudsimplus/examples/schedulers/SharingHostPEsUsingVmSchedulerSpaceSharedExample.java @@ -44,57 +44,40 @@ import java.util.ArrayList; import java.util.List; -/** - * An example that execute exactly as the - * {@link SharingHostPEsUsingVmSchedulerTimeSharedExample}, - * however the host uses an {@link VmSchedulerSpaceShared}, - * showing how half of the VMs will fail to be placed due to - * lack of available Host PEs. - * - * Considering this scenario where we have 1 hosts with 2 PEs - * and 4 VMs each one requesting these 2 PEs. - * This CloudSim paper below states in the section 3.2 that when using a - * VmSchedulerSpaceShared, one VM will execute first and after it finishes, - * the other one will start executing. - * However, the DatacenterBroker fails in allocating a host for 2 VMs - * due to lack of available PEs. - * Once each one of the 2 host PEs has a capacity of 1000 MIPS, even defining - * that each one of the 4 VMs requires just 500 MIPS, the allocation - * of 2 VMs fails. - * - * - * - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - */ +/// An example that execute exactly as the +/// [SharingHostPEsUsingVmSchedulerTimeSharedExample], +/// however the host uses an [VmSchedulerSpaceShared], +/// showing how half of the VMs will fail to be placed due to +/// lack of available Host PEs. +/// +/// Considering this scenario where we have 1 hosts with 2 PEs +/// and 4 VMs each one requesting these 2 PEs. +/// This CloudSim paper below states in the section 3.2 that when using a +/// VmSchedulerSpaceShared, one VM will execute first and after it finishes, +/// the other one will start executing. +/// However, the DatacenterBroker fails in allocating a host for 2 VMs +/// due to lack of available PEs. +/// Once each one of the 2 host PEs has a capacity of 1000 MIPS, even defining +/// that each one of the 4 VMs requires just 500 MIPS, the allocation +/// of 2 VMs fails. +/// +/// - [R. N. Calheiros, R. Ranjan, C. A. F. De Rose, and R. Buyya, “CloudSim: A Novel Framework for Modeling and Simulation of Cloud Computing Infrastructures and Services,” arXiv preprint arXiv:0903.2525. arXiv, p. 9, 2009](http://arxiv.org/abs/0903.2525). +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 public class SharingHostPEsUsingVmSchedulerSpaceSharedExample { - /** - * Capacity of each CPU core (in Million Instructions per Second). - */ + /// Capacity of each CPU core (in Million Instructions per Second). private static final long HOST_MIPS = 1000; - /** - * Number of processor elements (CPU cores) of each host. - */ + /// Number of processor elements (CPU cores) of each host. private static final int HOST_PES_NUM = 2; - /** - * The total MIPS capacity across all the Host PEs. - */ + /// The total MIPS capacity across all the Host PEs. private static final long HOST_TOTAL_MIPS_CAPACITY = HOST_MIPS*HOST_PES_NUM; - /** - * The length of each created cloudlet in Million Instructions (MI). - */ + /// The length of each created cloudlet in Million Instructions (MI). private static final long CLOUDLET_LENGTH = 10000; - /** - * Number of VMs to create. - */ + /// Number of VMs to create. private static final int NUMBER_OF_VMS = HOST_PES_NUM*2; private static final long VM_MIPS = HOST_TOTAL_MIPS_CAPACITY/NUMBER_OF_VMS; @@ -111,9 +94,7 @@ public static void main(String[] args) { new SharingHostPEsUsingVmSchedulerSpaceSharedExample(); } - /** - * Default constructor where the simulation is built. - */ + /// Default constructor where the simulation is built. private SharingHostPEsUsingVmSchedulerSpaceSharedExample() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ diff --git a/src/main/java/org/cloudsimplus/examples/schedulers/SharingHostPEsUsingVmSchedulerTimeSharedExample.java b/src/main/java/org/cloudsimplus/examples/schedulers/SharingHostPEsUsingVmSchedulerTimeSharedExample.java index 9c523f2..741be1f 100755 --- a/src/main/java/org/cloudsimplus/examples/schedulers/SharingHostPEsUsingVmSchedulerTimeSharedExample.java +++ b/src/main/java/org/cloudsimplus/examples/schedulers/SharingHostPEsUsingVmSchedulerTimeSharedExample.java @@ -43,48 +43,36 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to create 1 host and place multiple VMs at the same - * {@link Pe Processor Element (CPU core)} of it, - * using a VmSchedulerTimeShared policy at the Host. - * - *

      The number of VMs to be created will be the double of the Host PEs number. - * For each Host PE, two VMs requiring half the MIPS capacity of the PE will be - * created. Each VM will have just one cloudlet that will use - * all VM PEs and MIPS capacity.

      - * - *

      Thus, considering that each cloudlet has a length of 10000 MI and - * each VM has a PE of 1000 MIPS, the cloudlet will spend 10 seconds to finish. - * However, as each Host PE will be shared between two VMs using a time shared - * scheduler, the cloudlet will spend the double of the time to finish, - * as can be seen in the simulation results after running the example.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - */ +/// An example showing how to create 1 host and place multiple VMs at the same +/// [Processor Element (CPU core)][Pe] of it, +/// using a VmSchedulerTimeShared policy at the Host. +/// +/// The number of VMs to be created will be the double of the Host PEs number. +/// For each Host PE, two VMs requiring half the MIPS capacity of the PE will be +/// created. Each VM will have just one cloudlet that will use +/// all VM PEs and MIPS capacity. +/// +/// Thus, considering that each cloudlet has a length of 10000 MI and +/// each VM has a PE of 1000 MIPS, the cloudlet will spend 10 seconds to finish. +/// However, as each Host PE will be shared between two VMs using a time shared +/// scheduler, the cloudlet will spend the double of the time to finish, +/// as can be seen in the simulation results after running the example. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 public class SharingHostPEsUsingVmSchedulerTimeSharedExample { - /** - * Capacity of each CPU core (in Million Instructions per Second). - */ + /// Capacity of each CPU core (in Million Instructions per Second). private static final long HOST_MIPS = 1000; - /** - * Number of processor elements (CPU cores) of each host. - */ + /// Number of processor elements (CPU cores) of each host. private static final int HOST_PES_NUM = 2; - /** - * The total MIPS capacity across all the Host PEs. - */ + /// The total MIPS capacity across all the Host PEs. private static final long HOST_TOTAL_MIPS_CAPACITY = HOST_MIPS*HOST_PES_NUM; - /** - * The length of each created cloudlet in Million Instructions (MI). - */ + /// The length of each created cloudlet in Million Instructions (MI). private static final long CLOUDLET_LENGTH = 10000; - /** - * Number of VMs to create. - */ + /// Number of VMs to create. private static final int NUMBER_OF_VMS = HOST_PES_NUM*2; private static final long VM_MIPS = HOST_TOTAL_MIPS_CAPACITY/NUMBER_OF_VMS; @@ -100,9 +88,7 @@ public static void main(String[] args) { new SharingHostPEsUsingVmSchedulerTimeSharedExample(); } - /** - * Default constructor where the simulation is built. - */ + /// Default constructor where the simulation is built. private SharingHostPEsUsingVmSchedulerTimeSharedExample() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ diff --git a/src/main/java/org/cloudsimplus/examples/schedulers/TwoCloudletsAndOneSpaceSharedVmExample.java b/src/main/java/org/cloudsimplus/examples/schedulers/TwoCloudletsAndOneSpaceSharedVmExample.java index eb90484..08c8b04 100755 --- a/src/main/java/org/cloudsimplus/examples/schedulers/TwoCloudletsAndOneSpaceSharedVmExample.java +++ b/src/main/java/org/cloudsimplus/examples/schedulers/TwoCloudletsAndOneSpaceSharedVmExample.java @@ -43,29 +43,25 @@ import java.util.ArrayList; import java.util.List; -/** - * A simple example showing how to create a data center with 1 host, 1 VM and - * run 2 cloudlets on it that will run sequentially: first one cloudlet executes - * until complete, after the other one do the same. Once there is only one - * cloudlet running on the VM by time, each one uses all VM's CPU capacity while - * executing. By this way, one cloudlet finishes prior to the other, but the - * execution time (the time using the processor) is the same. Using the cloudlet - * space shared scheduler, the cloudlet is not interrupted when it starts to run - * (because the non-preemptive nature of the scheduler). - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - */ +/// A simple example showing how to create a data center with 1 host, 1 VM and +/// run 2 cloudlets on it that will run sequentially: first one cloudlet executes +/// until complete, after the other one do the same. Once there is only one +/// cloudlet running on the VM by time, each one uses all VM's CPU capacity while +/// executing. By this way, one cloudlet finishes prior to the other, but the +/// execution time (the time using the processor) is the same. Using the cloudlet +/// space shared scheduler, the cloudlet is not interrupted when it starts to run +/// (because the non-preemptive nature of the scheduler). +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 public class TwoCloudletsAndOneSpaceSharedVmExample { private List cloudletList; private List vmlist; private CloudSimPlus simulation; - /** - * Creates main() to run this example. - * - * @param args the args - */ + /// Creates main() to run this example. + /// + /// @param args the args public static void main(String[] args) { new TwoCloudletsAndOneSpaceSharedVmExample(); } @@ -137,11 +133,9 @@ private TwoCloudletsAndOneSpaceSharedVmExample(){ new CloudletsTableBuilder(cloudletFinishedList).build(); System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * Creates the Datacenter. - * - * @return the Datacenter - */ + /// Creates the Datacenter. + /// + /// @return the Datacenter private Datacenter createDatacenter() { final var hostList = new ArrayList(); final var peList = new ArrayList(); diff --git a/src/main/java/org/cloudsimplus/examples/schedulers/TwoCloudletsAndOneTimeSharedVmExample.java b/src/main/java/org/cloudsimplus/examples/schedulers/TwoCloudletsAndOneTimeSharedVmExample.java index 25fba7b..ffca9c1 100755 --- a/src/main/java/org/cloudsimplus/examples/schedulers/TwoCloudletsAndOneTimeSharedVmExample.java +++ b/src/main/java/org/cloudsimplus/examples/schedulers/TwoCloudletsAndOneTimeSharedVmExample.java @@ -45,29 +45,25 @@ import java.util.ArrayList; import java.util.List; -/** - * A simple example showing how to create a data center with 1 host, 1 vm and - * run 2 cloudlets on it that will compete for the VM's CPU. - * The VM's CPU is shared among the cloudlets using a time-shared scheduler, - * that performs a preemptive scheduling. By this way, all the 2 cloudlets - * will have a quantum to use the VM's CPU. As they have the same length, - * they start and finish together. Thus, the execution time is the double - * compared to running each cloudlet in its own VM or using a space shared - * scheduler. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - */ +/// A simple example showing how to create a data center with 1 host, 1 vm and +/// run 2 cloudlets on it that will compete for the VM's CPU. +/// The VM's CPU is shared among the cloudlets using a time-shared scheduler, +/// that performs a preemptive scheduling. By this way, all the 2 cloudlets +/// will have a quantum to use the VM's CPU. As they have the same length, +/// they start and finish together. Thus, the execution time is the double +/// compared to running each cloudlet in its own VM or using a space shared +/// scheduler. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 public class TwoCloudletsAndOneTimeSharedVmExample { private List cloudletList; private List vmlist; private CloudSimPlus simulation; - /** - * Creates main() to run this example. - * - * @param args the args - */ + /// Creates main() to run this example. + /// + /// @param args the args public static void main(String[] args) { new TwoCloudletsAndOneTimeSharedVmExample(); } @@ -142,11 +138,9 @@ private TwoCloudletsAndOneTimeSharedVmExample(){ System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * Creates the Datacenter. - * - * @return the Datacenter - */ + /// Creates the Datacenter. + /// + /// @return the Datacenter private Datacenter createDatacenter() { final var hostList = new ArrayList(); final var peList = new ArrayList(); diff --git a/src/main/java/org/cloudsimplus/examples/schedulers/VmSchedulerTimeSharedExample.java b/src/main/java/org/cloudsimplus/examples/schedulers/VmSchedulerTimeSharedExample.java index 94c8965..a162c8d 100755 --- a/src/main/java/org/cloudsimplus/examples/schedulers/VmSchedulerTimeSharedExample.java +++ b/src/main/java/org/cloudsimplus/examples/schedulers/VmSchedulerTimeSharedExample.java @@ -45,35 +45,32 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing the usage of the {@link VmSchedulerTimeShared} - * which allows multiple VMs to use the same PEs from a Host, - * provided those PEs have available MIPS capacity. - * - *

      In this example we have 2 Hosts with 2 PEs each one. - * Each PE having a capacity of 1000 MIPS (2000 MIPS by Host), - * totaling 4 PEs for those 2 Hosts (4000 MIPS at total). - * Then we create 8 VMs, each one requiring a single PE. - * That would require a total of 8 PEs from existing PMs, - * which there aren't available. - *

      - * - *

      Each VM requires just 500 MIPS and the MIPS required by all 8 VMs - * totals 4000 MIPS, which is the total capacity of the existing Hosts. - * Since we are using a {@link VmSchedulerTimeShared}, such an allocation is possible - * by sharing Hosts's PEs between running VMs. Each VM will use half of the MIPS capacity - * of the Host's PEs. Since the entire MIPS capacity required by each VM will - * be allocated to them, there is no performance degradation. - * Every Cloudlet will finish in 10 seconds, as if they weren't sharing any PE.

      - * - *

      Using a {@link VmSchedulerSpaceShared}, the allocation of some - * VMs will just fail due to lack of PEs. - * For the current scenario with {@link VmSchedulerTimeShared}, some VMs will fail due to lack - * of MIPS capacity only if we increase the number of VMs.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 5.1.4 - */ +/// An example showing the usage of the [VmSchedulerTimeShared] +/// which allows multiple VMs to use the same PEs from a Host, +/// provided those PEs have available MIPS capacity. +/// +/// In this example we have 2 Hosts with 2 PEs each one. +/// Each PE having a capacity of 1000 MIPS (2000 MIPS by Host), +/// **totaling 4 PEs for those 2 Hosts (4000 MIPS at total)**. +/// Then we create 8 VMs, each one requiring a single PE. +/// **That would require a total of 8 PEs from existing PMs**, +/// which there aren't available. +/// +/// Each VM requires just 500 MIPS and the MIPS required by all 8 VMs +/// totals 4000 MIPS, which is the total capacity of the existing Hosts. +/// Since we are using a [VmSchedulerTimeShared], such an allocation is possible +/// by sharing Hosts's PEs between running VMs. Each VM will use half of the MIPS capacity +/// of the Host's PEs. Since the entire MIPS capacity required by each VM will +/// be allocated to them, there is no performance degradation. +/// Every Cloudlet will finish in 10 seconds, as if they weren't sharing any PE. +/// +/// Using a [VmSchedulerSpaceShared], the allocation of some +/// VMs will just fail due to lack of PEs. +/// For the current scenario with [VmSchedulerTimeShared], some VMs will fail due to lack +/// of MIPS capacity only if we increase the number of VMs. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 5.1.4 public class VmSchedulerTimeSharedExample { private static final int HOSTS = 2; private static final int VMS = 8; @@ -143,13 +140,11 @@ private VmSchedulerTimeSharedExample() { } } - /** - * Prints the {@link Host#getStateHistory() state history} for a given Host. - * Realize that the state history is just collected if that is enabled before - * starting the simulation by calling {@link Host#setStateHistoryEnabled(boolean)}. - * - * @param host - */ + /// Prints the [state history][Host#getStateHistory()] for a given Host. + /// Realize that the state history is just collected if that is enabled before + /// starting the simulation by calling [Host#setStateHistoryEnabled(boolean)]. + /// + /// @param host private void printHostStateHistory(Host host) { System.out.printf("Host: %d%n", host.getId()); System.out.println("-----------------------------------------------------------------------------------------------------"); @@ -173,9 +168,7 @@ private double getVmAllocatedMips(Cloudlet c) { return c.getVm().getStateHistory().get(c.getVm().getStateHistory().size()-1).getAllocatedMips(); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private void createDatacenter() { for(int h = 0; h < HOSTS; h++) { final var host = createHost(); @@ -199,9 +192,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs for the {@link #broker0}. - */ + /// Creates a list of VMs for the [#broker0]. private void createVms() { for (int i = 0; i < VMS; i++) { final var vm = @@ -211,9 +202,7 @@ private void createVms() { } } - /** - * Creates one Cloudlet for each VM belonging to {@link #broker0}. - */ + /// Creates one Cloudlet for each VM belonging to [#broker0]. private void createCloudlets() { for (final var vm : vmList) { final var cloudlet = new CloudletSimple(CLOUDLET_LENGTH, CLOUDLET_PES); diff --git a/src/main/java/org/cloudsimplus/examples/schedulers/package-info.java b/src/main/java/org/cloudsimplus/examples/schedulers/package-info.java index bd7d0dc..93fc9de 100755 --- a/src/main/java/org/cloudsimplus/examples/schedulers/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/schedulers/package-info.java @@ -21,15 +21,13 @@ * You should have received a copy of the GNU General Public License * along with CloudSim Plus. If not, see . */ -/** - * Examples showing how to use {@link org.cloudsimplus.schedulers.cloudlet.CloudletScheduler} - * and {@link org.cloudsimplus.schedulers.vm.VmScheduler} in different infrastructure setups. - * Some examples show how to use - * {@link org.cloudsimplus.schedulers.cloudlet.CloudletSchedulerCompletelyFair} - * that implements a real scheduler used by recent Linux Kernels. - * - * @author Manoel Campos da Silva Filho - */ +/// Examples showing how to use [org.cloudsimplus.schedulers.cloudlet.CloudletScheduler] +/// and [org.cloudsimplus.schedulers.vm.VmScheduler] in different infrastructure setups. +/// Some examples show how to use +/// [org.cloudsimplus.schedulers.cloudlet.CloudletSchedulerCompletelyFair] +/// that implements a real scheduler used by recent Linux Kernels. +/// +/// @author Manoel Campos da Silva Filho @NullMarked package org.cloudsimplus.examples.schedulers; diff --git a/src/main/java/org/cloudsimplus/examples/simulationstatus/PauseSimulationAtGivenTimeExample1.java b/src/main/java/org/cloudsimplus/examples/simulationstatus/PauseSimulationAtGivenTimeExample1.java index 2ce5e54..d51dcdf 100755 --- a/src/main/java/org/cloudsimplus/examples/simulationstatus/PauseSimulationAtGivenTimeExample1.java +++ b/src/main/java/org/cloudsimplus/examples/simulationstatus/PauseSimulationAtGivenTimeExample1.java @@ -45,48 +45,44 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to pause the simulation at a given time in order to collect - * some partial results. In this example, such results are the cloudlets that have finished so far. - * The example creates 4 Cloudlets that will run sequentially using a {@link CloudletSchedulerSpaceShared}. - * - *

      The pause is scheduled before the simulation starts, which is the easiest way to perform - * such an action.

      - * - *

      This example uses CloudSim Plus Listener features to intercept when - * the simulation was paused, allowing to collect the desired data. - * This example uses the Java 8+ Lambda Functions features - * to pass a listener to a {@link CloudSimPlus} instance, by means of the - * {@link CloudSimPlus#addOnSimulationPauseListener(EventListener)} method. - * However, the same feature can be used for Java 7 passing an anonymous class - * that implements {@code EventListener}.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - * - * @see CloudSimPlus#pause(double) - * @see CloudSimPlus#addOnSimulationPauseListener(EventListener) - * @see EventListener - */ +/// An example showing how to pause the simulation at a given time in order to collect +/// some partial results. In this example, such results are the cloudlets that have finished so far. +/// The example creates 4 Cloudlets that will run sequentially using a [CloudletSchedulerSpaceShared]. +/// +/// The pause is scheduled before the simulation starts, which is the **easiest way** to perform +/// such an action. +/// +/// This example uses CloudSim Plus Listener features to intercept when +/// the simulation was paused, allowing to collect the desired data. +/// This example uses the Java 8+ Lambda Functions features +/// to pass a listener to a [CloudSimPlus] instance, by means of the +/// [CloudSimPlus#addOnSimulationPauseListener(EventListener)] method. +/// However, the same feature can be used for Java 7 passing an anonymous class +/// that implements `EventListener`. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 +/// +/// @see CloudSimPlus#pause(double) +/// @see CloudSimPlus#addOnSimulationPauseListener(EventListener) +/// @see EventListener public class PauseSimulationAtGivenTimeExample1 { - /** - * The interval in which the Datacenter will schedule events. - * As lower is this interval, sooner the processing of VMs and Cloudlets - * is updated and you will get more notifications about the simulation execution. - * However, it can affect the simulation performance. - * - *

      For this example, a large schedule interval such as 15 will make that just - * at every 15 seconds the processing of Cloudlets is updated. - * Consider that each Cloudlet takes 10 seconds to finish and that - * the simulation is paused at time 22. With a scheduling interval of 15 seconds, - * at the time 22, the Cloudlets execution will be updated just 1 time, that means - * if we get the list of finished cloudlets at time 22, it will not be updated yet with - * the second Cloudlet that finished at time 20.

      - * - *

      Considering this characteristics, the scheduling interval - * was set to a lower value to get updates as soon as possible. - * For more details, see {@link Datacenter#getSchedulingInterval()}.

      - */ + /// The interval in which the Datacenter will schedule events. + /// As lower is this interval, sooner the processing of VMs and Cloudlets + /// is updated and you will get more notifications about the simulation execution. + /// However, it can affect the simulation performance. + /// + /// For this example, a large schedule interval such as 15 will make that just + /// at every 15 seconds the processing of Cloudlets is updated. + /// Consider that each Cloudlet takes 10 seconds to finish and that + /// the simulation is paused at time 22. With a scheduling interval of 15 seconds, + /// at the time 22, the Cloudlets execution will be updated just 1 time, that means + /// if we get the list of finished cloudlets at time 22, it will not be updated yet with + /// the second Cloudlet that finished at time 20. + /// + /// Considering this characteristics, the scheduling interval + /// was set to a lower value to get updates as soon as possible. + /// For more details, see [Datacenter#getSchedulingInterval()]. public static final int SCHEDULING_INTERVAL = 1; private final CloudSimPlus simulation; @@ -98,9 +94,7 @@ public static void main(String[] args) { new PauseSimulationAtGivenTimeExample1(); } - /** - * Default constructor that builds the simulation. - */ + /// Default constructor that builds the simulation. private PauseSimulationAtGivenTimeExample1() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ diff --git a/src/main/java/org/cloudsimplus/examples/simulationstatus/PauseSimulationAtGivenTimeExample2.java b/src/main/java/org/cloudsimplus/examples/simulationstatus/PauseSimulationAtGivenTimeExample2.java index 8a5dc5f..6de2d0a 100755 --- a/src/main/java/org/cloudsimplus/examples/simulationstatus/PauseSimulationAtGivenTimeExample2.java +++ b/src/main/java/org/cloudsimplus/examples/simulationstatus/PauseSimulationAtGivenTimeExample2.java @@ -47,54 +47,50 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to pause the simulation at a given time in order to collect - * some partial results. In this example, such results are the cloudlets that have finished so far. - * The example creates 4 Cloudlets that will run sequentially using a {@link CloudletSchedulerSpaceShared}. - * - *

      The pause is scheduled after the simulation starts, by adding an - * {@link Simulation#addOnEventProcessingListener(EventListener) OnEventProcessingListener} - * that will be notified every time a simulation event is processed.

      - * - *

      This example uses CloudSim Plus Listener features to intercept when - * the simulation was paused, allowing to collect the desired data. - * This example uses the Java 8+ Lambda Functions features - * to pass a listener to a {@link CloudSimPlus} instance, by means of the - * {@link CloudSimPlus#addOnSimulationPauseListener(EventListener)} method. - * However, the same feature can be used for Java 7 passing an anonymous class - * that implements {@code EventListener}.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - * - * @see CloudSimPlus#pause(double) - * @see CloudSimPlus#addOnSimulationPauseListener(EventListener) - * @see EventListener - */ +/// An example showing how to pause the simulation at a given time in order to collect +/// some partial results. In this example, such results are the cloudlets that have finished so far. +/// The example creates 4 Cloudlets that will run sequentially using a [CloudletSchedulerSpaceShared]. +/// +/// The pause is scheduled after the simulation starts, by adding an +/// [OnEventProcessingListener][Simulation#addOnEventProcessingListener(EventListener)] +/// that will be notified every time a simulation event is processed. +/// +/// This example uses CloudSim Plus Listener features to intercept when +/// the simulation was paused, allowing to collect the desired data. +/// This example uses the Java 8+ Lambda Functions features +/// to pass a listener to a [CloudSimPlus] instance, by means of the +/// [CloudSimPlus#addOnSimulationPauseListener(EventListener)] method. +/// However, the same feature can be used for Java 7 passing an anonymous class +/// that implements `EventListener`. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 +/// +/// @see CloudSimPlus#pause(double) +/// @see CloudSimPlus#addOnSimulationPauseListener(EventListener) +/// @see EventListener public class PauseSimulationAtGivenTimeExample2 { - /** - * The interval in which the Datacenter will schedule events. - * As lower is this interval, sooner the processing of Cloudlets inside VMs - * is updated and you will get more notifications about the simulation execution. - * However, it can affect the simulation performance. - * - *

      For this example, a large schedule interval such as 15 will make that just - * at every 15 seconds the processing of Cloudlets is updated. - * Consider that each Cloudlet takes 10 seconds to finish and that - * the simulation is paused at time 22. With a scheduling interval of 15 seconds, - * at the time 22, the Cloudlets execution will be updated just 1 time, that means - * if we get the list of finished cloudlets at time 22, it will not be updated yet with - * the second Cloudlet that finished at time 20.

      - * - *

      Realise that changing this value, the method {@link #pauseSimulationAtSpecificTime(SimEvent)} - * may not be called at the expected time, doesn't making the simulation to pause. - * If you want to change this value, the number used inside the method mentioned above - * has to be a multiple of this value.

      - * - *

      Considering this characteristics, the scheduling interval - * was set to a lower value to get updates as soon as possible. - * For more details, see {@link Datacenter#getSchedulingInterval()}.

      - */ + /// The interval in which the Datacenter will schedule events. + /// As lower is this interval, sooner the processing of Cloudlets inside VMs + /// is updated and you will get more notifications about the simulation execution. + /// However, it can affect the simulation performance. + /// + /// For this example, a large schedule interval such as 15 will make that just + /// at every 15 seconds the processing of Cloudlets is updated. + /// Consider that each Cloudlet takes 10 seconds to finish and that + /// the simulation is paused at time 22. With a scheduling interval of 15 seconds, + /// at the time 22, the Cloudlets execution will be updated just 1 time, that means + /// if we get the list of finished cloudlets at time 22, it will not be updated yet with + /// the second Cloudlet that finished at time 20. + /// + /// **Realise that changing this value, the method [#pauseSimulationAtSpecificTime(SimEvent)] + /// may not be called at the expected time, doesn't making the simulation to pause. + /// If you want to change this value, the number used inside the method mentioned above + /// has to be a multiple of this value.** + /// + /// Considering this characteristics, the scheduling interval + /// was set to a lower value to get updates as soon as possible. + /// For more details, see [Datacenter#getSchedulingInterval()]. public static final int SCHEDULING_INTERVAL = 1; private final CloudSimPlus simulation; @@ -106,9 +102,7 @@ public static void main(String[] args) { new PauseSimulationAtGivenTimeExample2(); } - /** - * Default constructor that builds the simulation. - */ + /// Default constructor that builds the simulation. private PauseSimulationAtGivenTimeExample2() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -139,13 +133,11 @@ on behalf of a given cloud user (customer). this.broker.submitCloudletList(cloudletList); - /** - * Sets a Listener that will be notified when any {@link SimEvent} is processed during the simulation - * execution. - * Realise that it is being used Java 8 Lambda Expressions to define a Listener - * that will be executed only when a simulation event happens. - * See the {@link #pauseSimulationAtSpecificTime(SimEvent)} method for more details. - */ + /// Sets a Listener that will be notified when any [SimEvent] is processed during the simulation + /// execution. + /// Realise that it is being used Java 8 Lambda Expressions to define a Listener + /// that will be executed only when a simulation event happens. + /// See the [#pauseSimulationAtSpecificTime(SimEvent)] method for more details. this.simulation.addOnEventProcessingListener(this::pauseSimulationAtSpecificTime); /* @@ -166,9 +158,7 @@ on behalf of a given cloud user (customer). System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * Pauses the simulation when any event occurs at the a defined time. - */ + /// Pauses the simulation when any event occurs at the a defined time. private void pauseSimulationAtSpecificTime(SimEvent simEvent) { if(Math.floor(simEvent.getTime()) == 22){ simulation.pause(); diff --git a/src/main/java/org/cloudsimplus/examples/simulationstatus/TerminateSimulationAtGivenConditionExample.java b/src/main/java/org/cloudsimplus/examples/simulationstatus/TerminateSimulationAtGivenConditionExample.java index 8ac2dcd..9947b3b 100755 --- a/src/main/java/org/cloudsimplus/examples/simulationstatus/TerminateSimulationAtGivenConditionExample.java +++ b/src/main/java/org/cloudsimplus/examples/simulationstatus/TerminateSimulationAtGivenConditionExample.java @@ -46,27 +46,25 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to terminate the simulation when a condition is met, before its natural end. - * The example creates 4 Cloudlets that will run sequentially using a {@link CloudletSchedulerSpaceShared}. - * However, when the last Cloudlet reaches 50% of its execution, - * the simulation will be interrupted. By this way, just 3 Cloudlets will finish. - * - *

      This example uses CloudSim Plus Listener features to intercept when - * the second Cloudlet reaches 50% of its execution to then request - * the simulation termination. This example uses the Java 8+ Lambda Functions features - * to pass a listener to the mentioned Cloudlet, by means of the - * {@link Cloudlet#addOnUpdateProcessingListener(EventListener)} method. - * However, the same feature can be used for Java 7 passing an anonymous class - * that implements {@code EventListener}.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - * - * @see CloudSimPlus#terminate() - * @see Cloudlet#addOnUpdateProcessingListener(EventListener) - * @see EventListener - */ +/// An example showing how to terminate the simulation when a condition is met, before its natural end. +/// The example creates 4 Cloudlets that will run sequentially using a [CloudletSchedulerSpaceShared]. +/// However, when the last Cloudlet reaches 50% of its execution, +/// the simulation will be interrupted. By this way, just 3 Cloudlets will finish. +/// +/// This example uses CloudSim Plus Listener features to intercept when +/// the second Cloudlet reaches 50% of its execution to then request +/// the simulation termination. This example uses the Java 8+ Lambda Functions features +/// to pass a listener to the mentioned Cloudlet, by means of the +/// [Cloudlet#addOnUpdateProcessingListener(EventListener)] method. +/// However, the same feature can be used for Java 7 passing an anonymous class +/// that implements `EventListener`. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 +/// +/// @see CloudSimPlus#terminate() +/// @see Cloudlet#addOnUpdateProcessingListener(EventListener) +/// @see EventListener public class TerminateSimulationAtGivenConditionExample { private final CloudSimPlus simulation; private List cloudletList; @@ -79,9 +77,7 @@ public static void main(String[] args) { new TerminateSimulationAtGivenConditionExample(); } - /** - * Default constructor that builds the simulation. - */ + /// Default constructor that builds the simulation. private TerminateSimulationAtGivenConditionExample() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ @@ -125,11 +121,9 @@ on behalf of a given cloud user (customer). System.out.println(getClass().getSimpleName() + " finished!"); } - /** - * Checks if the Cloudlet that had its processing updated reached 50% of execution. - * If so, request the simulation interruption. - * @param event object containing data about the happened event - */ + /// Checks if the Cloudlet that had its processing updated reached 50% of execution. + /// If so, request the simulation interruption. + /// @param event object containing data about the happened event private void onClouletProcessingUpdate(CloudletVmEventInfo event) { if(event.getCloudlet().getFinishedLengthSoFar() >= event.getCloudlet().getLength()/2.0){ System.out.printf( diff --git a/src/main/java/org/cloudsimplus/examples/simulationstatus/TerminateSimulationAtGivenTimeExample.java b/src/main/java/org/cloudsimplus/examples/simulationstatus/TerminateSimulationAtGivenTimeExample.java index 555ed80..d0862e2 100755 --- a/src/main/java/org/cloudsimplus/examples/simulationstatus/TerminateSimulationAtGivenTimeExample.java +++ b/src/main/java/org/cloudsimplus/examples/simulationstatus/TerminateSimulationAtGivenTimeExample.java @@ -42,17 +42,15 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to terminate the simulation at a given time, before its natural end. - * The example creates 4 Cloudlets that will run sequentially using a {@link CloudletSchedulerSpaceShared}. - * However, at the middle of the simulation, after just 2 of these 4 Cloudlets have finished, - * the simulation will be interrupeted, avoiding the other 2 Cloudlets to run. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0 - * - * @see CloudSimPlus#terminateAt(double) - */ +/// An example showing how to terminate the simulation at a given time, before its natural end. +/// The example creates 4 Cloudlets that will run sequentially using a [CloudletSchedulerSpaceShared]. +/// However, at the middle of the simulation, after just 2 of these 4 Cloudlets have finished, +/// the simulation will be interrupeted, avoiding the other 2 Cloudlets to run. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0 +/// +/// @see CloudSimPlus#terminateAt(double) public class TerminateSimulationAtGivenTimeExample { private static final int TIME_TO_FINISH_SIMULATION = 21; @@ -66,9 +64,7 @@ public static void main(String[] args) { new TerminateSimulationAtGivenTimeExample(); } - /** - * Default constructor that builds the simulation. - */ + /// Default constructor that builds the simulation. private TerminateSimulationAtGivenTimeExample() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ diff --git a/src/main/java/org/cloudsimplus/examples/simulationstatus/package-info.java b/src/main/java/org/cloudsimplus/examples/simulationstatus/package-info.java index 5ecaad8..418228e 100755 --- a/src/main/java/org/cloudsimplus/examples/simulationstatus/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/simulationstatus/package-info.java @@ -21,12 +21,10 @@ * You should have received a copy of the GNU General Public License * along with CloudSim Plus. If not, see . */ -/** - * Examples showing how to control simulation execution by - * pausing, resuming and stopping it. - * - * @author Manoel Campos da Silva Filho - */ +/// Examples showing how to control simulation execution by +/// pausing, resuming and stopping it. +/// +/// @author Manoel Campos da Silva Filho @NullMarked package org.cloudsimplus.examples.simulationstatus; diff --git a/src/main/java/org/cloudsimplus/examples/sla/VmMigrationWhenCpuMetricIsViolatedExample.java b/src/main/java/org/cloudsimplus/examples/sla/VmMigrationWhenCpuMetricIsViolatedExample.java index 165cb46..72a7cc9 100755 --- a/src/main/java/org/cloudsimplus/examples/sla/VmMigrationWhenCpuMetricIsViolatedExample.java +++ b/src/main/java/org/cloudsimplus/examples/sla/VmMigrationWhenCpuMetricIsViolatedExample.java @@ -50,16 +50,12 @@ import java.util.ArrayList; import java.util.List; -/** - * This example shows how to do a migration using CpuUtilization threshold - * defined in an SLA Contract. VM migration is triggered when the CPU metric is violated. - * - * @author raysaoliveira - */ +/// This example shows how to do a migration using CpuUtilization threshold +/// defined in an SLA Contract. VM migration is triggered when the CPU metric is violated. +/// +/// @author raysaoliveira public final class VmMigrationWhenCpuMetricIsViolatedExample { - /** - * @see Datacenter#setSchedulingInterval(double) - */ + /// @see Datacenter#setSchedulingInterval(double) private static final int SCHEDULE_TIME_TO_PROCESS_DATACENTER_EVENTS = 5; private static final int HOST_MIPS_BY_PE = 1000; @@ -78,23 +74,19 @@ public final class VmMigrationWhenCpuMetricIsViolatedExample { private static final long CLOUDLET_FILESIZE = 300; private static final long CLOUDLET_OUTPUTSIZE = 300; - /** - * The percentage of CPU that a cloudlet will use when it starts executing - * (in scale from 0 to 1, where 1 is 100%). For each cloudlet create, this - * value is used as a base to define CPU usage. - * - * @see #createAndSubmitCloudlets(DatacenterBroker) - */ + /// The percentage of CPU that a cloudlet will use when it starts executing + /// (in scale from 0 to 1, where 1 is 100%). For each cloudlet create, this + /// value is used as a base to define CPU usage. + /// + /// @see #createAndSubmitCloudlets(DatacenterBroker) private static final double CLOUDLET_INITIAL_CPU_USAGE_PERCENT = 0.6; - /** - * Defines the speed (in percentage) that CPU usage of a cloudlet will - * increase during the simulation time. (in scale from 0 to 1, where 1 is - * 100%). - * - * @see #createAndSubmitCloudletsWithDynamicCpuUsage(double, double, - * Vm, DatacenterBroker) - */ + /// Defines the speed (in percentage) that CPU usage of a cloudlet will + /// increase during the simulation time. (in scale from 0 to 1, where 1 is + /// 100%). + /// + /// @see #createAndSubmitCloudletsWithDynamicCpuUsage(double, double, + /// Vm, DatacenterBroker) private static final double CLOUDLET_CPU_USAGE_INCREMENT_PER_SECOND = 0.05; private static final int HOSTS = 20; @@ -104,9 +96,7 @@ public final class VmMigrationWhenCpuMetricIsViolatedExample { private final List vmList = new ArrayList<>(); private CloudSimPlus simulation; - /** - * The file containing the Customer's SLA Contract in JSON format. - */ + /// The file containing the Customer's SLA Contract in JSON format. private static final String CUSTOMER_SLA_CONTRACT = "CustomerSLA.json"; private SlaContract contract; @@ -206,15 +196,13 @@ private void createAndSubmitCloudlets( } } - /** - * Creates a {@link UtilizationModel} for a Cloudlet - * defines if CPU usage will be static or dynamic. - * - * @param initialCpuUsagePercent the percentage of CPU the Cloudlet will use initially - * @param maxCloudletCpuUsagePercent the maximum percentage of CPU the Cloudlet will use - * @param progressiveCpuUsage true if the CPU usage must increment along the time, false if it's static. - * @return the {@link UtilizationModel} for a Cloudlet's CPU usage - */ + /// Creates a [UtilizationModel] for a Cloudlet + /// defines if CPU usage will be static or dynamic. + /// + /// @param initialCpuUsagePercent the percentage of CPU the Cloudlet will use initially + /// @param maxCloudletCpuUsagePercent the maximum percentage of CPU the Cloudlet will use + /// @param progressiveCpuUsage true if the CPU usage must increment along the time, false if it's static. + /// @return the [UtilizationModel] for a Cloudlet's CPU usage private UtilizationModelDynamic createUtilizationModel( double initialCpuUsagePercent, double maxCloudletCpuUsagePercent, @@ -232,12 +220,10 @@ private UtilizationModelDynamic createUtilizationModel( return um; } - /** - * Increments the CPU resource utilization, that is defined in percentage - * values. - * - * @return the new resource utilization after the increment - */ + /// Increments the CPU resource utilization, that is defined in percentage + /// values. + /// + /// @return the new resource utilization after the increment private double getCpuUtilizationIncrement(final UtilizationModelDynamic um) { return um.getUtilization() + um.getTimeSpan() * CLOUDLET_CPU_USAGE_INCREMENT_PER_SECOND; } diff --git a/src/main/java/org/cloudsimplus/examples/synchronous/SynchronousSimulationExample1.java b/src/main/java/org/cloudsimplus/examples/synchronous/SynchronousSimulationExample1.java index 9ed0f1a..142530f 100755 --- a/src/main/java/org/cloudsimplus/examples/synchronous/SynchronousSimulationExample1.java +++ b/src/main/java/org/cloudsimplus/examples/synchronous/SynchronousSimulationExample1.java @@ -45,31 +45,26 @@ import java.util.Comparator; import java.util.List; -/** - * An example showing how to run the simulation synchronously, - * (by calling {@link CloudSimPlus#startSync()}). - * This way, the researcher can interact with the simulation, - * for instance to collect data. - * - *

      A synchronous simulation is similar to setting a {@link Datacenter#setSchedulingInterval(double) scheduling interval}: - * the simulation clock will be increased at the pace of the given interval. - * However, using the {@link CloudSimPlus#startSync()} we can collect - * simulation data inside a loop, - * without requiring to use {@link org.cloudsimplus.listeners.EventListener}s for that. - *

      - * - *

      In this example, we are collecting VMs' CPU utilization inside a loop, - * after each call of the {@link CloudSimPlus#runFor(double)} method.

      - * - * @author Pawel Koperek - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.5.0 - */ +/// An example showing how to run the simulation synchronously, +/// (by calling [CloudSimPlus#startSync()]). +/// This way, the researcher can interact with the simulation, +/// for instance to collect data. +/// +/// A synchronous simulation is similar to setting a [scheduling interval][Datacenter#setSchedulingInterval(double)]: +/// the simulation clock will be increased at the pace of the given interval. +/// However, using the [CloudSimPlus#startSync()] we can collect +/// simulation data inside a loop, +/// without requiring to use [org.cloudsimplus.listeners.EventListener]s for that. +/// +/// In this example, we are collecting VMs' CPU utilization inside a loop, +/// after each call of the [CloudSimPlus#runFor(double)] method. +/// +/// @author Pawel Koperek +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.5.0 public class SynchronousSimulationExample1 { - /** - * Defines the time (in seconds) to run the simulation for. - * The clock is increased in the interval defined here. - */ + /// Defines the time (in seconds) to run the simulation for. + /// The clock is increased in the interval defined here. private static final double INTERVAL = 2; private static final int HOSTS = 2; private static final int HOST_PES = 4; @@ -144,9 +139,7 @@ private void printVmCpuUtilization() { System.out.printf("%n%n"); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -177,9 +170,7 @@ private Host createHost() { return new HostSimple(ram, bw, storage, peList); } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var list = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -192,9 +183,7 @@ private List createVms() { return list; } - /** - * Creates a list of Cloudlets with different submission delays. - */ + /// Creates a list of Cloudlets with different submission delays. private List createCloudlets() { final var list = new ArrayList(CLOUDLETS); diff --git a/src/main/java/org/cloudsimplus/examples/synchronous/package-info.java b/src/main/java/org/cloudsimplus/examples/synchronous/package-info.java index 9948c23..8a83a3e 100755 --- a/src/main/java/org/cloudsimplus/examples/synchronous/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/synchronous/package-info.java @@ -21,18 +21,16 @@ * You should have received a copy of the GNU General Public License * along with CloudSim Plus. If not, see . */ -/** - * A set of examples showing how to run synchronous simulations. - * They use the {@link org.cloudsimplus.core.CloudSimPlus#startSync()} - * and then the {@link org.cloudsimplus.core.CloudSimPlus#runFor(double)} - * to run the simulation for a given period o time. - * This way, the simulation can be executed inside a loop, where - * different operations can be performed in each iteration - * (such as data collection). - * - * @author Pawel Koperek - * @author Manoel Campos da Silva Filho - */ +/// A set of examples showing how to run synchronous simulations. +/// They use the [org.cloudsimplus.core.CloudSimPlus#startSync()] +/// and then the [org.cloudsimplus.core.CloudSimPlus#runFor(double)] +/// to run the simulation for a given period o time. +/// This way, the simulation can be executed inside a loop, where +/// different operations can be performed in each iteration +/// (such as data collection). +/// +/// @author Pawel Koperek +/// @author Manoel Campos da Silva Filho @NullMarked package org.cloudsimplus.examples.synchronous; diff --git a/src/main/java/org/cloudsimplus/examples/traces/PlanetLabExample1.java b/src/main/java/org/cloudsimplus/examples/traces/PlanetLabExample1.java index 612f85f..44471f2 100755 --- a/src/main/java/org/cloudsimplus/examples/traces/PlanetLabExample1.java +++ b/src/main/java/org/cloudsimplus/examples/traces/PlanetLabExample1.java @@ -50,14 +50,12 @@ import java.util.List; import java.util.stream.IntStream; -/** - * An example showing how to use the {@link UtilizationModelPlanetLab} class - * to define Cloudlets' CPU utilization based on PlanetLab's trace files. - * Check the {@link #createCloudlets()} method. - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.0.0 - */ +/// An example showing how to use the [UtilizationModelPlanetLab] class +/// to define Cloudlets' CPU utilization based on [PlanetLab's](https://www.planet-lab.org) trace files. +/// Check the [#createCloudlets()] method. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.0.0 public class PlanetLabExample1 { private static final int HOSTS = 3; private static final int HOST_PES = 10; @@ -72,16 +70,14 @@ public class PlanetLabExample1 { private static final String TRACE_FILE = "workload/planetlab/20110303/75-130-96-12_static_oxfr_ma_charter_com_irisaple_wup"; - /** - * The time interval in which precise values can be got from - * the PlanetLab {@link #TRACE_FILE}. - * Such a value must be also defined as the Datacenter - * scheduling interval to ensure that Cloudlets' processing - * is updated with the values read from the trace file - * at the given interval. - * - * @see UtilizationModelPlanetLab#getSchedulingInterval() - */ + /// The time interval in which precise values can be got from + /// the PlanetLab [#TRACE_FILE]. + /// Such a value must be also defined as the Datacenter + /// scheduling interval to ensure that Cloudlets' processing + /// is updated with the values read from the trace file + /// at the given interval. + /// + /// @see UtilizationModelPlanetLab#getSchedulingInterval() private static final int SCHEDULING_INTERVAL = 300; private final CloudSimPlus simulation; @@ -119,9 +115,7 @@ private PlanetLabExample1() { System.out.printf("Simulation finished at %s. Execution time: %.2f seconds%n", LocalTime.now(), TimeUtil.elapsedSeconds(startSecs)); } - /** - * Creates a Datacenter and its Hosts. - */ + /// Creates a Datacenter and its Hosts. private Datacenter createDatacenter() { final var hostList = new ArrayList(HOSTS); for(int i = 0; i < HOSTS; i++) { @@ -150,9 +144,7 @@ private Host createHost() { return host; } - /** - * Creates a list of VMs. - */ + /// Creates a list of VMs. private List createVms() { final var list = new ArrayList(VMS); for (int i = 0; i < VMS; i++) { @@ -167,11 +159,9 @@ private List createVms() { return list; } - /** - * Creates a list of Cloudlets setting their CPU UtilizationModel as - * a {@link UtilizationModelPlanetLab} that read CPU utilization from - * a PlanetLab trace file. - */ + /// Creates a list of Cloudlets setting their CPU UtilizationModel as + /// a [UtilizationModelPlanetLab] that read CPU utilization from + /// a PlanetLab trace file. private List createCloudlets() { final var list = new ArrayList(CLOUDLETS); final var utilizationCpu = UtilizationModelPlanetLab.getInstance(TRACE_FILE, SCHEDULING_INTERVAL); diff --git a/src/main/java/org/cloudsimplus/examples/traces/SwfWorkloadFormatExample1.java b/src/main/java/org/cloudsimplus/examples/traces/SwfWorkloadFormatExample1.java index 633d76a..d288ff4 100755 --- a/src/main/java/org/cloudsimplus/examples/traces/SwfWorkloadFormatExample1.java +++ b/src/main/java/org/cloudsimplus/examples/traces/SwfWorkloadFormatExample1.java @@ -49,51 +49,40 @@ import java.util.ArrayList; import java.util.List; -/** - * An example showing how to dynamically create cloudlets from a workload trace - * file in the Standard Workload Format (.swf file) defined by the - * Hebrew University - * of Jerusalem. This example uses the workload file - * "NASA-iPSC-1993-3.1-cln.swf.gz", which was downloaded from the given - * web page and is located at the resources folder of this project. - * The workload file has 18239 jobs that will be created as Cloudlets. - * - *

      Considering the large number of cloudlets that can have a workload file, - * that can cause the simulation to consume a lot of resources - * at the developer machine and can spend a long time to finish, - * the example allow to limit the maximum number of cloudlets to be submitted - * to the DatacenterBroker. - * See the {@link #maxCloudletsToCreateFromWorkloadFile} attribute for more details. - *

      - * - *

      - * The workload file is compressed in gz format and the - * swf file inside it is just a text file that can be opened in any text - * editor. For more information about the workload format, check - * this - * page. - *

      - * - *

      Check important details at {@link SwfWorkloadFileReader} - * and {@link TraceReaderAbstract}.

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 1.0.0 - */ +/// An example showing how to dynamically create cloudlets from a workload trace +/// file in the Standard Workload Format (.swf file) defined by the +/// [Hebrew University of Jerusalem](http://www.cs.huji.ac.il/labs/parallel/workload/). This example uses the workload file +/// "*NASA-iPSC-1993-3.1-cln.swf.gz*", which was downloaded from the given +/// web page and is located at the resources folder of this project. +/// The workload file has 18239 jobs that will be created as Cloudlets. +/// +/// Considering the large number of cloudlets that can have a workload file, +/// that can cause the simulation to consume a lot of resources +/// at the developer machine and can **spend a long time to finish**, +/// the example allow to limit the maximum number of cloudlets to be submitted +/// to the DatacenterBroker. +/// See the [#maxCloudletsToCreateFromWorkloadFile] attribute for more details. +/// +/// The workload file is compressed in *gz* format and the +/// *swf* file inside it is just a text file that can be opened in any text +/// editor. For more information about the workload format, check +/// [this page](http://www.cs.huji.ac.il/labs/parallel/workload/swf.html). +/// +/// Check important details at [SwfWorkloadFileReader] +/// and [TraceReaderAbstract]. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 1.0.0 public class SwfWorkloadFormatExample1 { - /** - * The workload file to be read. - */ + /// The workload file to be read. private static final String WORKLOAD_FILENAME = "workload/swf/NASA-iPSC-1993-3.1-cln.swf.gz"; private final CloudSimPlus simulation; - /** - * Defines the maximum number of cloudlets to be created - * from the given workload file. - * {@link Integer#MAX_VALUE} indicates that every job inside the workload file - * will be created as one cloudlet. - */ + /// Defines the maximum number of cloudlets to be created + /// from the given workload file. + /// [Integer#MAX_VALUE] indicates that every job inside the workload file + /// will be created as one cloudlet. private int maxCloudletsToCreateFromWorkloadFile = Integer.MAX_VALUE; private final int HOST_PES = 12; @@ -108,11 +97,9 @@ public class SwfWorkloadFormatExample1 { private final List vmlist = new ArrayList<>(); private final DatacenterBroker broker; - /** - * Creates main() to run this example. - * - * @param args the args - */ + /// Creates main() to run this example. + /// + /// @param args the args public static void main(String[] args) { new SwfWorkloadFormatExample1(); } @@ -155,12 +142,10 @@ private SwfWorkloadFormatExample1() { } } - /** - * Method executed when all VMs submitted to the broker are placed - * into some Host. - * @param info - * @see DatacenterBroker#addOnVmsCreatedListener(EventListener) - */ + /// Method executed when all VMs submitted to the broker are placed + /// into some Host. + /// @param info + /// @see DatacenterBroker#addOnVmsCreatedListener(EventListener) private void onVmsCreated(DatacenterBrokerEventInfo info) { System.out.printf("%d VMs from Broker %d placed into some Host%n", vmlist.size(), info.getDatacenterBroker().getId()); } @@ -173,10 +158,8 @@ private void sleep(final long seconds) { } } - /** - * Creates a list of VMs according to the number of Cloudlets, - * in order to try accommodating all Cloudlets into those VMs. - */ + /// Creates a list of VMs according to the number of Cloudlets, + /// in order to try accommodating all Cloudlets into those VMs. private void createVms() { final double totalCloudletPes = cloudletList.stream().mapToDouble(Cloudlet::getPesNumber).sum(); /* The number to multiply the VM_PES was chosen at random. @@ -201,12 +184,10 @@ private void createCloudletsFromWorkloadFile() { System.out.printf("# Created %12d Cloudlets for %s%n", this.cloudletList.size(), broker); } - /** - * Creates the Datacenter with a number of Hosts according to the number of created VMs, - * in order to try accommodating all VMs into those Hosts. - * - * @return the created Datacenter - */ + /// Creates the Datacenter with a number of Hosts according to the number of created VMs, + /// in order to try accommodating all VMs into those Hosts. + /// + /// @return the created Datacenter private Datacenter createDatacenter() { final var hostList = createHosts(vmlist.size()/2); var datacenter = new DatacenterSimple(simulation, hostList, new VmAllocationPolicyFirstFit()); @@ -215,12 +196,10 @@ private Datacenter createDatacenter() { return datacenter; } - /** - * Creates a specific number of PM's with the same capacity. - * - * @param hostsNumber number of hosts to create - * @return the created host - */ + /// Creates a specific number of PM's with the same capacity. + /// + /// @param hostsNumber number of hosts to create + /// @return the created host private List createHosts(final long hostsNumber) { final long ram = VM_RAM * 100; final long storage = VM_SIZE * 1000; diff --git a/src/main/java/org/cloudsimplus/examples/traces/google/GoogleMachineEventsExample1.java b/src/main/java/org/cloudsimplus/examples/traces/google/GoogleMachineEventsExample1.java index 2517edc..b5e5919 100755 --- a/src/main/java/org/cloudsimplus/examples/traces/google/GoogleMachineEventsExample1.java +++ b/src/main/java/org/cloudsimplus/examples/traces/google/GoogleMachineEventsExample1.java @@ -51,32 +51,26 @@ import java.util.List; import java.util.function.Function; -/** - * An example showing how to create Hosts from a Google Machine Events Trace - * using a {@link GoogleMachineEventsTraceReader}. The trace is located in - * resources/workload/google-traces/machine-events-sample-1.csv It has some - * records that defines the addition and removal of Hosts to the Datacenters. - * - *

      - * The removal is used to simulate maintenance or failure but the trace doesn't - * provide information about the cause of the removal. This way, CloudSim Plus - * considers that any Host removal is due to a failure and injects that failure - * for the Host at the specified timestamp. The same Host can fail and recover - * as specified in the trace. CloudSim Plus accordingly process such events. You - * can confirm in the logs that Host 3 is added and removed multiple times. - *

      - * - *

      - * Check important details at {@link TraceReaderAbstract}. To better understand - * the structure of trace files, check the google-cluster-data-samples.xlsx - * spreadsheet inside the docs dir. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.0.0 - * - * TODO {@link MachineEventType#UPDATE} events are not being processed yet. - */ +/// An example showing how to create Hosts from a Google Machine Events Trace +/// using a [GoogleMachineEventsTraceReader]. The trace is located in +/// resources/workload/google-traces/machine-events-sample-1.csv It has some +/// records that defines the addition and removal of Hosts to the Datacenters. +/// +/// The removal is used to simulate maintenance or failure but the trace doesn't +/// provide information about the cause of the removal. This way, CloudSim Plus +/// considers that any Host removal is due to a failure and injects that failure +/// for the Host at the specified timestamp. The same Host can fail and recover +/// as specified in the trace. CloudSim Plus accordingly process such events. You +/// can confirm in the logs that Host 3 is added and removed multiple times. +/// +/// Check important details at [TraceReaderAbstract]. To better understand +/// the structure of trace files, check the google-cluster-data-samples.xlsx +/// spreadsheet inside the docs dir. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.0.0 +/// +/// TODO [MachineEventType#UPDATE] events are not being processed yet. public class GoogleMachineEventsExample1 { private static final String TRACE_FILENAME = "workload/google-traces/machine-events-sample-1.csv"; private static final int HOST_BW = 10; @@ -125,29 +119,23 @@ private double getHostStartupTime(final Cloudlet cloudlet) { return cloudlet.getVm().getHost().getStartTime(); } - /** - * Method called every time a new Host becomes available during simulation runtime - * for the second Datacenter. It creates a VM and a Cloudlet, submitting them when there is a new Host available. - * - * @param info event information (that includes the simulation time and the new available host) - */ + /// Method called every time a new Host becomes available during simulation runtime + /// for the second Datacenter. It creates a VM and a Cloudlet, submitting them when there is a new Host available. + /// + /// @param info event information (that includes the simulation time and the new available host) private void onHostAvailableListener(HostEventInfo info) { final Vm vm = createVm(info.getHost()); broker0.submitVm(vm); broker0.submitCloudlet(createCloudlet(vm)); } - /** - * Creates the Datacenters and Hosts, where Hosts's specification is read from a - * "machine events" Google Cluster Data trace file - * - *

      - * A {@link GoogleMachineEventsTraceReader} instance is used to read the file. - * It requires a {@link Function} - * that will be called internally to actually create the Hosts. - * This function is the {@link #createHost(MachineEvent)}. - *

      - */ + /// Creates the Datacenters and Hosts, where Hosts's specification is read from a + /// "machine events" Google Cluster Data trace file + /// + /// A [GoogleMachineEventsTraceReader] instance is used to read the file. + /// It requires a [Function] + /// that will be called internally to actually create the Hosts. + /// This function is the [#createHost(MachineEvent)]. private void createDatacenters() { datacenters = new ArrayList<>(DATACENTERS_NUMBER); @@ -176,14 +164,12 @@ private void createDatacenters() { datacenters.get(0).addHostList(hostList); } - /** - * A method that is used to actually create each Host defined in the trace file. - * The researcher can write his/her own code inside this method to define - * how he/she wants to create the Hosts based on the trace data. - * - * @param event an object containing the trace line read, used to create the Host. - * @return - */ + /// A method that is used to actually create each Host defined in the trace file. + /// The researcher can write his/her own code inside this method to define + /// how he/she wants to create the Hosts based on the trace data. + /// + /// @param event an object containing the trace line read, used to create the Host. + /// @return private Host createHost(final MachineEvent event) { final Host host = new HostSimple(event.getRam(), HOST_BW, HOST_STORAGE, createPesList(event.getCpuCores())); host.setId(event.getMachineId()); @@ -199,9 +185,7 @@ private List createPesList(final int count) { return cpuCoresList; } - /** - * Creates a list of VMs and Cloudlets in a given Datacenter. - */ + /// Creates a list of VMs and Cloudlets in a given Datacenter. private List createAndSubmitVms(Datacenter datacenter) { final var list = new ArrayList(datacenter.getHostList().size()); /* Creates 1 VM for each available Host of the datacenter. @@ -214,21 +198,17 @@ private List createAndSubmitVms(Datacenter datacenter) { return list; } - /** - * Creates a VM with the same capacity of a given Host. - * This way, it will run one VM by Host. - * @param host - * @return - */ + /// Creates a VM with the same capacity of a given Host. + /// This way, it will run one VM by Host. + /// @param host + /// @return private Vm createVm(final Host host) { return new VmSimple(1000, host.getPesNumber()) .setRam(host.getRam().getCapacity()).setBw(HOST_BW).setSize(HOST_STORAGE) .setCloudletScheduler(new CloudletSchedulerSpaceShared()); } - /** - * Creates a list of Cloudlets for the given VMs. - */ + /// Creates a list of Cloudlets for the given VMs. private void createAndSubmitCloudlets(final List vmList) { final var list = new ArrayList(vmList.size()); for (final var vm : vmList) { diff --git a/src/main/java/org/cloudsimplus/examples/traces/google/GoogleTaskEventsExample1.java b/src/main/java/org/cloudsimplus/examples/traces/google/GoogleTaskEventsExample1.java index 6f3676a..fed8b1f 100755 --- a/src/main/java/org/cloudsimplus/examples/traces/google/GoogleTaskEventsExample1.java +++ b/src/main/java/org/cloudsimplus/examples/traces/google/GoogleTaskEventsExample1.java @@ -63,33 +63,27 @@ import static org.cloudsimplus.util.BytesConversion.megaBytesToBytes; import static org.cloudsimplus.util.MathUtil.positive; -/** - * An example showing how to use Google Cluster Data trace files. - * The example creates Cloudlets (tasks) from a Google Task Events - * Trace using a {@link GoogleTaskEventsTraceReader}. Then it uses a - * {@link GoogleTaskUsageTraceReader} to read "task usage" trace files that - * define how created Cloudlets will use resources along the time. - * - *

      - * The traces are located in resources/workload/google-traces/. Each line in the - * "task events" trace defines the scheduling of tasks (Cloudlets) inside a - * Datacenter. - *

      - * - *

      - * Check important details at {@link TraceReaderAbstract}. To better understand - * the structure of trace files, check the google-cluster-data-samples.xlsx - * spreadsheet inside the docs dir. - *

      - * - * @author Manoel Campos da Silva Filho - * @since CloudSim Plus 4.0.0 - * - * TODO A joint example that creates Hosts and Cloudlets from trace files will be useful. - * TODO See https://github.com/manoelcampos/cloudsimplus/issues/151 - * TODO {@link CloudSimTag#CLOUDLET_FAIL} events aren't been processed. - * TODO It has to be checked how to make the Cloudlet to be executed in the Host specified in the trace file. - */ +/// An example showing how to use [Google Cluster Data](https://github.com/google/cluster-data) trace files. +/// The example creates Cloudlets (tasks) from a Google Task Events +/// Trace using a [GoogleTaskEventsTraceReader]. Then it uses a +/// [GoogleTaskUsageTraceReader] to read "task usage" trace files that +/// define how created Cloudlets will use resources along the time. +/// +/// The traces are located in resources/workload/google-traces/. Each line in the +/// "task events" trace defines the scheduling of tasks (Cloudlets) inside a +/// Datacenter. +/// +/// Check important details at [TraceReaderAbstract]. To better understand +/// the structure of trace files, check the google-cluster-data-samples.xlsx +/// spreadsheet inside the docs dir. +/// +/// @author Manoel Campos da Silva Filho +/// @since CloudSim Plus 4.0.0 +/// +/// TODO A joint example that creates Hosts and Cloudlets from trace files will be useful. +/// TODO See https://github.com/manoelcampos/cloudsimplus/issues/151 +/// TODO [CloudSimTag#CLOUDLET_FAIL] events aren't been processed. +/// TODO It has to be checked how to make the Cloudlet to be executed in the Host specified in the trace file. public class GoogleTaskEventsExample1 { private static final String TASK_EVENTS_FILE = "workload/google-traces/task-events-sample-1.csv"; private static final String TASK_USAGE_FILE = "workload/google-traces/task-usage-sample-1.csv"; @@ -102,18 +96,14 @@ public class GoogleTaskEventsExample1 { private static final long HOST_STORAGE = 1000000; //in Megabytes private static final double HOST_MIPS = 1000; - /** - * Defines a negative length for Cloudlets created from the Google Task Events Trace file, - * so that they can run indefinitely until a {@link CloudSimTag#CLOUDLET_FINISH} - * event is received by the {@link DatacenterBroker}. - * Check out {@link Cloudlet#setLength(long)} for details. - */ + /// Defines a negative length for Cloudlets created from the Google Task Events Trace file, + /// so that they can run indefinitely until a [CloudSimTag#CLOUDLET_FINISH] + /// event is received by the [DatacenterBroker]. + /// Check out [Cloudlet#setLength(long)] for details. private static final int CLOUDLET_LENGTH = -10_000; - /** - * Max number of Cloudlets to create from the Google Task Events trace file. - * @see GoogleTaskEventsTraceReader#setMaxCloudletsToCreate(int) - */ + /// Max number of Cloudlets to create from the Google Task Events trace file. + /// @see GoogleTaskEventsTraceReader#setMaxCloudletsToCreate(int) private static final int MAX_CLOUDLETS = 8; private static final long VM_PES = 4; @@ -162,26 +152,21 @@ private int getTotalCreatedCloudletsNumber() { return brokers.stream().mapToInt(b -> b.getCloudletCreatedList().size()).sum(); } - /** - * Creates a list of Cloudlets from a "task events" Google Cluster Data trace file. - * The brokers that own each Cloudlet are defined by the username field - * in the file. For each distinct username, a broker is created - * and its name is defined based on the username. - * - *

      - * A {@link GoogleTaskEventsTraceReader} instance is used to read the file. - * It requires a {@link Function} - * that will be called internally to actually create the Cloudlets. - * This function is the {@link #createCloudlet(TaskEvent)}.* - *

      - * - *

      - * If you want to improve simulation performance and use the same broker - * for all created cloudlets, avoiding the reader to create brokers based on the - * username field of the trace file, call {@link BrokerManager#setDefaultBroker(DatacenterBroker)}. - *

      - * @see GoogleTaskEventsTraceReader#getBrokerManager() - */ + /// Creates a list of Cloudlets from a "task events" Google Cluster Data trace file. + /// The brokers that own each Cloudlet are defined by the username field + /// in the file. For each distinct username, a broker is created + /// and its name is defined based on the username. + /// + /// A [GoogleTaskEventsTraceReader] instance is used to read the file. + /// It requires a [Function] + /// that will be called internally to actually create the Cloudlets. + /// This function is the [#createCloudlet(TaskEvent)].* + /// + /// If you want to improve simulation performance and use the same broker + /// for all created cloudlets, avoiding the reader to create brokers based on the + /// username field of the trace file, call [BrokerManager#setDefaultBroker(DatacenterBroker)]. + /// + /// @see GoogleTaskEventsTraceReader#getBrokerManager() private void createCloudletsAndBrokersFromTraceFile() { taskEventsReader = GoogleTaskEventsTraceReader @@ -196,15 +181,13 @@ private void createCloudletsAndBrokersFromTraceFile() { cloudlets.size(), brokers.size(), TASK_EVENTS_FILE); } - /** - * A method called by a {@link GoogleTaskEventsTraceReader} to actually create each Cloudlet - * defined as a task in the trace file. - * You can write your own code inside this method to define - * how you want to create the Cloudlet based on the trace data. - * - * @param event an object containing the trace line read, used to create the Cloudlet. - * @return - */ + /// A method called by a [GoogleTaskEventsTraceReader] to actually create each Cloudlet + /// defined as a task in the trace file. + /// You can write your own code inside this method to define + /// how you want to create the Cloudlet based on the trace data. + /// + /// @param event an object containing the trace line read, used to create the Cloudlet. + /// @return private Cloudlet createCloudlet(final TaskEvent event) { /* The trace doesn't define the actual number of CPU cores (PEs) a Cloudlet will require, @@ -228,16 +211,12 @@ private Cloudlet createCloudlet(final TaskEvent event) { .setUtilizationModelRam(utilizationRam); } - /** - * Process a "task usage" trace file from the Google Cluster Data that - * defines the resource usage for Cloudlets (tasks) along the time. - * The reader is just considering data about RAM and CPU utilization. - * - *

      - * You are encouraged to check {@link GoogleTaskUsageTraceReader#process()} - * documentation to understand the details. - *

      - */ + /// Process a "task usage" trace file from the Google Cluster Data that + /// defines the resource usage for Cloudlets (tasks) along the time. + /// The reader is just considering data about RAM and CPU utilization. + /// + /// You are encouraged to check [GoogleTaskUsageTraceReader#process()] + /// documentation to understand the details. private void readTaskUsageTraceFile() { final var reader = GoogleTaskUsageTraceReader.getInstance(taskEventsReader, TASK_USAGE_FILE); final var cloudletsCollection = reader.process(); diff --git a/src/main/java/org/cloudsimplus/examples/traces/package-info.java b/src/main/java/org/cloudsimplus/examples/traces/package-info.java index a434ea3..19ed84a 100755 --- a/src/main/java/org/cloudsimplus/examples/traces/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/traces/package-info.java @@ -21,11 +21,9 @@ * You should have received a copy of the GNU General Public License * along with CloudSim Plus. If not, see . */ -/** - * Examples showing how to create simulations using a trace file. - * - * @author Manoel Campos da Silva Filho - */ +/// Examples showing how to create simulations using a trace file. +/// +/// @author Manoel Campos da Silva Filho @NullMarked package org.cloudsimplus.examples.traces;