Commit 4075c6b2 authored by Nikolay's avatar Nikolay

Performance improvement of the Logger. Ubiquitous string concatenation when the…

Performance improvement of the Logger. Ubiquitous string concatenation when the logger is off is now avoided.
parent 5c5c8cd5
...@@ -383,12 +383,12 @@ public class Datacenter extends SimEntity { ...@@ -383,12 +383,12 @@ public class Datacenter extends SimEntity {
status = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId) status = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId)
.getCloudletScheduler().getCloudletStatus(cloudletId); .getCloudletScheduler().getCloudletStatus(cloudletId);
} catch (Exception e) { } catch (Exception e) {
Log.printLine(getName() + ": Error in processing CloudSimTags.CLOUDLET_STATUS"); Log.printConcatLine(getName(), ": Error in processing CloudSimTags.CLOUDLET_STATUS");
Log.printLine(e.getMessage()); Log.printLine(e.getMessage());
return; return;
} }
} catch (Exception e) { } catch (Exception e) {
Log.printLine(getName() + ": Error in processing CloudSimTags.CLOUDLET_STATUS"); Log.printConcatLine(getName(), ": Error in processing CloudSimTags.CLOUDLET_STATUS");
Log.printLine(e.getMessage()); Log.printLine(e.getMessage());
return; return;
} }
...@@ -412,7 +412,7 @@ public class Datacenter extends SimEntity { ...@@ -412,7 +412,7 @@ public class Datacenter extends SimEntity {
*/ */
protected void processOtherEvent(SimEvent ev) { protected void processOtherEvent(SimEvent ev) {
if (ev == null) { if (ev == null) {
Log.printLine(getName() + ".processOtherEvent(): Error - an event is null."); Log.printConcatLine(getName(), ".processOtherEvent(): Error - an event is null.");
} }
} }
...@@ -560,12 +560,12 @@ public class Datacenter extends SimEntity { ...@@ -560,12 +560,12 @@ public class Datacenter extends SimEntity {
userId = cl.getUserId(); userId = cl.getUserId();
vmId = cl.getVmId(); vmId = cl.getVmId();
} catch (Exception e) { } catch (Exception e) {
Log.printLine(super.getName() + ": Error in processing Cloudlet"); Log.printConcatLine(super.getName(), ": Error in processing Cloudlet");
Log.printLine(e.getMessage()); Log.printLine(e.getMessage());
return; return;
} }
} catch (Exception e) { } catch (Exception e) {
Log.printLine(super.getName() + ": Error in processing a Cloudlet."); Log.printConcatLine(super.getName(), ": Error in processing a Cloudlet.");
Log.printLine(e.getMessage()); Log.printLine(e.getMessage());
return; return;
} }
...@@ -685,8 +685,8 @@ public class Datacenter extends SimEntity { ...@@ -685,8 +685,8 @@ public class Datacenter extends SimEntity {
// checks whether this Cloudlet has finished or not // checks whether this Cloudlet has finished or not
if (cl.isFinished()) { if (cl.isFinished()) {
String name = CloudSim.getEntityName(cl.getUserId()); String name = CloudSim.getEntityName(cl.getUserId());
Log.printLine(getName() + ": Warning - Cloudlet #" + cl.getCloudletId() + " owned by " + name Log.printConcatLine(getName(), ": Warning - Cloudlet #", cl.getCloudletId(), " owned by ", name,
+ " is already completed/finished."); " is already completed/finished.");
Log.printLine("Therefore, it is not being executed again"); Log.printLine("Therefore, it is not being executed again");
Log.printLine(); Log.printLine();
...@@ -1015,7 +1015,7 @@ public class Datacenter extends SimEntity { ...@@ -1015,7 +1015,7 @@ public class Datacenter extends SimEntity {
*/ */
@Override @Override
public void shutdownEntity() { public void shutdownEntity() {
Log.printLine(getName() + " is shutting down..."); Log.printConcatLine(getName(), " is shutting down...");
} }
/* /*
...@@ -1024,7 +1024,7 @@ public class Datacenter extends SimEntity { ...@@ -1024,7 +1024,7 @@ public class Datacenter extends SimEntity {
*/ */
@Override @Override
public void startEntity() { public void startEntity() {
Log.printLine(getName() + " is starting..."); Log.printConcatLine(getName(), " is starting...");
// this resource should register to regional GIS. // this resource should register to regional GIS.
// However, if not specified, then register to system GIS (the // However, if not specified, then register to system GIS (the
// default CloudInformationService) entity. // default CloudInformationService) entity.
......
...@@ -200,8 +200,8 @@ public class DatacenterBroker extends SimEntity { ...@@ -200,8 +200,8 @@ public class DatacenterBroker extends SimEntity {
setDatacenterIdsList(CloudSim.getCloudResourceList()); setDatacenterIdsList(CloudSim.getCloudResourceList());
setDatacenterCharacteristicsList(new HashMap<Integer, DatacenterCharacteristics>()); setDatacenterCharacteristicsList(new HashMap<Integer, DatacenterCharacteristics>());
Log.printLine(CloudSim.clock() + ": " + getName() + ": Cloud Resource List received with " Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": Cloud Resource List received with ",
+ getDatacenterIdsList().size() + " resource(s)"); getDatacenterIdsList().size(), " resource(s)");
for (Integer datacenterId : getDatacenterIdsList()) { for (Integer datacenterId : getDatacenterIdsList()) {
sendNow(datacenterId, CloudSimTags.RESOURCE_CHARACTERISTICS, getId()); sendNow(datacenterId, CloudSimTags.RESOURCE_CHARACTERISTICS, getId());
...@@ -224,12 +224,12 @@ public class DatacenterBroker extends SimEntity { ...@@ -224,12 +224,12 @@ public class DatacenterBroker extends SimEntity {
if (result == CloudSimTags.TRUE) { if (result == CloudSimTags.TRUE) {
getVmsToDatacentersMap().put(vmId, datacenterId); getVmsToDatacentersMap().put(vmId, datacenterId);
getVmsCreatedList().add(VmList.getById(getVmList(), vmId)); getVmsCreatedList().add(VmList.getById(getVmList(), vmId));
Log.printLine(CloudSim.clock() + ": " + getName() + ": VM #" + vmId Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": VM #", vmId,
+ " has been created in Datacenter #" + datacenterId + ", Host #" " has been created in Datacenter #", datacenterId, ", Host #",
+ VmList.getById(getVmsCreatedList(), vmId).getHost().getId()); VmList.getById(getVmsCreatedList(), vmId).getHost().getId());
} else { } else {
Log.printLine(CloudSim.clock() + ": " + getName() + ": Creation of VM #" + vmId Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": Creation of VM #", vmId,
+ " failed in Datacenter #" + datacenterId); " failed in Datacenter #", datacenterId);
} }
incrementVmsAcks(); incrementVmsAcks();
...@@ -270,11 +270,11 @@ public class DatacenterBroker extends SimEntity { ...@@ -270,11 +270,11 @@ public class DatacenterBroker extends SimEntity {
protected void processCloudletReturn(SimEvent ev) { protected void processCloudletReturn(SimEvent ev) {
Cloudlet cloudlet = (Cloudlet) ev.getData(); Cloudlet cloudlet = (Cloudlet) ev.getData();
getCloudletReceivedList().add(cloudlet); getCloudletReceivedList().add(cloudlet);
Log.printLine(CloudSim.clock() + ": " + getName() + ": Cloudlet " + cloudlet.getCloudletId() Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": Cloudlet ", cloudlet.getCloudletId(),
+ " received"); " received");
cloudletsSubmitted--; cloudletsSubmitted--;
if (getCloudletList().size() == 0 && cloudletsSubmitted == 0) { // all cloudlets executed if (getCloudletList().size() == 0 && cloudletsSubmitted == 0) { // all cloudlets executed
Log.printLine(CloudSim.clock() + ": " + getName() + ": All Cloudlets executed. Finishing..."); Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": All Cloudlets executed. Finishing...");
clearDatacenters(); clearDatacenters();
finishExecution(); finishExecution();
} else { // some cloudlets haven't finished yet } else { // some cloudlets haven't finished yet
...@@ -298,12 +298,11 @@ public class DatacenterBroker extends SimEntity { ...@@ -298,12 +298,11 @@ public class DatacenterBroker extends SimEntity {
*/ */
protected void processOtherEvent(SimEvent ev) { protected void processOtherEvent(SimEvent ev) {
if (ev == null) { if (ev == null) {
Log.printLine(getName() + ".processOtherEvent(): " + "Error - an event is null."); Log.printConcatLine(getName(), ".processOtherEvent(): ", "Error - an event is null.");
return; return;
} }
Log.printLine(getName() + ".processOtherEvent(): " Log.printConcatLine(getName(), ".processOtherEvent(): Error - event unknown by this DatacenterBroker.");
+ "Error - event unknown by this DatacenterBroker.");
} }
/** /**
...@@ -348,15 +347,18 @@ public class DatacenterBroker extends SimEntity { ...@@ -348,15 +347,18 @@ public class DatacenterBroker extends SimEntity {
vm = getVmsCreatedList().get(vmIndex); vm = getVmsCreatedList().get(vmIndex);
} else { // submit to the specific vm } else { // submit to the specific vm
vm = VmList.getById(getVmsCreatedList(), cloudlet.getVmId()); vm = VmList.getById(getVmsCreatedList(), cloudlet.getVmId());
if (vm == null) { // vm was not created if (vm == null && !Log.isDisabled()) { // vm was not created
Log.printLine(CloudSim.clock() + ": " + getName() + ": Postponing execution of cloudlet " Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": Postponing execution of cloudlet ",
+ cloudlet.getCloudletId() + ": bount VM not available"); cloudlet.getCloudletId(), ": bount VM not available");
continue; continue;
} }
} }
Log.printLine(CloudSim.clock() + ": " + getName() + ": Sending cloudlet " if (!Log.isDisabled()) {
+ cloudlet.getCloudletId() + " to VM #" + vm.getId()); Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": Sending cloudlet ",
cloudlet.getCloudletId(), " to VM #", vm.getId());
}
cloudlet.setVmId(vm.getId()); cloudlet.setVmId(vm.getId());
sendNow(getVmsToDatacentersMap().get(vm.getId()), CloudSimTags.CLOUDLET_SUBMIT, cloudlet); sendNow(getVmsToDatacentersMap().get(vm.getId()), CloudSimTags.CLOUDLET_SUBMIT, cloudlet);
cloudletsSubmitted++; cloudletsSubmitted++;
...@@ -377,7 +379,7 @@ public class DatacenterBroker extends SimEntity { ...@@ -377,7 +379,7 @@ public class DatacenterBroker extends SimEntity {
*/ */
protected void clearDatacenters() { protected void clearDatacenters() {
for (Vm vm : getVmsCreatedList()) { for (Vm vm : getVmsCreatedList()) {
Log.printLine(CloudSim.clock() + ": " + getName() + ": Destroying VM #" + vm.getId()); Log.printConcatLine(CloudSim.clock(), ": " + getName(), ": Destroying VM #", vm.getId());
sendNow(getVmsToDatacentersMap().get(vm.getId()), CloudSimTags.VM_DESTROY, vm); sendNow(getVmsToDatacentersMap().get(vm.getId()), CloudSimTags.VM_DESTROY, vm);
} }
...@@ -400,7 +402,7 @@ public class DatacenterBroker extends SimEntity { ...@@ -400,7 +402,7 @@ public class DatacenterBroker extends SimEntity {
*/ */
@Override @Override
public void shutdownEntity() { public void shutdownEntity() {
Log.printLine(getName() + " is shutting down..."); Log.printConcatLine(getName(), " is shutting down...");
} }
/* /*
...@@ -409,7 +411,7 @@ public class DatacenterBroker extends SimEntity { ...@@ -409,7 +411,7 @@ public class DatacenterBroker extends SimEntity {
*/ */
@Override @Override
public void startEntity() { public void startEntity() {
Log.printLine(getName() + " is starting..."); Log.printConcatLine(getName(), " is starting...");
schedule(getId(), 0, CloudSimTags.RESOURCE_CHARACTERISTICS_REQUEST); schedule(getId(), 0, CloudSimTags.RESOURCE_CHARACTERISTICS_REQUEST);
} }
......
...@@ -356,7 +356,7 @@ public class HarddriveStorage implements Storage { ...@@ -356,7 +356,7 @@ public class HarddriveStorage implements Storage {
// check first whether file name is valid or not // check first whether file name is valid or not
File obj = null; File obj = null;
if (fileName == null || fileName.length() == 0) { if (fileName == null || fileName.length() == 0) {
Log.printLine(name + ".getFile(): Warning - invalid " + "file name."); Log.printConcatLine(name, ".getFile(): Warning - invalid " + "file name.");
return obj; return obj;
} }
...@@ -450,13 +450,13 @@ public class HarddriveStorage implements Storage { ...@@ -450,13 +450,13 @@ public class HarddriveStorage implements Storage {
private boolean isFileValid(File file, String methodName) { private boolean isFileValid(File file, String methodName) {
if (file == null) { if (file == null) {
Log.printLine(name + "." + methodName + ": Warning - the given file is null."); Log.printConcatLine(name, ".", methodName, ": Warning - the given file is null.");
return false; return false;
} }
String fileName = file.getName(); String fileName = file.getName();
if (fileName == null || fileName.length() == 0) { if (fileName == null || fileName.length() == 0) {
Log.printLine(name + "." + methodName + ": Warning - invalid file name."); Log.printConcatLine(name, "." + methodName, ": Warning - invalid file name.");
return false; return false;
} }
...@@ -482,7 +482,7 @@ public class HarddriveStorage implements Storage { ...@@ -482,7 +482,7 @@ public class HarddriveStorage implements Storage {
// check the capacity // check the capacity
if (file.getSize() + currentSize > capacity) { if (file.getSize() + currentSize > capacity) {
Log.printLine(name + ".addFile(): Warning - not enough space" + " to store " + file.getName()); Log.printConcatLine(name, ".addFile(): Warning - not enough space to store ", file.getName());
return result; return result;
} }
...@@ -512,7 +512,7 @@ public class HarddriveStorage implements Storage { ...@@ -512,7 +512,7 @@ public class HarddriveStorage implements Storage {
public double addFile(List<File> list) { public double addFile(List<File> list) {
double result = 0.0; double result = 0.0;
if (list == null || list.isEmpty()) { if (list == null || list.isEmpty()) {
Log.printLine(name + ".addFile(): Warning - list is empty."); Log.printConcatLine(name, ".addFile(): Warning - list is empty.");
return result; return result;
} }
...@@ -607,7 +607,7 @@ public class HarddriveStorage implements Storage { ...@@ -607,7 +607,7 @@ public class HarddriveStorage implements Storage {
public boolean contains(String fileName) { public boolean contains(String fileName) {
boolean result = false; boolean result = false;
if (fileName == null || fileName.length() == 0) { if (fileName == null || fileName.length() == 0) {
Log.printLine(name + ".contains(): Warning - invalid file name"); Log.printConcatLine(name, ".contains(): Warning - invalid file name");
return result; return result;
} }
// check each file in the list // check each file in the list
......
...@@ -115,14 +115,14 @@ public class Host { ...@@ -115,14 +115,14 @@ public class Host {
if (!getVmsMigratingIn().contains(vm)) { if (!getVmsMigratingIn().contains(vm)) {
if (getStorage() < vm.getSize()) { if (getStorage() < vm.getSize()) {
Log.printLine("[VmScheduler.addMigratingInVm] Allocation of VM #" + vm.getId() + " to Host #" Log.printConcatLine("[VmScheduler.addMigratingInVm] Allocation of VM #", vm.getId(), " to Host #",
+ getId() + " failed by storage"); getId(), " failed by storage");
System.exit(0); System.exit(0);
} }
if (!getRamProvisioner().allocateRamForVm(vm, vm.getCurrentRequestedRam())) { if (!getRamProvisioner().allocateRamForVm(vm, vm.getCurrentRequestedRam())) {
Log.printLine("[VmScheduler.addMigratingInVm] Allocation of VM #" + vm.getId() + " to Host #" Log.printConcatLine("[VmScheduler.addMigratingInVm] Allocation of VM #", vm.getId(), " to Host #",
+ getId() + " failed by RAM"); getId(), " failed by RAM");
System.exit(0); System.exit(0);
} }
...@@ -202,27 +202,27 @@ public class Host { ...@@ -202,27 +202,27 @@ public class Host {
*/ */
public boolean vmCreate(Vm vm) { public boolean vmCreate(Vm vm) {
if (getStorage() < vm.getSize()) { if (getStorage() < vm.getSize()) {
Log.printLine("[VmScheduler.vmCreate] Allocation of VM #" + vm.getId() + " to Host #" + getId() Log.printConcatLine("[VmScheduler.vmCreate] Allocation of VM #", vm.getId(), " to Host #", getId(),
+ " failed by storage"); " failed by storage");
return false; return false;
} }
if (!getRamProvisioner().allocateRamForVm(vm, vm.getCurrentRequestedRam())) { if (!getRamProvisioner().allocateRamForVm(vm, vm.getCurrentRequestedRam())) {
Log.printLine("[VmScheduler.vmCreate] Allocation of VM #" + vm.getId() + " to Host #" + getId() Log.printConcatLine("[VmScheduler.vmCreate] Allocation of VM #", vm.getId(), " to Host #", getId(),
+ " failed by RAM"); " failed by RAM");
return false; return false;
} }
if (!getBwProvisioner().allocateBwForVm(vm, vm.getCurrentRequestedBw())) { if (!getBwProvisioner().allocateBwForVm(vm, vm.getCurrentRequestedBw())) {
Log.printLine("[VmScheduler.vmCreate] Allocation of VM #" + vm.getId() + " to Host #" + getId() Log.printConcatLine("[VmScheduler.vmCreate] Allocation of VM #", vm.getId(), " to Host #", getId(),
+ " failed by BW"); " failed by BW");
getRamProvisioner().deallocateRamForVm(vm); getRamProvisioner().deallocateRamForVm(vm);
return false; return false;
} }
if (!getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips())) { if (!getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips())) {
Log.printLine("[VmScheduler.vmCreate] Allocation of VM #" + vm.getId() + " to Host #" + getId() Log.printConcatLine("[VmScheduler.vmCreate] Allocation of VM #", vm.getId(), " to Host #", getId(),
+ " failed by MIPS"); " failed by MIPS");
getRamProvisioner().deallocateRamForVm(vm); getRamProvisioner().deallocateRamForVm(vm);
getBwProvisioner().deallocateBwForVm(vm); getBwProvisioner().deallocateBwForVm(vm);
return false; return false;
......
...@@ -28,6 +28,9 @@ public class Log { ...@@ -28,6 +28,9 @@ public class Log {
/** The disable output flag. */ /** The disable output flag. */
private static boolean disabled; private static boolean disabled;
/** Buffer to avoid creating new string builder upon every print. */
private static StringBuilder buffer = new StringBuilder();
/** /**
* Prints the message. * Prints the message.
...@@ -75,17 +78,52 @@ public class Log { ...@@ -75,17 +78,52 @@ public class Log {
} }
} }
/**
* Prints the concatenated text representation of the arguements.
*
* @param messages the messages to print
*/
public static void printConcat(Object... messages) {
if (!isDisabled()) {
buffer.setLength(0); // Clear the buffer
for(int i = 0 ; i < messages.length ; i ++) {
buffer.append(String.valueOf(messages[i]));
}
print(buffer);
}
}
/**
* Prints the concatenated text representation of the arguements and a new line.
*
* @param messages the messages to print
*/
public static void printConcatLine(Object... messages) {
if (!isDisabled()) {
buffer.setLength(0); // Clear the buffer
for(int i = 0 ; i < messages.length ; i ++) {
buffer.append(String.valueOf(messages[i]));
}
printLine(buffer);
}
}
/** /**
* Prints the line passed as a non-String object. * Prints the line passed as a non-String object.
* *
* @param message the message * @param message the message
*/ */
public static void printLine(Object message) { public static void printLine(Object message) {
if (!isDisabled()) { if (!isDisabled()) {
printLine(String.valueOf(message)); printLine(String.valueOf(message));
} }
} }
/** /**
* Prints a string formated as in String.format(). * Prints a string formated as in String.format().
* *
......
...@@ -57,7 +57,7 @@ public class NetworkTopology { ...@@ -57,7 +57,7 @@ public class NetworkTopology {
* @post $none * @post $none
*/ */
public static void buildNetworkTopology(String fileName) { public static void buildNetworkTopology(String fileName) {
Log.printLine("Topology file: " + fileName); Log.printConcatLine("Topology file: ", fileName);
// try to find the file // try to find the file
GraphReaderBrite reader = new GraphReaderBrite(); GraphReaderBrite reader = new GraphReaderBrite();
...@@ -178,15 +178,15 @@ public class NetworkTopology { ...@@ -178,15 +178,15 @@ public class NetworkTopology {
if (!map.containsValue(briteID)) { // this BRITE node was already mapped? if (!map.containsValue(briteID)) { // this BRITE node was already mapped?
map.put(cloudSimEntityID, briteID); map.put(cloudSimEntityID, briteID);
} else { } else {
Log.printLine("Error in network mapping. BRITE node " + briteID + " already in use."); Log.printConcatLine("Error in network mapping. BRITE node ", briteID, " already in use.");
} }
} else { } else {
Log.printLine("Error in network mapping. CloudSim entity " + cloudSimEntityID Log.printConcatLine("Error in network mapping. CloudSim entity ", cloudSimEntityID,
+ " already mapped."); " already mapped.");
} }
} catch (Exception e) { } catch (Exception e) {
Log.printLine("Error in network mapping. CloudSim node " + cloudSimEntityID Log.printConcatLine("Error in network mapping. CloudSim node ", cloudSimEntityID,
+ " not mapped to BRITE node " + briteID + "."); " not mapped to BRITE node ", briteID, ".");
} }
} }
} }
...@@ -203,7 +203,7 @@ public class NetworkTopology { ...@@ -203,7 +203,7 @@ public class NetworkTopology {
try { try {
map.remove(cloudSimEntityID); map.remove(cloudSimEntityID);
} catch (Exception e) { } catch (Exception e) {
Log.printLine("Error in network unmapping. CloudSim node: " + cloudSimEntityID); Log.printConcatLine("Error in network unmapping. CloudSim node: ", cloudSimEntityID);
} }
} }
} }
......
...@@ -120,7 +120,7 @@ public class SanStorage extends HarddriveStorage { ...@@ -120,7 +120,7 @@ public class SanStorage extends HarddriveStorage {
public double addFile(List<File> list) { public double addFile(List<File> list) {
double result = 0.0; double result = 0.0;
if (list == null || list.size() == 0) { if (list == null || list.size() == 0) {
Log.printLine(getName() + ".addFile(): Warning - list is empty."); Log.printConcatLine(getName(), ".addFile(): Warning - list is empty.");
return result; return result;
} }
......
...@@ -149,7 +149,7 @@ public class VmSchedulerTimeShared extends VmScheduler { ...@@ -149,7 +149,7 @@ public class VmSchedulerTimeShared extends VmScheduler {
break; break;
} }
if (!peIterator.hasNext()) { if (!peIterator.hasNext()) {
Log.printLine("There is no enough MIPS (" + mips + ") to accommodate VM " + vmUid); Log.printConcatLine("There is no enough MIPS (", mips, ") to accommodate VM ", vmUid);
// System.exit(0); // System.exit(0);
} }
pe = peIterator.next(); pe = peIterator.next();
......
...@@ -237,8 +237,8 @@ public class CloudInformationService extends SimEntity { ...@@ -237,8 +237,8 @@ public class CloudInformationService extends SimEntity {
*/ */
protected void processOtherEvent(SimEvent ev) { protected void processOtherEvent(SimEvent ev) {
if (ev == null) { if (ev == null) {
Log.printLine("CloudInformationService.processOtherEvent(): " Log.printConcatLine("CloudInformationService.processOtherEvent(): ",
+ "Unable to handle a request since the event is null."); "Unable to handle a request since the event is null.");
return; return;
} }
...@@ -294,7 +294,7 @@ public class CloudInformationService extends SimEntity { ...@@ -294,7 +294,7 @@ public class CloudInformationService extends SimEntity {
* @post $none * @post $none
*/ */
private void notifyAllEntity() { private void notifyAllEntity() {
Log.printLine(super.getName() + ": Notify all CloudSim entities for shutting down."); Log.printConcatLine(super.getName(), ": Notify all CloudSim entities for shutting down.");
signalShutdown(resList); signalShutdown(resList);
signalShutdown(gisList); signalShutdown(gisList);
......
...@@ -183,7 +183,7 @@ public class CloudSim { ...@@ -183,7 +183,7 @@ public class CloudSim {
* @post $none * @post $none
*/ */
public static double startSimulation() throws NullPointerException { public static double startSimulation() throws NullPointerException {
Log.printLine("Starting CloudSim version " + CLOUDSIM_VERSION_STRING); Log.printConcatLine("Starting CloudSim version ", CLOUDSIM_VERSION_STRING);
try { try {
double clock = run(); double clock = run();
......
...@@ -532,7 +532,7 @@ public abstract class SimEntity implements Cloneable { ...@@ -532,7 +532,7 @@ public abstract class SimEntity implements Cloneable {
} }
if (entityId < 0) { if (entityId < 0) {
Log.printLine(getName() + ".send(): Error - " + "invalid entity id " + entityId); Log.printConcatLine(getName(), ".send(): Error - " + "invalid entity id ", entityId);
return; return;
} }
......
...@@ -205,7 +205,7 @@ public class PeList { ...@@ -205,7 +205,7 @@ public class PeList {
status = "WORKING"; status = "WORKING";
} }
Log.printLine(resName + " - Machine: " + hostId + " is " + status); Log.printConcatLine(resName, " - Machine: ", hostId, " is ", status);
setStatusFailed(peList, failed); setStatusFailed(peList, failed);
} }
......
...@@ -223,8 +223,8 @@ public class NetDatacenterBroker extends SimEntity { ...@@ -223,8 +223,8 @@ public class NetDatacenterBroker extends SimEntity {
setDatacenterIdsList(CloudSim.getCloudResourceList()); setDatacenterIdsList(CloudSim.getCloudResourceList());
setDatacenterCharacteristicsList(new HashMap<Integer, DatacenterCharacteristics>()); setDatacenterCharacteristicsList(new HashMap<Integer, DatacenterCharacteristics>());
Log.printLine(CloudSim.clock() + ": " + getName() + ": Cloud Resource List received with " Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": Cloud Resource List received with ",
+ getDatacenterIdsList().size() + " resource(s)"); getDatacenterIdsList().size(), " resource(s)");
for (Integer datacenterId : getDatacenterIdsList()) { for (Integer datacenterId : getDatacenterIdsList()) {
sendNow(datacenterId, CloudSimTags.RESOURCE_CHARACTERISTICS, getId()); sendNow(datacenterId, CloudSimTags.RESOURCE_CHARACTERISTICS, getId());
...@@ -254,7 +254,7 @@ public class NetDatacenterBroker extends SimEntity { ...@@ -254,7 +254,7 @@ public class NetDatacenterBroker extends SimEntity {
cloudletsSubmitted--; cloudletsSubmitted--;
// all cloudlets executed // all cloudlets executed
if (getCloudletList().size() == 0 && cloudletsSubmitted == 0 && NetworkConstants.iteration > 10) { if (getCloudletList().size() == 0 && cloudletsSubmitted == 0 && NetworkConstants.iteration > 10) {
Log.printLine(CloudSim.clock() + ": " + getName() + ": All Cloudlets executed. Finishing..."); Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": All Cloudlets executed. Finishing...");
clearDatacenters(); clearDatacenters();
finishExecution(); finishExecution();
} else { // some cloudlets haven't finished yet } else { // some cloudlets haven't finished yet
...@@ -279,12 +279,12 @@ public class NetDatacenterBroker extends SimEntity { ...@@ -279,12 +279,12 @@ public class NetDatacenterBroker extends SimEntity {
*/ */
protected void processOtherEvent(SimEvent ev) { protected void processOtherEvent(SimEvent ev) {
if (ev == null) { if (ev == null) {
Log.printLine(getName() + ".processOtherEvent(): " + "Error - an event is null."); Log.printConcatLine(getName(), ".processOtherEvent(): Error - an event is null.");
return; return;
} }
Log.printLine(getName() + ".processOtherEvent(): " Log.printConcatLine(getName(), ".processOtherEvent(): ",
+ "Error - event unknown by this DatacenterBroker."); "Error - event unknown by this DatacenterBroker.");
} }
/** /**
...@@ -402,7 +402,7 @@ public class NetDatacenterBroker extends SimEntity { ...@@ -402,7 +402,7 @@ public class NetDatacenterBroker extends SimEntity {
*/ */
protected void clearDatacenters() { protected void clearDatacenters() {
for (Vm vm : getVmsCreatedList()) { for (Vm vm : getVmsCreatedList()) {
Log.printLine(CloudSim.clock() + ": " + getName() + ": Destroying VM #" + vm.getId()); Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": Destroying VM #", vm.getId());
sendNow(getVmsToDatacentersMap().get(vm.getId()), CloudSimTags.VM_DESTROY, vm); sendNow(getVmsToDatacentersMap().get(vm.getId()), CloudSimTags.VM_DESTROY, vm);
} }
...@@ -425,7 +425,7 @@ public class NetDatacenterBroker extends SimEntity { ...@@ -425,7 +425,7 @@ public class NetDatacenterBroker extends SimEntity {
*/ */
@Override @Override
public void shutdownEntity() { public void shutdownEntity() {
Log.printLine(getName() + " is shutting down..."); Log.printConcatLine(getName(), " is shutting down...");
} }
/* /*
...@@ -434,7 +434,7 @@ public class NetDatacenterBroker extends SimEntity { ...@@ -434,7 +434,7 @@ public class NetDatacenterBroker extends SimEntity {
*/ */
@Override @Override
public void startEntity() { public void startEntity() {
Log.printLine(getName() + " is starting..."); Log.printConcatLine(getName(), " is starting...");
schedule(getId(), 0, CloudSimTags.RESOURCE_CHARACTERISTICS_REQUEST); schedule(getId(), 0, CloudSimTags.RESOURCE_CHARACTERISTICS_REQUEST);
} }
......
...@@ -147,8 +147,8 @@ public class NetworkDatacenter extends Datacenter { ...@@ -147,8 +147,8 @@ public class NetworkDatacenter extends Datacenter {
// checks whether this Cloudlet has finished or not // checks whether this Cloudlet has finished or not
if (cl.isFinished()) { if (cl.isFinished()) {
String name = CloudSim.getEntityName(cl.getUserId()); String name = CloudSim.getEntityName(cl.getUserId());
Log.printLine(getName() + ": Warning - Cloudlet #" + cl.getCloudletId() + " owned by " + name Log.printConcatLine(getName(), ": Warning - Cloudlet #", cl.getCloudletId(), " owned by ", name,
+ " is already completed/finished."); " is already completed/finished.");
Log.printLine("Therefore, it is not being executed again"); Log.printLine("Therefore, it is not being executed again");
Log.printLine(); Log.printLine();
......
...@@ -80,7 +80,7 @@ public class Switch extends SimEntity { ...@@ -80,7 +80,7 @@ public class Switch extends SimEntity {
@Override @Override
public void startEntity() { public void startEntity() {
Log.printLine(getName() + " is starting..."); Log.printConcatLine(getName(), " is starting...");
schedule(getId(), 0, CloudSimTags.RESOURCE_CHARACTERISTICS_REQUEST); schedule(getId(), 0, CloudSimTags.RESOURCE_CHARACTERISTICS_REQUEST);
} }
...@@ -380,7 +380,7 @@ public class Switch extends SimEntity { ...@@ -380,7 +380,7 @@ public class Switch extends SimEntity {
@Override @Override
public void shutdownEntity() { public void shutdownEntity() {
Log.printLine(getName() + " is shutting down..."); Log.printConcatLine(getName(), " is shutting down...");
} }
} }
...@@ -156,7 +156,7 @@ public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAl ...@@ -156,7 +156,7 @@ public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAl
break; break;
} }
Log.printLine("Under-utilized host: host #" + underUtilizedHost.getId() + "\n"); Log.printConcatLine("Under-utilized host: host #", underUtilizedHost.getId(), "\n");
excludedHostsForFindingUnderUtilizedHost.add(underUtilizedHost); excludedHostsForFindingUnderUtilizedHost.add(underUtilizedHost);
excludedHostsForFindingNewVmPlacement.add(underUtilizedHost); excludedHostsForFindingNewVmPlacement.add(underUtilizedHost);
...@@ -196,7 +196,7 @@ public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAl ...@@ -196,7 +196,7 @@ public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAl
if (!Log.isDisabled()) { if (!Log.isDisabled()) {
Log.printLine("Over-utilized hosts:"); Log.printLine("Over-utilized hosts:");
for (PowerHostUtilizationHistory host : overUtilizedHosts) { for (PowerHostUtilizationHistory host : overUtilizedHosts) {
Log.printLine("Host #" + host.getId()); Log.printConcatLine("Host #", host.getId());
} }
Log.printLine(); Log.printLine();
} }
...@@ -299,7 +299,7 @@ public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAl ...@@ -299,7 +299,7 @@ public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAl
PowerHost allocatedHost = findHostForVm(vm, excludedHosts); PowerHost allocatedHost = findHostForVm(vm, excludedHosts);
if (allocatedHost != null) { if (allocatedHost != null) {
allocatedHost.vmCreate(vm); allocatedHost.vmCreate(vm);
Log.printLine("VM #" + vm.getId() + " allocated to host #" + allocatedHost.getId()); Log.printConcatLine("VM #", vm.getId(), " allocated to host #", allocatedHost.getId());
Map<String, Object> migrate = new HashMap<String, Object>(); Map<String, Object> migrate = new HashMap<String, Object>();
migrate.put("vm", vm); migrate.put("vm", vm);
...@@ -326,7 +326,7 @@ public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAl ...@@ -326,7 +326,7 @@ public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAl
PowerHost allocatedHost = findHostForVm(vm, excludedHosts); PowerHost allocatedHost = findHostForVm(vm, excludedHosts);
if (allocatedHost != null) { if (allocatedHost != null) {
allocatedHost.vmCreate(vm); allocatedHost.vmCreate(vm);
Log.printLine("VM #" + vm.getId() + " allocated to host #" + allocatedHost.getId()); Log.printConcatLine("VM #", vm.getId(), " allocated to host #", allocatedHost.getId());
Map<String, Object> migrate = new HashMap<String, Object>(); Map<String, Object> migrate = new HashMap<String, Object>();
migrate.put("vm", vm); migrate.put("vm", vm);
...@@ -519,7 +519,7 @@ public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAl ...@@ -519,7 +519,7 @@ public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAl
Vm vm = (Vm) map.get("vm"); Vm vm = (Vm) map.get("vm");
PowerHost host = (PowerHost) map.get("host"); PowerHost host = (PowerHost) map.get("host");
if (!host.vmCreate(vm)) { if (!host.vmCreate(vm)) {
Log.printLine("Couldn't restore VM #" + vm.getId() + " on host #" + host.getId()); Log.printConcatLine("Couldn't restore VM #", vm.getId(), " on host #", host.getId());
System.exit(0); System.exit(0);
} }
getVmTable().put(vm.getUid(), host); getVmTable().put(vm.getUid(), host);
......
...@@ -119,8 +119,8 @@ public class PowerVmAllocationPolicyMigrationInterQuartileRange extends ...@@ -119,8 +119,8 @@ public class PowerVmAllocationPolicyMigrationInterQuartileRange extends
*/ */
protected void setSafetyParameter(double safetyParameter) { protected void setSafetyParameter(double safetyParameter) {
if (safetyParameter < 0) { if (safetyParameter < 0) {
Log.printLine("The safety parameter cannot be less than zero. The passed value is: " Log.printConcatLine("The safety parameter cannot be less than zero. The passed value is: ",
+ safetyParameter); safetyParameter);
System.exit(0); System.exit(0);
} }
this.safetyParameter = safetyParameter; this.safetyParameter = safetyParameter;
......
...@@ -119,8 +119,8 @@ public class PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation extends ...@@ -119,8 +119,8 @@ public class PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation extends
*/ */
protected void setSafetyParameter(double safetyParameter) { protected void setSafetyParameter(double safetyParameter) {
if (safetyParameter < 0) { if (safetyParameter < 0) {
Log.printLine("The safety parameter cannot be less than zero. The passed value is: " Log.printConcatLine("The safety parameter cannot be less than zero. The passed value is: ",
+ safetyParameter); safetyParameter);
System.exit(0); System.exit(0);
} }
this.safetyParameter = safetyParameter; this.safetyParameter = safetyParameter;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment