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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -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
51 changes: 51 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
</issueManagement>

<properties>
<errorprone.version>2.50.0</errorprone.version>
<nullaway.version>0.14.2</nullaway.version>
<jspecify.version>1.0.0</jspecify.version>
<!-- Error Prone arguments (see maven-compiler-plugin). -->
<errorprone.args>-XepDisableWarningsInGeneratedCode -XepExcludedPaths:.*/target/generated-sources/.* -Xep:StringConcatToTextBlock:OFF</errorprone.args>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<license-maven-plugin.version>5.0.0</license-maven-plugin.version>
<!-- License file to be used by the com.mycila.license-maven-plugin -->
Expand All @@ -63,6 +68,42 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<!--
Error Prone: Google's static analyzer that runs as a javac plugin,
finding common mistakes at compile time.
It is also the base to run NullAway.
StringConcatToTextBlock is disabled because it crashes on some string concatenations.
Requires the options in .mvn/jvm.config to work on JDK 16+.
https://errorprone.info
-->
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>${errorprone.version}</version>
</path>
<path>
<!--
NullAway: Error Prone check that fails the build when a value
that may be null is used without a check, avoiding NullPointerException.
Just packages annotated with JSpecify @NullMarked (see package-info.java files) are checked.
Inside them, everything is considered non-null by default, unless annotated with @Nullable.
This way, classes from dependencies (such as CloudSim Plus) are considered unannotated.
https://github.com/uber/NullAway
-->
<groupId>com.uber.nullaway</groupId>
<artifactId>nullaway</artifactId>
<version>${nullaway.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<!-- Error Prone and NullAway settings (see the comments in annotationProcessorPaths above). -->
<arg>-XDcompilePolicy=simple</arg>
<arg>--should-stop=ifError=FLOW</arg>
<arg>-Xplugin:ErrorProne ${errorprone.args} -Xep:NullAway:ERROR -XepOpt:NullAway:OnlyNullMarked=true</arg>
</compilerArgs>
</configuration>
</plugin>

<plugin>
Expand Down Expand Up @@ -152,5 +193,15 @@
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<!--
JSpecify annotations (such as @Nullable) to indicate values that may be null.
They are checked by NullAway at compile time.
https://jspecify.dev
-->
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
<version>${jspecify.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@NullMarked
package org.cloudbus.cloudsim.examples.network.applications;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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<Host> hostList;
private final List<Host> hostList = new ArrayList<>();

private static final int VMS_BY_BROKER = 2;
private static final int VM_PES = 2; //number of cpus
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -327,8 +326,8 @@ private List<Cloudlet> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Cloudlet> cloudletList;
private List<Vm> vmList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
*
* @author Manoel Campos da Silva Filho
*/
@NullMarked
package org.cloudsimplus.examples.autoscaling;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
*
* @author Manoel Campos da Silva Filho
*/
@NullMarked
package org.cloudsimplus.examples.brokers;

import org.jspecify.annotations.NullMarked;
27 changes: 27 additions & 0 deletions src/main/java/org/cloudsimplus/examples/costs/package-info.java
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
@NullMarked
package org.cloudsimplus.examples.costs;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public final class DynamicVmAllocationPolicyBestFitExample {
private final List<Vm> vmList = new ArrayList<>();

private CloudSimPlus simulation;
private List<Host> hostList;
private final List<Host> hostList = new ArrayList<>();

public static void main(String[] args) {
new DynamicVmAllocationPolicyBestFitExample();
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
*
* @author Manoel Campos da Silva Filho
*/
@NullMarked
package org.cloudsimplus.examples.dynamic;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
*
* @author Manoel Campos da Silva Filho
*/
@NullMarked
package org.cloudsimplus.examples.listeners;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public final class ManualMigrationExample1 {
private final Datacenter datacenter0;

private CloudSimPlus simulation;
private List<Host> hostList;
private final List<Host> hostList = new ArrayList<>();
private boolean migrationRequested;
private int migrationsNumber;

Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ public final class MigrationExample1 {
private final DatacenterBrokerSimple broker;

private final CloudSimPlus simulation;
private VmAllocationPolicyMigrationStaticThreshold allocationPolicy;
private List<Host> hostList;
private final VmAllocationPolicyMigrationStaticThreshold allocationPolicy;
private final List<Host> hostList;
private int migrationsNumber = 0;

public static void main(String[] args) {
Expand All @@ -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);
Expand Down Expand Up @@ -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(
Expand All @@ -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<Host> createHosts() {
final var hostList = new ArrayList<Host>(HOST_PES.length);
for (int i = 0; i < HOST_PES.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
*
* @author Manoel Campos da Silva Filho
*/
@NullMarked
package org.cloudsimplus.examples.migration;

import org.jspecify.annotations.NullMarked;
27 changes: 27 additions & 0 deletions src/main/java/org/cloudsimplus/examples/package-info.java
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
@NullMarked
package org.cloudsimplus.examples;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -127,7 +128,12 @@ public class UtilizationModelStochasticPerformance {
private List<Vm> vmList;
private List<Cloudlet> 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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
@NullMarked
package org.cloudsimplus.examples.performance;

import org.jspecify.annotations.NullMarked;
Loading
Loading