diff --git a/.mvn/jvm.config b/.mvn/jvm.config new file mode 100644 index 0000000..32599ce --- /dev/null +++ b/.mvn/jvm.config @@ -0,0 +1,10 @@ +--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED +--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED +--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED diff --git a/pom.xml b/pom.xml index 03ede8f..0c8d724 100755 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,11 @@ + 2.50.0 + 0.14.2 + 1.0.0 + + -XepDisableWarningsInGeneratedCode -XepExcludedPaths:.*/target/generated-sources/.* -Xep:StringConcatToTextBlock:OFF UTF-8 5.0.0 @@ -63,6 +68,42 @@ org.apache.maven.plugins maven-compiler-plugin 3.14.0 + + + + + com.google.errorprone + error_prone_core + ${errorprone.version} + + + + com.uber.nullaway + nullaway + ${nullaway.version} + + + + + -XDcompilePolicy=simple + --should-stop=ifError=FLOW + -Xplugin:ErrorProne ${errorprone.args} -Xep:NullAway:ERROR -XepOpt:NullAway:OnlyNullMarked=true + + @@ -152,5 +193,15 @@ logback-classic ${logback.version} + + + org.jspecify + jspecify + ${jspecify.version} + 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 126b476..c539008 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 @@ -230,7 +230,7 @@ protected void createNetwork(final NetworkDatacenter datacenter) { * @return the index of the switch to connect the host */ public static int getSwitchIndex(final NetworkHost host, final int switchPorts) { - return Math.round(host.getId() % Integer.MAX_VALUE) / switchPorts; + return (int) (host.getId() % Integer.MAX_VALUE) / switchPorts; } /** diff --git a/src/main/java/org/cloudbus/cloudsim/examples/network/applications/package-info.java b/src/main/java/org/cloudbus/cloudsim/examples/network/applications/package-info.java new file mode 100644 index 0000000..31b1a90 --- /dev/null +++ b/src/main/java/org/cloudbus/cloudsim/examples/network/applications/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package org.cloudbus.cloudsim.examples.network.applications; + +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/cloudbus/cloudsim/examples/network/package-info.java b/src/main/java/org/cloudbus/cloudsim/examples/network/package-info.java new file mode 100644 index 0000000..30b75c9 --- /dev/null +++ b/src/main/java/org/cloudbus/cloudsim/examples/network/package-info.java @@ -0,0 +1,12 @@ +/* + * Title: CloudSim Toolkit + * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation + * of Clouds + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Copyright (c) 2009, The University of Melbourne, Australia + */ +@NullMarked +package org.cloudbus.cloudsim.examples.network; + +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/cloudsimplus/examples/HostFaultInjectionExample1.java b/src/main/java/org/cloudsimplus/examples/HostFaultInjectionExample1.java index 79521c2..dd3d64b 100755 --- a/src/main/java/org/cloudsimplus/examples/HostFaultInjectionExample1.java +++ b/src/main/java/org/cloudsimplus/examples/HostFaultInjectionExample1.java @@ -95,7 +95,7 @@ public final class HostFaultInjectionExample1 { /** @see HostFaultInjection#setMaxTimeToFailInHours(double) */ private static final double MAX_TIME_TO_FAIL_IN_HOURS = TimeUtil.daysToHours(30); - private List hostList; + private final List hostList = new ArrayList<>(); private static final int VMS_BY_BROKER = 2; private static final int VM_PES = 2; //number of cpus @@ -220,7 +220,6 @@ public void createAndSubmitCloudlets(final DatacenterBroker broker) { } private Datacenter createDatacenter() { - hostList = new ArrayList<>(); for (int id = 1; id <= HOSTS; id++) { hostList.add(createHost(id)); } @@ -327,8 +326,8 @@ private List cloneCloudlets(final Vm sourceVm) { final var clonedCloudlet = cloneCloudlet(sourceCloudlet); clonedCloudletList.add(clonedCloudlet); System.out.printf( - "# %s: Cloning %s as Cloudlet %d%n", - sourceVm.getBroker(), sourceCloudlet, clonedCloudlet.getId(), sourceVm); + "# %s: Cloning %s from %s as Cloudlet %d%n", + sourceVm.getBroker(), sourceCloudlet, sourceVm, clonedCloudlet.getId()); } return clonedCloudletList; diff --git a/src/main/java/org/cloudsimplus/examples/ParallelSimulationsExample.java b/src/main/java/org/cloudsimplus/examples/ParallelSimulationsExample.java index 47e157c..0116d82 100755 --- a/src/main/java/org/cloudsimplus/examples/ParallelSimulationsExample.java +++ b/src/main/java/org/cloudsimplus/examples/ParallelSimulationsExample.java @@ -73,6 +73,8 @@ public class ParallelSimulationsExample implements Runnable { private final String title; private final CloudSimPlus simulation; + /** Created when the simulation is started inside {@link #run()}. */ + @SuppressWarnings("NullAway.Init") private DatacenterBroker broker; private List cloudletList; private List vmList; 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 4622666..f7804f1 100755 --- a/src/main/java/org/cloudsimplus/examples/autoscaling/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/autoscaling/package-info.java @@ -5,4 +5,7 @@ * * @author Manoel Campos da Silva Filho */ +@NullMarked package org.cloudsimplus.examples.autoscaling; + +import org.jspecify.annotations.NullMarked; 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 31eae7a..f0a0c9b 100755 --- a/src/main/java/org/cloudsimplus/examples/brokers/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/brokers/package-info.java @@ -14,4 +14,7 @@ * * @author Manoel Campos da Silva Filho */ +@NullMarked package org.cloudsimplus.examples.brokers; + +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/cloudsimplus/examples/costs/package-info.java b/src/main/java/org/cloudsimplus/examples/costs/package-info.java new file mode 100644 index 0000000..68e1b6f --- /dev/null +++ b/src/main/java/org/cloudsimplus/examples/costs/package-info.java @@ -0,0 +1,27 @@ +/* + * 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 . + */ +@NullMarked +package org.cloudsimplus.examples.costs; + +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmAllocationPolicyBestFitExample.java b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmAllocationPolicyBestFitExample.java index 2718aa5..975d927 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmAllocationPolicyBestFitExample.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/DynamicVmAllocationPolicyBestFitExample.java @@ -133,7 +133,7 @@ public final class DynamicVmAllocationPolicyBestFitExample { private final List vmList = new ArrayList<>(); private CloudSimPlus simulation; - private List hostList; + private final List hostList = new ArrayList<>(); public static void main(String[] args) { new DynamicVmAllocationPolicyBestFitExample(); @@ -234,7 +234,6 @@ public Vm createVm(int pes) { * @return */ private Datacenter createDatacenter() { - this.hostList = new ArrayList<>(); for(int i = 0; i < HOSTS; i++){ final int pes = HOST_INITIAL_PES + i; final var host = createHost(pes, HOST_MIPS); 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 c428143..18ea74d 100755 --- a/src/main/java/org/cloudsimplus/examples/dynamic/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/dynamic/package-info.java @@ -5,4 +5,7 @@ * * @author Manoel Campos da Silva Filho */ +@NullMarked package org.cloudsimplus.examples.dynamic; + +import org.jspecify.annotations.NullMarked; 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 51864a6..4a827a3 100755 --- a/src/main/java/org/cloudsimplus/examples/listeners/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/listeners/package-info.java @@ -7,4 +7,7 @@ * * @author Manoel Campos da Silva Filho */ +@NullMarked package org.cloudsimplus.examples.listeners; + +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/cloudsimplus/examples/migration/ManualMigrationExample1.java b/src/main/java/org/cloudsimplus/examples/migration/ManualMigrationExample1.java index 4d25501..afd611a 100755 --- a/src/main/java/org/cloudsimplus/examples/migration/ManualMigrationExample1.java +++ b/src/main/java/org/cloudsimplus/examples/migration/ManualMigrationExample1.java @@ -135,7 +135,7 @@ public final class ManualMigrationExample1 { private final Datacenter datacenter0; private CloudSimPlus simulation; - private List hostList; + private final List hostList = new ArrayList<>(); private boolean migrationRequested; private int migrationsNumber; @@ -280,7 +280,6 @@ public Vm createVm(int pes) { * @return */ private Datacenter createDatacenter() { - this.hostList = new ArrayList<>(); for(int i = 0; i < HOSTS; i++){ final int pes = HOST_INITIAL_PES + i; hostList.add(createHost(pes, HOST_MIPS)); diff --git a/src/main/java/org/cloudsimplus/examples/migration/MigrationExample1.java b/src/main/java/org/cloudsimplus/examples/migration/MigrationExample1.java index 4c80ded..7356aff 100755 --- a/src/main/java/org/cloudsimplus/examples/migration/MigrationExample1.java +++ b/src/main/java/org/cloudsimplus/examples/migration/MigrationExample1.java @@ -202,8 +202,8 @@ public final class MigrationExample1 { private final DatacenterBrokerSimple broker; private final CloudSimPlus simulation; - private VmAllocationPolicyMigrationStaticThreshold allocationPolicy; - private List hostList; + private final VmAllocationPolicyMigrationStaticThreshold allocationPolicy; + private final List hostList; private int migrationsNumber = 0; public static void main(String[] args) { @@ -220,6 +220,8 @@ private MigrationExample1(){ System.out.println("Starting " + getClass().getSimpleName()); simulation = new CloudSimPlus(); + this.hostList = createHosts(); + this.allocationPolicy = createAllocationPolicy(); @SuppressWarnings("unused") final var datacenter0 = createDatacenter(); broker = new DatacenterBrokerSimple(simulation); @@ -424,25 +426,7 @@ private double getCpuUsageIncrement(final UtilizationModelDynamic um){ * @return */ private Datacenter createDatacenter() { - this.hostList = createHosts(); System.out.println(); - - /** - * 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. - */ - this.allocationPolicy = - new VmAllocationPolicyMigrationBestFitStaticThreshold( - new VmSelectionPolicyMinimumUtilization(), - HOST_OVER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION + 0.2); - this.allocationPolicy.setUnderUtilizationThreshold(HOST_UNDER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION); - final var dc = new DatacenterSimple(simulation, hostList, allocationPolicy); for (Host host : hostList) { System.out.printf( @@ -454,6 +438,26 @@ 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. + */ + private VmAllocationPolicyMigrationStaticThreshold createAllocationPolicy() { + final var policy = + new VmAllocationPolicyMigrationBestFitStaticThreshold( + new VmSelectionPolicyMinimumUtilization(), + HOST_OVER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION + 0.2); + policy.setUnderUtilizationThreshold(HOST_UNDER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION); + return policy; + } + private List createHosts() { final var hostList = new ArrayList(HOST_PES.length); for (int i = 0; i < HOST_PES.length; i++) { 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 9984c5b..8fdefde 100755 --- a/src/main/java/org/cloudsimplus/examples/migration/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/migration/package-info.java @@ -5,4 +5,7 @@ * * @author Manoel Campos da Silva Filho */ +@NullMarked package org.cloudsimplus.examples.migration; + +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/cloudsimplus/examples/package-info.java b/src/main/java/org/cloudsimplus/examples/package-info.java new file mode 100644 index 0000000..acf1185 --- /dev/null +++ b/src/main/java/org/cloudsimplus/examples/package-info.java @@ -0,0 +1,27 @@ +/* + * 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 . + */ +@NullMarked +package org.cloudsimplus.examples; + +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/cloudsimplus/examples/performance/UtilizationModelStochasticPerformance.java b/src/main/java/org/cloudsimplus/examples/performance/UtilizationModelStochasticPerformance.java index 854f986..02d6e6b 100755 --- a/src/main/java/org/cloudsimplus/examples/performance/UtilizationModelStochasticPerformance.java +++ b/src/main/java/org/cloudsimplus/examples/performance/UtilizationModelStochasticPerformance.java @@ -43,6 +43,7 @@ import org.cloudsimplus.utilizationmodels.UtilizationModelStochastic; import org.cloudsimplus.vms.Vm; import org.cloudsimplus.vms.VmSimple; +import org.jspecify.annotations.Nullable; import java.lang.management.ManagementFactory; import java.lang.management.MemoryPoolMXBean; @@ -127,7 +128,12 @@ public class UtilizationModelStochasticPerformance { private List vmList; private List cloudletList; private Datacenter datacenter0; - private UtilizationModelStochastic um; + /** + * The utilization model shared by all Cloudlets + * (when {@link #MULTIPLE_UTILIZATION_MODELS} is false). + * It's null until the first Cloudlet is created. + */ + private @Nullable UtilizationModelStochastic um; public static void main(String[] args) { new UtilizationModelStochasticPerformance(); diff --git a/src/main/java/org/cloudsimplus/examples/performance/package-info.java b/src/main/java/org/cloudsimplus/examples/performance/package-info.java new file mode 100644 index 0000000..6fa7cbf --- /dev/null +++ b/src/main/java/org/cloudsimplus/examples/performance/package-info.java @@ -0,0 +1,27 @@ +/* + * 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 . + */ +@NullMarked +package org.cloudsimplus.examples.performance; + +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/cloudsimplus/examples/power/package-info.java b/src/main/java/org/cloudsimplus/examples/power/package-info.java new file mode 100644 index 0000000..cdecfb8 --- /dev/null +++ b/src/main/java/org/cloudsimplus/examples/power/package-info.java @@ -0,0 +1,27 @@ +/* + * 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 . + */ +@NullMarked +package org.cloudsimplus.examples.power; + +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/cloudsimplus/examples/resourceusage/VmsRamAndBwUsageExample.java b/src/main/java/org/cloudsimplus/examples/resourceusage/VmsRamAndBwUsageExample.java index ff13a92..1a6f194 100755 --- a/src/main/java/org/cloudsimplus/examples/resourceusage/VmsRamAndBwUsageExample.java +++ b/src/main/java/org/cloudsimplus/examples/resourceusage/VmsRamAndBwUsageExample.java @@ -151,16 +151,18 @@ private void printVmUtilizationHistory(Vm vm) { System.out.println(vm + " RAM and BW utilization history"); System.out.println("----------------------------------------------------------------------------------"); - //A set containing all resource utilization collected times - final Set timeSet = allVmsRamUtilizationHistory.get(vm).keySet(); - - final Map vmRamUtilization = allVmsRamUtilizationHistory.get(vm); - final Map vmBwUtilization = allVmsBwUtilizationHistory.get(vm); - - for (final double time : timeSet) { + //Every VM has a utilization map, created by initializeUtilizationHistory() + final Map vmRamUtilization = Objects.requireNonNull(allVmsRamUtilizationHistory.get(vm)); + final Map vmBwUtilization = Objects.requireNonNull(allVmsBwUtilizationHistory.get(vm)); + + //Each entry has a resource utilization collected time and the RAM utilization at that time + for (final var entry : vmRamUtilization.entrySet()) { + final double time = entry.getKey(); + //RAM and BW utilization are collected at the same times + final double bwUtilization = Objects.requireNonNull(vmBwUtilization.get(time)); System.out.printf( "Time: %10.1f secs | RAM Utilization: %10.2f%% | BW Utilization: %10.2f%%%n", - time, vmRamUtilization.get(time) * 100, vmBwUtilization.get(time) * 100); + time, entry.getValue() * 100, bwUtilization * 100); } System.out.printf("----------------------------------------------------------------------------------%n%n"); @@ -213,7 +215,7 @@ private void collectVmResourceUtilization(final Map> all /*Gets the internal resource utilization map for the current VM. * The key of this map is the time the usage was collected (in seconds) * and the value the percentage of utilization (from 0 to 1). */ - final Map vmUtilizationHistory = allVmsUtilizationHistory.get(vm); + final Map vmUtilizationHistory = Objects.requireNonNull(allVmsUtilizationHistory.get(vm)); vmUtilizationHistory.put(simulation.clock(), vm.getResource(resourceClass).getPercentUtilization()); } } 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 55bd2c7..a46e81a 100755 --- a/src/main/java/org/cloudsimplus/examples/resourceusage/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/resourceusage/package-info.java @@ -8,4 +8,7 @@ * * @author Manoel Campos da Silva Filho */ +@NullMarked package org.cloudsimplus.examples.resourceusage; + +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/cloudsimplus/examples/schedulers/VmSchedulerTimeSharedExample.java b/src/main/java/org/cloudsimplus/examples/schedulers/VmSchedulerTimeSharedExample.java index fb6ece1..94c8965 100755 --- a/src/main/java/org/cloudsimplus/examples/schedulers/VmSchedulerTimeSharedExample.java +++ b/src/main/java/org/cloudsimplus/examples/schedulers/VmSchedulerTimeSharedExample.java @@ -139,7 +139,7 @@ private VmSchedulerTimeSharedExample() { hostList.forEach(this::printHostStateHistory); for (final var vm : vmList) { - System.out.printf("%s: Requested MIPS: %.0f Allocated MIPS: %.0f%n", vm, vm.getCurrentRequestedMips(), vm.getMips()); + System.out.printf("%s: Requested MIPS: %.0f Allocated MIPS: %.0f%n", vm, vm.getCurrentRequestedMips().totalMips(), vm.getMips()); } } 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 6ff1d1c..d7ff36d 100755 --- a/src/main/java/org/cloudsimplus/examples/schedulers/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/schedulers/package-info.java @@ -7,4 +7,7 @@ * * @author Manoel Campos da Silva Filho */ +@NullMarked package org.cloudsimplus.examples.schedulers; + +import org.jspecify.annotations.NullMarked; 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 7db0e3f..1052255 100755 --- a/src/main/java/org/cloudsimplus/examples/simulationstatus/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/simulationstatus/package-info.java @@ -4,4 +4,7 @@ * * @author Manoel Campos da Silva Filho */ +@NullMarked package org.cloudsimplus.examples.simulationstatus; + +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/cloudsimplus/examples/sla/package-info.java b/src/main/java/org/cloudsimplus/examples/sla/package-info.java new file mode 100644 index 0000000..fb7742c --- /dev/null +++ b/src/main/java/org/cloudsimplus/examples/sla/package-info.java @@ -0,0 +1,27 @@ +/* + * 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 . + */ +@NullMarked +package org.cloudsimplus.examples.sla; + +import org.jspecify.annotations.NullMarked; 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 4110562..0e7f196 100755 --- a/src/main/java/org/cloudsimplus/examples/synchronous/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/synchronous/package-info.java @@ -10,4 +10,7 @@ * @author Pawel Koperek * @author Manoel Campos da Silva Filho */ +@NullMarked package org.cloudsimplus.examples.synchronous; + +import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/cloudsimplus/examples/traces/SwfWorkloadFormatExample1.java b/src/main/java/org/cloudsimplus/examples/traces/SwfWorkloadFormatExample1.java index 9bc6741..633d76a 100755 --- a/src/main/java/org/cloudsimplus/examples/traces/SwfWorkloadFormatExample1.java +++ b/src/main/java/org/cloudsimplus/examples/traces/SwfWorkloadFormatExample1.java @@ -104,10 +104,9 @@ public class SwfWorkloadFormatExample1 { private static final int VM_RAM = 1000; private static final long VM_BW = 50000; - private List cloudletList; - private List vmlist; - private Datacenter datacenter0; - private DatacenterBroker broker; + private final List cloudletList = new ArrayList<>(); + private final List vmlist = new ArrayList<>(); + private final DatacenterBroker broker; /** * Creates main() to run this example. @@ -130,16 +129,16 @@ private SwfWorkloadFormatExample1() { System.out.printf("Simulation started at %s%n%n", LocalTime.now()); simulation = new CloudSimPlus(); + broker = new DatacenterBrokerSimple(simulation); try { - broker = new DatacenterBrokerSimple(simulation); - /*Vms and cloudlets are created before the Datacenter and host because the example is creating: (i) hosts based on VM requirements; (ii) VMs based on cloudlet requirements.*/ createCloudletsFromWorkloadFile(); createVms(); - datacenter0 = createDatacenter(); + @SuppressWarnings("unused") + final var datacenter0 = createDatacenter(); broker.submitVmList(vmlist); broker.submitCloudletList(cloudletList); @@ -184,7 +183,6 @@ private void createVms() { * It's used to reduce the number of VMs to create. */ final int totalVms = (int)Math.ceil(totalCloudletPes / (VM_PES*6)); - vmlist = new ArrayList<>(); for (int i = 0; i < totalVms; i++) { final var vm = new VmSimple(VM_MIPS, VM_PES) .setRam(VM_RAM).setBw(VM_BW).setSize(VM_SIZE) @@ -198,7 +196,7 @@ private void createVms() { private void createCloudletsFromWorkloadFile() { final var reader = SwfWorkloadFileReader.getInstance(WORKLOAD_FILENAME, VM_MIPS); reader.setMaxLinesToRead(maxCloudletsToCreateFromWorkloadFile); - this.cloudletList = reader.generateWorkload(); + this.cloudletList.addAll(reader.generateWorkload()); System.out.printf("# Created %12d Cloudlets for %s%n", this.cloudletList.size(), broker); } diff --git a/src/main/java/org/cloudsimplus/examples/traces/google/package-info.java b/src/main/java/org/cloudsimplus/examples/traces/google/package-info.java new file mode 100644 index 0000000..7438fd8 --- /dev/null +++ b/src/main/java/org/cloudsimplus/examples/traces/google/package-info.java @@ -0,0 +1,27 @@ +/* + * 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 . + */ +@NullMarked +package org.cloudsimplus.examples.traces.google; + +import org.jspecify.annotations.NullMarked; 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 f9a4015..f47bbea 100755 --- a/src/main/java/org/cloudsimplus/examples/traces/package-info.java +++ b/src/main/java/org/cloudsimplus/examples/traces/package-info.java @@ -3,4 +3,7 @@ * * @author Manoel Campos da Silva Filho */ +@NullMarked package org.cloudsimplus.examples.traces; + +import org.jspecify.annotations.NullMarked;