Skip to content

Close #28 #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 25, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
runs-on: ubuntu-20.04
name: Java 17 Build
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 17
cache: 'maven'
- name: Maven Build
run: mvn -B package
run: mvn -B package
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
The module version defines the version of CloudSim Plus to be used.
This way, it cannot be a version number which doesn't exist for CloudSim Plus.
-->
<version>8.5.1</version>
<version>8.5.4</version>

<name>CloudSim Plus Examples</name>
<description>
Expand Down Expand Up @@ -53,6 +53,8 @@
<license-maven-plugin.version>3.0</license-maven-plugin.version>
<!-- License file to be used by the com.mycila.license-maven-plugin -->
<copyrightfile>../COPYRIGHT</copyrightfile>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
* 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 <b>static computed utilization threshold</b>.
* according to a <b>statically computed utilization threshold</b>.
* Then it requests the RAM to be scaled up.</p>
*
* <p>The example uses the CloudSim Plus {@link EventListener} feature
Expand Down Expand Up @@ -107,12 +107,21 @@ public class VerticalVmRamScalingExample {

private static final int HOST_MIPS = 1000;
private static final int VMS = 1;

/**
* 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)
*/
private static final double VM_RAM_SCALING_FACTOR = 0.1;

private final CloudSimPlus simulation;
private final DatacenterBroker broker0;
private final List<Host> hostList;
Expand Down Expand Up @@ -165,13 +174,13 @@ private VerticalVmRamScalingExample() {
printSimulationResults();
}

private void onClockTickListener(EventInfo event) {
private void onClockTickListener(final EventInfo event) {
for (final var vm : vmList) {
System.out.printf("\t\tTime %6.1f: Vm %d Ram Usage: %6.2f%% (%4d of %4d MB)",
event.getTime(), vm.getId(), vm.getRam().getPercentUtilization() * 100.0,
vm.getRam().getAllocatedResource(), vm.getRam().getCapacity());

System.out.printf(" | Host Ram Allocation: %6.2f%% (%5d of %5d MB). Running Cloudlets: %d",
System.out.printf(" | Host Ram Allocation: %6.2f%% (%5d of %5d MB). Running Cloudlets: %d%n",
vm.getHost().getRam().getPercentUtilization() * 100,
vm.getHost().getRam().getAllocatedResource(),
vm.getHost().getRam().getCapacity(), vm.getCloudletScheduler().getCloudletExecList().size());
Expand Down Expand Up @@ -239,15 +248,17 @@ private Vm createVm() {
* @param vm the VM in which the VerticalVmScaling will be created
* @see #createListOfScalableVms(int)
*/
private void createVerticalRamScalingForVm(Vm vm) {
var verticalRamScaling = new VerticalVmScalingSimple(Ram.class, 0.1);
private void createVerticalRamScalingForVm(final Vm vm) {
final var verticalRamScaling = new VerticalVmScalingSimple(Ram.class, VM_RAM_SCALING_FACTOR);

/* By uncommenting the line below, you will see that, instead of gradually
* increasing or decreasing the RAM when the scaling object detects
* the RAM usage is up or down the defined thresholds,
* it will automatically calculate the amount of RAM to add/remove to
* move the VM from the over or under-load condition.
*/
//verticalRamScaling.setResourceScaling(new ResourceScalingInstantaneous());

verticalRamScaling.setLowerThresholdFunction(this::lowerRamUtilizationThreshold)
.setUpperThresholdFunction(this::upperRamUtilizationThreshold);
vm.setRamVerticalScaling(verticalRamScaling);
Expand All @@ -264,7 +275,7 @@ private void createVerticalRamScalingForVm(Vm vm) {
* threshold is applied for any Vm.
* @return the lower RAM utilization threshold
*/
private double lowerRamUtilizationThreshold(Vm vm) {
private double lowerRamUtilizationThreshold(final Vm vm) {
return 0.5;
}

Expand All @@ -279,20 +290,23 @@ private double lowerRamUtilizationThreshold(Vm vm) {
* threshold is applied for any Vm.
* @return the upper RAM utilization threshold
*/
private double upperRamUtilizationThreshold(Vm vm) {
private double upperRamUtilizationThreshold(final Vm vm) {
return 0.7;
}

private void createCloudletList() {
final int initialRamUtilization1 = 100; //MB

// A constant RAM utilization model
final var ramModel1 = new UtilizationModelDynamic(Unit.ABSOLUTE, initialRamUtilization1);
for (long length: CLOUDLET_LENGTHS) {
cloudletList.add(createCloudlet(ramModel1, length));
}

final int initialRamUtilization2 = 10; //MB
final int maxRamUtilization = 500; //MB

// An increasing RAM utilization model
final var ramModel2 = new UtilizationModelDynamic(Unit.ABSOLUTE, initialRamUtilization2);
ramModel2
.setMaxResourceUtilization(maxRamUtilization)
Expand Down Expand Up @@ -322,7 +336,7 @@ private Cloudlet createCloudlet(final UtilizationModel ramUtilizationModel, fina
* @param um the Utilization Model that has called this function
* @return the new resource utilization after the increment
*/
private double utilizationIncrement(UtilizationModelDynamic um) {
private double utilizationIncrement(final UtilizationModelDynamic um) {
final int ramIncreaseMB = 10;
return um.getUtilization() + um.getTimeSpan() * ramIncreaseMB;
}
Expand Down
Loading