|
34 | 34 | import org.cloudsimplus.cloudlets.CloudletSimple; |
35 | 35 | import org.cloudsimplus.core.CloudSimPlus; |
36 | 36 | import org.cloudsimplus.datacenters.Datacenter; |
| 37 | +import org.cloudsimplus.datacenters.DatacenterCharacteristics; |
| 38 | +import org.cloudsimplus.datacenters.DatacenterCharacteristics.Distribution; |
37 | 39 | import org.cloudsimplus.datacenters.DatacenterSimple; |
38 | 40 | import org.cloudsimplus.hosts.Host; |
39 | 41 | import org.cloudsimplus.hosts.HostSimple; |
@@ -293,8 +295,8 @@ private void printResults() { |
293 | 295 | new CloudletsTableBuilder(cloudletFinishedList).setTitle(broker.toString()).build(); |
294 | 296 | } |
295 | 297 |
|
296 | | - System.out.printf("%nNumber of VM migrations: %d%n", migrationsNumber); |
297 | 298 | printHostStateHistory(); |
| 299 | + System.out.printf("%nNumber of VM migrations: %d%n", migrationsNumber); |
298 | 300 | } |
299 | 301 |
|
300 | 302 | private void printHostStateHistory() { |
@@ -327,12 +329,18 @@ private void createVmsAndCloudlets() { |
327 | 329 | * setting the allocation policy to the default value |
328 | 330 | * so that some Hosts will be overloaded with the placed VMs and migration will be fired. |
329 | 331 | * |
330 | | - * The listener is removed after finishing, so that it's called just once, |
331 | | - * even if new VMs are submitted and created latter on. |
| 332 | + * <p>The listener is removed after finishing, so that it's called just once, |
| 333 | + * even if new VMs are submitted and created later on.</p> |
332 | 334 | */ |
333 | 335 | private void onVmsCreatedListener(final DatacenterBrokerEventInfo info) { |
334 | 336 | final var broker = info.getDatacenterBroker(); |
335 | | - System.out.printf("# All %d VMs submitted to %s have been created.%n", broker.getVmCreatedList().size(), broker); |
| 337 | + final String vmIds = broker.getVmCreatedList() |
| 338 | + .stream() |
| 339 | + .mapToLong(Vm::getId) |
| 340 | + .mapToObj(Long::toString) |
| 341 | + .collect(joining(", ")); |
| 342 | + |
| 343 | + System.out.printf("# %d VMs submitted to %s have been created. VMs: %s.%n", broker.getVmCreatedList().size(), broker, vmIds); |
336 | 344 | datacenterList.stream() |
337 | 345 | .map(dc -> (VmAllocationPolicyMigrationFirstFitStaticThreshold)dc.getVmAllocationPolicy()) |
338 | 346 | .forEach(policy -> policy.setOverUtilizationThreshold(HOST_OVER_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION)); |
@@ -442,18 +450,27 @@ private List<Datacenter> createDatacenters() { |
442 | 450 | return IntStream.range(0, datacentersNumber).mapToObj(this::createDatacenter).toList(); |
443 | 451 | } |
444 | 452 |
|
| 453 | + /** |
| 454 | + * Create a private-cloud Datacenter for even indexes and public-cloud one for odd indexes. |
| 455 | + * @param index the Datacenter index |
| 456 | + * @return the created Datacenter |
| 457 | + * @see DatacenterCharacteristics.Distribution |
| 458 | + */ |
445 | 459 | private Datacenter createDatacenter(final int index) { |
| 460 | + final var distribution = index % 2 == 0 ? Distribution.PRIVATE : Distribution.PUBLIC; |
446 | 461 | final var hostList = createHosts(DC_HOST_PES[index]); |
447 | 462 | final var allocationPolicy = createVmAllocationPolicy(); |
448 | 463 | final var dc = new DatacenterSimple(simulation, hostList, allocationPolicy); |
449 | 464 | dc.setSchedulingInterval(SCHEDULING_INTERVAL) |
450 | | - .setHostSearchRetryDelay(HOST_SEARCH_RETRY_DELAY); |
| 465 | + .setHostSearchRetryDelay(HOST_SEARCH_RETRY_DELAY) |
| 466 | + .getCharacteristics() |
| 467 | + .setDistribution(distribution); |
451 | 468 |
|
452 | 469 | final String hostsStr = |
453 | 470 | hostList.stream() |
454 | 471 | .map(host -> String.format("Host %d w/ %d PEs", host.getId(), host.getPesNumber())) |
455 | 472 | .collect(joining(", ")); |
456 | | - System.out.printf("%s: %s%n", dc, hostsStr); |
| 473 | + System.out.printf("%7s-cloud %s: %s%n", distribution, dc, hostsStr); |
457 | 474 | return dc; |
458 | 475 | } |
459 | 476 |
|
|
0 commit comments