@@ -114,6 +114,14 @@ public class VerticalVmRamScalingExample {
114114 private static final int VM_RAM = 1000 ;
115115 private static final int VM_PES = 5 ;
116116 private static final int VM_MIPS = 1000 ;
117+
118+ /**
119+ * The percentage (in scale from 0 to 1) to scale VM RAM capacity up/down
120+ * when it becomes under/overloaded.
121+ * @see #createVerticalRamScalingForVm(Vm)
122+ */
123+ private static final double VM_RAM_SCALING_FACTOR = 0.1 ;
124+
117125 private final CloudSimPlus simulation ;
118126 private final DatacenterBroker broker0 ;
119127 private final List <Host > hostList ;
@@ -172,7 +180,7 @@ private void onClockTickListener(final EventInfo event) {
172180 event .getTime (), vm .getId (), vm .getRam ().getPercentUtilization () * 100.0 ,
173181 vm .getRam ().getAllocatedResource (), vm .getRam ().getCapacity ());
174182
175- System .out .printf (" | Host Ram Allocation: %6.2f%% (%5d of %5d MB). Running Cloudlets: %d" ,
183+ System .out .printf (" | Host Ram Allocation: %6.2f%% (%5d of %5d MB). Running Cloudlets: %d%n " ,
176184 vm .getHost ().getRam ().getPercentUtilization () * 100 ,
177185 vm .getHost ().getRam ().getAllocatedResource (),
178186 vm .getHost ().getRam ().getCapacity (), vm .getCloudletScheduler ().getCloudletExecList ().size ());
@@ -241,14 +249,16 @@ private Vm createVm() {
241249 * @see #createListOfScalableVms(int)
242250 */
243251 private void createVerticalRamScalingForVm (final Vm vm ) {
244- final var verticalRamScaling = new VerticalVmScalingSimple (Ram .class , 0.1 );
252+ final var verticalRamScaling = new VerticalVmScalingSimple (Ram .class , VM_RAM_SCALING_FACTOR );
253+
245254 /* By uncommenting the line below, you will see that, instead of gradually
246255 * increasing or decreasing the RAM when the scaling object detects
247256 * the RAM usage is up or down the defined thresholds,
248257 * it will automatically calculate the amount of RAM to add/remove to
249258 * move the VM from the over or under-load condition.
250259 */
251260 //verticalRamScaling.setResourceScaling(new ResourceScalingInstantaneous());
261+
252262 verticalRamScaling .setLowerThresholdFunction (this ::lowerRamUtilizationThreshold )
253263 .setUpperThresholdFunction (this ::upperRamUtilizationThreshold );
254264 vm .setRamVerticalScaling (verticalRamScaling );
@@ -287,13 +297,16 @@ private double upperRamUtilizationThreshold(final Vm vm) {
287297 private void createCloudletList () {
288298 final int initialRamUtilization1 = 100 ; //MB
289299
300+ // A constant RAM utilization model
290301 final var ramModel1 = new UtilizationModelDynamic (Unit .ABSOLUTE , initialRamUtilization1 );
291302 for (long length : CLOUDLET_LENGTHS ) {
292303 cloudletList .add (createCloudlet (ramModel1 , length ));
293304 }
294305
295306 final int initialRamUtilization2 = 10 ; //MB
296307 final int maxRamUtilization = 500 ; //MB
308+
309+ // An increasing RAM utilization model
297310 final var ramModel2 = new UtilizationModelDynamic (Unit .ABSOLUTE , initialRamUtilization2 );
298311 ramModel2
299312 .setMaxResourceUtilization (maxRamUtilization )
0 commit comments