Skip to content

Commit b43dbc0

Browse files
committed
VirtualMemoryForRequestedRamHigherThanAvailableExample refactoring
Signed-off-by: Manoel Campos <[email protected]>
1 parent ffabaeb commit b43dbc0

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/main/java/org/cloudsimplus/examples/resourceusage/VirtualMemoryForRequestedRamHigherThanAvailableExample.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,24 @@ public class VirtualMemoryForRequestedRamHigherThanAvailableExample {
107107
* As slower is the reading speed, higher is the memory swapping overhead
108108
* and the increase in cloudlet processing (exec) time.
109109
*/
110-
private static final int HOSTS_MAX_TRANSFER_RATE = 1600;
111-
private static final long HOST_RAM = 20480; //in Megabytes
110+
private static final int HOSTS_MAX_TRANSFER_RATE = 1_600;
111+
private static final long HOST_RAM = 20_480; //in Megabytes
112112

113113
private static final int HOSTS = 2;
114114
private static final int HOST_PES = 8;
115+
private static final int HOST_MIPS = 1_000;
116+
115117

116118
private static final int VMS = 3;
117119
private static final int VM_PES = 2;
118-
119-
private static final int CLOUDLET_PES = 1;
120-
private static final int CLOUDLET_LENGTH = 10000;
121-
120+
private static final int VM_MIPS = 1_000;
122121
/**
123122
* VM RAM capacity (in MB)
124123
*/
125-
public static final int VM_RAM = 10000;
124+
private static final int VM_RAM = 10_000;
125+
126+
private static final int CLOUDLET_PES = 1;
127+
private static final int CLOUDLET_LENGTH = 10_000;
126128

127129
private final CloudSimPlus simulation;
128130
private final DatacenterBroker broker0;
@@ -164,7 +166,7 @@ private VirtualMemoryForRequestedRamHigherThanAvailableExample() {
164166
}
165167

166168
private void printOverSubscriptionDelay() {
167-
final String format = "%s exec time: %6.2f | RAM/BW over-subscription delay: %6.2f secs | Expected finish time (if no over-subscription): %6.2f secs%n";
169+
final String format = "%s exec time: %6.1f | RAM/BW over-subscription delay: %6.1f secs | Expected finish time (if no over-subscription): %6.1f secs%n";
168170
for (final var vm : vmList) {
169171
vm.getCloudletScheduler()
170172
.getCloudletFinishedList()
@@ -224,11 +226,11 @@ private Host createHost() {
224226
//List of Host's CPUs (Processing Elements, PEs)
225227
for (int i = 0; i < HOST_PES; i++) {
226228
//Uses a PeProvisionerSimple by default to provision PEs for VMs
227-
peList.add(new PeSimple(1000));
229+
peList.add(new PeSimple(HOST_MIPS));
228230
}
229231

230232
final long bw = 10000; //in Megabits/s
231-
final long storageSize = 1000000; //in Megabytes
233+
final long storageSize = 1_000_000; //in Megabytes
232234
final var hardDrive = new HarddriveStorage(storageSize);
233235
hardDrive.setAvgSeekTime(0).setLatency(0).setMaxTransferRate(HOSTS_MAX_TRANSFER_RATE);
234236

@@ -246,7 +248,7 @@ private List<Vm> createVms() {
246248
final var newVmList = new ArrayList<Vm>(VMS);
247249
for (int i = 0; i < VMS; i++) {
248250
//Uses a CloudletSchedulerTimeShared by default to schedule Cloudlets
249-
final Vm vm = new VmSimple(1000, VM_PES);
251+
final Vm vm = new VmSimple(VM_MIPS, VM_PES);
250252
vm.setRam(VM_RAM).setBw(1000).setSize(10000);
251253
newVmList.add(vm);
252254
}

0 commit comments

Comments
 (0)