@@ -114,6 +114,14 @@ public class VerticalVmRamScalingExample {
114
114
private static final int VM_RAM = 1000 ;
115
115
private static final int VM_PES = 5 ;
116
116
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
+
117
125
private final CloudSimPlus simulation ;
118
126
private final DatacenterBroker broker0 ;
119
127
private final List <Host > hostList ;
@@ -172,7 +180,7 @@ private void onClockTickListener(final EventInfo event) {
172
180
event .getTime (), vm .getId (), vm .getRam ().getPercentUtilization () * 100.0 ,
173
181
vm .getRam ().getAllocatedResource (), vm .getRam ().getCapacity ());
174
182
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 " ,
176
184
vm .getHost ().getRam ().getPercentUtilization () * 100 ,
177
185
vm .getHost ().getRam ().getAllocatedResource (),
178
186
vm .getHost ().getRam ().getCapacity (), vm .getCloudletScheduler ().getCloudletExecList ().size ());
@@ -241,14 +249,16 @@ private Vm createVm() {
241
249
* @see #createListOfScalableVms(int)
242
250
*/
243
251
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
+
245
254
/* By uncommenting the line below, you will see that, instead of gradually
246
255
* increasing or decreasing the RAM when the scaling object detects
247
256
* the RAM usage is up or down the defined thresholds,
248
257
* it will automatically calculate the amount of RAM to add/remove to
249
258
* move the VM from the over or under-load condition.
250
259
*/
251
260
//verticalRamScaling.setResourceScaling(new ResourceScalingInstantaneous());
261
+
252
262
verticalRamScaling .setLowerThresholdFunction (this ::lowerRamUtilizationThreshold )
253
263
.setUpperThresholdFunction (this ::upperRamUtilizationThreshold );
254
264
vm .setRamVerticalScaling (verticalRamScaling );
@@ -287,13 +297,16 @@ private double upperRamUtilizationThreshold(final Vm vm) {
287
297
private void createCloudletList () {
288
298
final int initialRamUtilization1 = 100 ; //MB
289
299
300
+ // A constant RAM utilization model
290
301
final var ramModel1 = new UtilizationModelDynamic (Unit .ABSOLUTE , initialRamUtilization1 );
291
302
for (long length : CLOUDLET_LENGTHS ) {
292
303
cloudletList .add (createCloudlet (ramModel1 , length ));
293
304
}
294
305
295
306
final int initialRamUtilization2 = 10 ; //MB
296
307
final int maxRamUtilization = 500 ; //MB
308
+
309
+ // An increasing RAM utilization model
297
310
final var ramModel2 = new UtilizationModelDynamic (Unit .ABSOLUTE , initialRamUtilization2 );
298
311
ramModel2
299
312
.setMaxResourceUtilization (maxRamUtilization )
0 commit comments