/** * Prints a list of debts generated on each of the simulated datacenters. * * @param datacentersList a list of datacenters. */ private void printDebts(List<PowerDatacenter> datacentersList) { Log.printLine(); Log.print("========== Datacenters' Debts ==========\n"); for(PowerDatacenter datacenter : datacentersList) { datacenter.printDebts(); Log.print("\n"); } }
/** * Gets the output stream. * * @return the output */ public static OutputStream getOutput() { if (output == null) { setOutput(System.out); } return output; }
/** * Prints a message and a new line. * * @param message the message */ public static void printLine(String message) { if (!isDisabled()) { print(message + LINE_SEPARATOR); } }
/** * Prints the message passed as a non-String object and a new line. * * @param message the message */ public static void printLine(Object message) { if (!isDisabled()) { printLine(String.valueOf(message)); } }
/** * Prints the over utilized hosts. * * @param overUtilizedHosts the over utilized hosts */ protected void printOverUtilizedHosts(List<PowerContainerHostUtilizationHistory> overUtilizedHosts) { if (!Log.isDisabled()) { Log.printLine("Over-utilized hosts:"); for (PowerContainerHostUtilizationHistory host : overUtilizedHosts) { Log.printConcatLine("Host #", host.getId()); } Log.printLine(); } }
Log.printConcatLine("Under-utilized host: host #", underUtilizedHost.getId(), "\n"); Log.print("Reallocation of Containers from the under-utilized host: "); if (!Log.isDisabled()) { for (ContainerVm vm : vmsToMigrateFromUnderUtilizedHost) { Log.print(vm.getId() + " "); Log.printLine(); Log.printLine();
/** * Prints a message about the progress of the simulation. * * @param message the message */ private static void printMessage(String message) { Log.printLine(message); }
Log.printLine("\n\n--------------------------------------------------------------\n\n"); Log.formatLine("New resource usage for the time frame starting at %.2f:", currentTime); Log.printLine(); Log.formatLine( "%.2f: [Host #%d] utilization is %.2f%%", currentTime, Log.formatLine( "\nEnergy consumption for the last time frame from %.2f to %.2f:", getLastProcessTime(), Log.printLine(); Log.formatLine( "%.2f: [Host #%d] utilization at %.2f was %.2f%%, now is %.2f%%", currentTime, previousUtilizationOfCpu * 100, utilizationOfCpu * 100); Log.formatLine( "%.2f: [Host #%d] energy is %.2f W*sec", currentTime, Log.formatLine( "\n%.2f: Data center's energy is %.2f W*sec\n", currentTime, getVmAllocationPolicy().deallocateHostForVm(vm);
/** * Runs all simulations of a specific environment. * It creates all CloudSim entities, runs the simulation and generates the * report. This cycle is repeated the number of times indicated by the * NumberOfSimulations setting. * * @since 1.0 */ private void runAllSimulations() { RemovePreviousReports(); isMailNotificationEnabled = SettingBusiness.isMailNotificationEnabled(); int numberOfSimulations = SettingBusiness.getNumberOfSimulations(); for (int simulationId = 1; simulationId <= numberOfSimulations; simulationId++) { SettingBusiness.setCurrentSimulation(simulationId); MainView.getSimulationView().setBarLabel("Simulation " + simulationId + " of " + HibernateUtil.getActiveDatabase() + " is in progress..."); Log.setOutput(LogIO.getFileOutputStream()); Log.printLine("CloudReports version 1.1"); Log.print("Verifying available resources..."); ResetCustomersTimeToSend(); if (Verification.verifyVMsDeploymentViability()) { runSimulation(simulationId); } else { Dialog.showErrorMessage(null, "Simulation aborted:\nSome of the virtual machines cannot be deployed by any available host."); MainView.getSimulationView().dispose(); break; } LogIO.removeTempLogFile(); } }
Log.printLine("\n\n--------------------------------------------------------------\n\n"); Log.formatLine("Power data center: New resource usage for the time frame starting at %.2f:", currentTime); Log.printLine(); Log.formatLine( "%.2f: [Host #%d] utilization is %.2f%%", currentTime, Log.formatLine( "\nEnergy consumption for the last time frame from %.2f to %.2f:", getLastProcessTime(), Log.printLine(); Log.formatLine( "%.2f: [Host #%d] utilization at %.2f was %.2f%%, now is %.2f%%", currentTime, previousUtilizationOfCpu * 100, utilizationOfCpu * 100); Log.formatLine( "%.2f: [Host #%d] energy is %.2f W*sec", currentTime, Log.formatLine( "\n%.2f: Data center's energy is %.2f W*sec\n", currentTime, getVmAllocationPolicy().deallocateHostForVm(vm);
boolean outputInCsv, String outputFolder) { Log.enable(); List<Host> hosts = datacenter.getHostList(); Log.setDisabled(false); Log.printLine(); Log.printLine(String.format("Experiment name: " + experimentName)); Log.printLine(String.format("Number of hosts: " + numberOfHosts)); Log.printLine(String.format("Number of VMs: " + numberOfVms)); Log.printLine(String.format("Total simulation time: %.2f sec", totalSimulationTime)); Log.printLine(String.format("Energy consumption: %.2f kWh", energy)); Log.printLine(String.format("Number of VM migrations: %d", numberOfMigrations)); Log.printLine(String.format("SLA: %.5f%%", sla * 100)); Log.printLine(String.format( "SLA perf degradation due to migration: %.2f%%", slaDegradationDueToMigration * 100)); Log.printLine(String.format("SLA time per active host: %.2f%%", slaTimePerActiveHost * 100)); Log.printLine(String.format("Overall SLA violation: %.2f%%", slaOverall * 100)); Log.printLine(String.format("Average SLA violation: %.2f%%", slaAverage * 100)); Log.printLine(String.format("Number of host shutdowns: %d", numberOfHostShutdowns)); Log.printLine(String.format( "Mean time before a host shutdown: %.2f sec", meanTimeBeforeHostShutdown)); Log.printLine(String.format( "StDev time before a host shutdown: %.2f sec", stDevTimeBeforeHostShutdown)); Log.printLine(String.format(
/** * Creates the network topology if the file exists and can be successfully parsed. File is * written in the BRITE format and contains topological information on simulation entities. * * @param fileName name of the BRITE file * @pre fileName != null * @post $none */ public static void buildNetworkTopology(String fileName) { Log.printConcatLine("Topology file: ", fileName); // try to find the file GraphReaderBrite reader = new GraphReaderBrite(); try { graph = reader.readGraphFile(fileName); map = new HashMap<Integer, Integer>(); generateMatrices(); } catch (IOException e) { // problem with the file. Does not simulate network Log.printLine("Problem in processing BRITE file. Network simulation is disabled. Error: " + e.getMessage()); } }
String parameter) throws IOException, FileNotFoundException { setEnableOutput(enableOutput); Log.setDisabled(!isEnableOutput()); if (isEnableOutput() && outputToFile) { File folder = new File(outputFolder); + getExperimentName(workload, vmAllocationPolicy, vmSelectionPolicy, parameter) + ".txt"); file.createNewFile(); Log.setOutput(new FileOutputStream(file));
.getPath(); Log.setDisabled(!Constants.ENABLE_OUTPUT); Log.printLine("Starting " + experimentName); Log.printLine("Received " + newList.size() + " cloudlets"); Log.printLine("The simulation has been terminated due to an unexpected error"); System.exit(0); Log.printLine("Finished " + experimentName);
@Override public ContainerVm getContainerVm(List<ContainerVm> vmList, Object obj, Set<? extends ContainerVm> excludedVmList) { ContainerVm containerVm = null; while (true) { if (vmList.size() > 0) { int randomNum = new RandomGen().getNum(vmList.size()); containerVm = vmList.get(randomNum); if (excludedVmList.contains(containerVm)) { continue; } } else { Log.print(String.format("Error: The VM list Size is: %d", vmList.size())); } return containerVm; } } }
@Override public boolean allocateHostForVm(Vm vm, Host host) { if (host == null) { Log.formatLine("%.2f: No suitable host found for VM #" + vm.getId() + "\n", CloudSim.clock()); return false; } if (host.vmCreate(vm)) { // if vm has been succesfully created in the host getVmTable().put(vm.getUid(), host); Log.formatLine( "%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(), CloudSim.clock()); return true; } Log.formatLine( "%.2f: Creation of VM #" + vm.getId() + " on the host #" + host.getId() + " failed\n", CloudSim.clock()); return false; }
/** * Prints the metric history. * * @param hosts the hosts * @param vmAllocationPolicy the vm allocation policy */ public static void printMetricHistory( List<? extends Host> hosts, PowerVmAllocationPolicyMigrationAbstract vmAllocationPolicy) { for (int i = 0; i < 10; i++) { Host host = hosts.get(i); Log.printLine("Host #" + host.getId()); Log.printLine("Time:"); if (!vmAllocationPolicy.getTimeHistory().containsKey(host.getId())) { continue; } for (Double time : vmAllocationPolicy.getTimeHistory().get(host.getId())) { Log.format("%.2f, ", time); } Log.printLine(); for (Double utilization : vmAllocationPolicy.getUtilizationHistory().get(host.getId())) { Log.format("%.2f, ", utilization); } Log.printLine(); for (Double metric : vmAllocationPolicy.getMetricHistory().get(host.getId())) { Log.format("%.2f, ", metric); } Log.printLine(); } }
double totalAllocatedMips = getVmScheduler().getTotalAllocatedMipsForVm(vm); if (!Log.isDisabled()) { Log.formatLine( "%.2f: [Host #" + getId() + "] Total allocated MIPS for VM #" + vm.getId() + " (Host #" + vm.getHost().getId() .getTotalAllocatedMipsForVm(vm))); Log.formatLine( "%.2f: [Host #" + getId() + "] MIPS for VM #" + vm.getId() + " by PEs (" + getNumberOfPes() + " * " + getVmScheduler().getPeCapacity() + ")." Log.formatLine("%.2f: [Host #" + getId() + "] VM #" + vm.getId() + " is being migrated to Host #" + getId(), CloudSim.clock()); } else { if (totalAllocatedMips + 0.1 < totalRequestedMips) { Log.formatLine("%.2f: [Host #" + getId() + "] Under allocated MIPS for VM #" + vm.getId() + ": %.2f", CloudSim.clock(), totalRequestedMips - totalAllocatedMips); Log.formatLine( "%.2f: [Host #" + getId() + "] VM #" + vm.getId() + " is in migration", CloudSim.clock());
if (!host.getVmList().contains(vm)) { if (!host.containerVmCreate(vm)) { Log.printConcatLine("Couldn't restore VM #", vm.getId(), " on host #", host.getId()); System.exit(0); Log.printConcatLine("Couldn't restore Container #", container.getId(), " on vm #", vm.getId()); System.exit(0); Log.print("The Container is in the VM already"); Log.print("The Vm is null");
ContainerVm oldVm = container.getVm(); if (oldVm == null) { Log.formatLine( "%.2f: Migration of Container #%d to Vm #%d is started", currentTime, targetVm.getId()); } else { Log.formatLine( "%.2f: Migration of Container #%d from Vm #%d to VM #%d is started", currentTime, Log.formatLine( "%.2f: Migration of Container #%d to newly created Vm #%d is started", currentTime, Log.formatLine( "%.2f: Migration of Container #%d to newly created Vm #%d is started", currentTime, Log.formatLine( "%.2f: Migration of VM #%d to Host #%d is started", currentTime, targetHost.getId()); } else { Log.formatLine( "%.2f: Migration of VM #%d from Host #%d to Host #%d is started", currentTime,