Commit a0226d94 authored by Anton Beloglazov's avatar Anton Beloglazov

- Removed some obsolete code

parent 45cfcbff
......@@ -1005,23 +1005,6 @@ public class Cloudlet {
return getCloudletLength() * getPesNumber();
}
/**
* Gets the total execution time of this Cloudlet from the latest
* CloudResource.
*
* @return the total execution time of this Cloudlet in a CloudResource
*
* @pre $none
* @post $result >= 0.0
*/
public double getActualCPUTimeOld() {
//TODO: check which method to leave
if (index == -1) {
return 0.0;
}
return resList.get(index).actualCPUTime;
}
/**
* Gets the cost running this Cloudlet in the latest CloudResource.
*
......@@ -1038,33 +1021,6 @@ public class Cloudlet {
return resList.get(index).costPerSec;
}
/**
* Gets the total cost of processing or executing this Cloudlet
* <tt>Processing Cost = actual CPU Time * cost per sec</tt>.
*
* @return the total cost of processing Cloudlet
*
* @see CloudSim.Cloudlet#getActualCPUTime()
* @see CloudSim.Cloudlet#getCostPerSecond()
* @pre $none
* @post $result >= 0.0
*/
public double getProcessingCostOld() {
//TODO: check which method to leave
if (index == -1) {
return 0.0;
}
Resource res = null;
double cost = 0.0;
for (int i = 0; i <= index; i++) {
res = resList.get(i);
cost += (res.actualCPUTime * res.costPerSec);
}
return cost;
}
/**
* Gets the time of this Cloudlet resides in the latest CloudResource
* (from arrival time until departure time).
......@@ -1550,22 +1506,6 @@ public class Cloudlet {
this.utilizationModelBw = utilizationModelBw;
}
/**
* Gets the utilization of cpu.
*
* @param time the time
*
* @return the utilization of cpu
*/
// public List<Double> getUtilizationOfCpu(final double time) {
// double utilization = getUtilizationModelCpu().getUtilization(time);
// List<Double> utilizationMap = new ArrayList<Double>();
// for (int i = 0; i < getPesNumber(); i++) {
// utilizationMap.add(utilization);
// }
// return utilizationMap;
// }
/**
* Gets the total utilization of cpu.
*
......
......@@ -106,7 +106,6 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
for (ResCloudlet rcl : getCloudletExecList()) {
if (rcl.getRemainingCloudletLength() == 0.0) {// finished anyway, rounding issue...
toRemove.add(rcl);
//getCloudletExecList().remove(obj);
cloudletFinish(rcl);
finished++;
}
......@@ -127,7 +126,6 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
getCloudletExecList().add(rcl);
usedPes += rcl.getPesNumber();
toRemove.add(rcl);
//getCloudletWaitingList().remove(j);
break;
}
}
......@@ -380,20 +378,12 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
rcl.setMachineAndPeId(0, i);
}
// double size = rgl.getRemainingCloudletLength();
// size*=rgl.getNumPE();
// rgl.getCloudlet().setCloudletLength(size);
getCloudletExecList().add(rcl);
usedPes += cloudlet.getPesNumber();
} else {// no enough free PEs: go to the waiting queue
ResCloudlet rcl = new ResCloudlet(cloudlet);
rcl.setCloudletStatus(Cloudlet.QUEUED);
// double size = rgl.getRemainingCloudletLength();
// size*=rgl.getNumPE();
// rgl.getCloudlet().setCloudletLength(size);
getCloudletWaitingList().add(rcl);
return 0.0;
}
......@@ -542,6 +532,7 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
/**
* Gets the cloudlet waiting list.
*
* @param <T> the generic type
* @return the cloudlet waiting list
*/
@SuppressWarnings("unchecked")
......@@ -552,6 +543,7 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
/**
* Cloudlet waiting list.
*
* @param <T> the generic type
* @param cloudletWaitingList the cloudlet waiting list
*/
protected <T extends ResCloudlet> void cloudletWaitingList(List<T> cloudletWaitingList) {
......@@ -561,6 +553,7 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
/**
* Gets the cloudlet exec list.
*
* @param <T> the generic type
* @return the cloudlet exec list
*/
@SuppressWarnings("unchecked")
......@@ -571,6 +564,7 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
/**
* Sets the cloudlet exec list.
*
* @param <T> the generic type
* @param cloudletExecList the new cloudlet exec list
*/
protected <T extends ResCloudlet> void setCloudletExecList(List<T> cloudletExecList) {
......@@ -580,6 +574,7 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
/**
* Gets the cloudlet paused list.
*
* @param <T> the generic type
* @return the cloudlet paused list
*/
@SuppressWarnings("unchecked")
......@@ -590,6 +585,7 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
/**
* Sets the cloudlet paused list.
*
* @param <T> the generic type
* @param cloudletPausedList the new cloudlet paused list
*/
protected <T extends ResCloudlet> void setCloudletPausedList(List<T> cloudletPausedList) {
......@@ -599,6 +595,7 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
/**
* Gets the cloudlet finished list.
*
* @param <T> the generic type
* @return the cloudlet finished list
*/
@SuppressWarnings("unchecked")
......@@ -609,12 +606,16 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
/**
* Sets the cloudlet finished list.
*
* @param <T> the generic type
* @param cloudletFinishedList the new cloudlet finished list
*/
protected <T extends ResCloudlet> void setCloudletFinishedList(List<T> cloudletFinishedList) {
this.cloudletFinishedList = cloudletFinishedList;
}
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.CloudletScheduler#getCurrentRequestedMips()
*/
@Override
public List<Double> getCurrentRequestedMips() {
List<Double> mipsShare = new ArrayList<Double>();
......@@ -626,6 +627,9 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
return mipsShare;
}
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.CloudletScheduler#getTotalCurrentAvailableMipsForCloudlet(org.cloudbus.cloudsim.ResCloudlet, java.util.List)
*/
@Override
public double getTotalCurrentAvailableMipsForCloudlet(ResCloudlet rcl, List<Double> mipsShare) {
double capacity = 0.0;
......@@ -641,28 +645,22 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
return capacity;
}
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.CloudletScheduler#getTotalCurrentAllocatedMipsForCloudlet(org.cloudbus.cloudsim.ResCloudlet, double)
*/
@Override
public double getTotalCurrentAllocatedMipsForCloudlet(ResCloudlet rcl, double time) {
// TODO Auto-generated method stub
return 0.0;
}
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.CloudletScheduler#getTotalCurrentRequestedMipsForCloudlet(org.cloudbus.cloudsim.ResCloudlet, double)
*/
@Override
public double getTotalCurrentRequestedMipsForCloudlet(ResCloudlet rcl, double time) {
// TODO Auto-generated method stub
return 0.0;
}
// @Override
// public List<Double> getCurrentAllocatedMips() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// public double getTotalCurrentAllocatedMips() {
// // TODO Auto-generated method stub
// return 0;
// }
}
......@@ -70,7 +70,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
for (ResCloudlet rcl : getCloudletExecList()) {
rcl.updateCloudletFinishedSoFar((long) (getCapacity(mipsShare) * timeSpam * rcl.getPesNumber()));
// Log.printLine(CloudSim.clock()+": CloudletSchedulerTimeShared: updating cloudlet #"+rgl.getCloudletId()+": remaining:"+rgl.getRemainingCloudletLength());
}
if (getCloudletExecList().size() == 0) {
......@@ -86,7 +85,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
double remainingLength = rcl.getRemainingCloudletLength();
if (remainingLength == 0.00) {// finished: remove from the list
toRemove.add(rcl);
//getCloudletExecList().remove(rcl);
cloudletFinish(rcl);
continue;
}
......@@ -322,9 +320,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
rcl.setMachineAndPeId(0, i);
}
// double size = rgl.getRemainingCloudletLength();
// size*=rgl.getNumPE();
// rgl.getCloudlet().setCloudletLength(size);
getCloudletExecList().add(rcl);
// use the current capacity to estimate the extra amount of
......@@ -447,6 +442,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
/**
* Gets the cloudlet exec list.
*
* @param <T> the generic type
* @return the cloudlet exec list
*/
@SuppressWarnings("unchecked")
......@@ -457,6 +453,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
/**
* Sets the cloudlet exec list.
*
* @param <T> the generic type
* @param cloudletExecList the new cloudlet exec list
*/
protected <T extends ResCloudlet> void setCloudletExecList(List<T> cloudletExecList) {
......@@ -466,6 +463,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
/**
* Gets the cloudlet paused list.
*
* @param <T> the generic type
* @return the cloudlet paused list
*/
@SuppressWarnings("unchecked")
......@@ -476,6 +474,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
/**
* Sets the cloudlet paused list.
*
* @param <T> the generic type
* @param cloudletPausedList the new cloudlet paused list
*/
protected <T extends ResCloudlet> void setCloudletPausedList(List<T> cloudletPausedList) {
......@@ -485,6 +484,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
/**
* Gets the cloudlet finished list.
*
* @param <T> the generic type
* @return the cloudlet finished list
*/
@SuppressWarnings("unchecked")
......@@ -495,6 +495,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
/**
* Sets the cloudlet finished list.
*
* @param <T> the generic type
* @param cloudletFinishedList the new cloudlet finished list
*/
protected <T extends ResCloudlet> void setCloudletFinishedList(List<T> cloudletFinishedList) {
......@@ -543,16 +544,4 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
return 0.0;
}
// @Override
// public List<Double> getCurrentAllocatedMips() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// public double getTotalCurrentAllocatedMips() {
// // TODO Auto-generated method stub
// return 0;
// }
}
......@@ -103,68 +103,6 @@ public class Datacenter extends SimEntity {
getCharacteristics().setId(super.getId());
}
/**
* Handles external events that are coming to this PowerDatacenter entity.
* This method also registers the identity of this entity to
* <tt>CloudInformationService</tt> class.
* <p>
* The services or tags available for this resource are:
* <ul>
* <li> {@link cloudsim.DatacenterTags#VM_CREATE} </li>
* <li> {@link cloudsim.DatacenterTags#VM_CREATE_ACK} </li>
* <li> {@link cloudsim.DatacenterTags#VM_DESTROY} </li>
* <li> {@link cloudsim.DatacenterTags#VM_DESTROY_ACK} </li>
* <li> {@link cloudsim.DatacenterTags#VM_MIGRATE} </li>
* <li> {@link cloudsim.DatacenterTags#VM_MIGRATE_ACK} </li>
* </ul>
* <br>
*
* @pre $none
* @post $none
*/
public void body() {
// this resource should register to regional GIS.
// However, if not specified, then register to system GIS (the
// default CloudInformationService) entity.
int cisId = CloudSim.getEntityId(regionalCisName);
if (cisId == -1) {
cisId = CloudSim.getCloudInfoServiceEntityId();
}
// need to wait for few seconds before registering to a regional GIS.
// This is because to allow all routers to fill in their routing tables
else {
super.pause(2);
Log.printLine(super.getName() + ".body(): wait for " +
" 2 seconds before registering to " +
regionalCisName);
}
// send the registration to GIS
sendNow(cisId, CloudSimTags.REGISTER_RESOURCE, getId());
// Below method is for a child class to override
registerOtherEntity();
// Process events until END_OF_SIMULATION is received from the
// CloudSimShutdown Entity
// SimEvent ev = new SimEvent();
SimEvent ev;
while (CloudSim.running()){
//super.sim_get_next(ev);
ev = getNextEvent();
// if the simulation finishes then exit the loop
if (ev.getTag() == CloudSimTags.END_OF_SIMULATION){
break;
}
// process the received event
processEvent(ev);
}
// remove I/O entities created during construction of this entity
//super.terminateIOEntities();
}
/**
* Overrides this method when making a new and different type of resource.
* This method is called by {@link #body()} to register other type to
......
......@@ -420,6 +420,7 @@ public class DatacenterBroker extends SimEntity {
/**
* Gets the vm list.
*
* @param <T> the generic type
* @return the vm list
*/
@SuppressWarnings("unchecked")
......@@ -430,6 +431,7 @@ public class DatacenterBroker extends SimEntity {
/**
* Sets the vm list.
*
* @param <T> the generic type
* @param vmList the new vm list
*/
protected <T extends Vm> void setVmList(List<T> vmList) {
......@@ -440,6 +442,7 @@ public class DatacenterBroker extends SimEntity {
/**
* Gets the cloudlet list.
*
* @param <T> the generic type
* @return the cloudlet list
*/
@SuppressWarnings("unchecked")
......@@ -451,6 +454,7 @@ public class DatacenterBroker extends SimEntity {
/**
* Sets the cloudlet list.
*
* @param <T> the generic type
* @param cloudletList the new cloudlet list
*/
protected <T extends Cloudlet> void setCloudletList(List<T> cloudletList) {
......@@ -460,6 +464,7 @@ public class DatacenterBroker extends SimEntity {
/**
* Gets the cloudlet submitted list.
*
* @param <T> the generic type
* @return the cloudlet submitted list
*/
@SuppressWarnings("unchecked")
......@@ -471,6 +476,7 @@ public class DatacenterBroker extends SimEntity {
/**
* Sets the cloudlet submitted list.
*
* @param <T> the generic type
* @param cloudletSubmittedList the new cloudlet submitted list
*/
protected <T extends Cloudlet> void setCloudletSubmittedList(List<T> cloudletSubmittedList) {
......@@ -480,6 +486,7 @@ public class DatacenterBroker extends SimEntity {
/**
* Gets the cloudlet received list.
*
* @param <T> the generic type
* @return the cloudlet received list
*/
@SuppressWarnings("unchecked")
......@@ -490,6 +497,7 @@ public class DatacenterBroker extends SimEntity {
/**
* Sets the cloudlet received list.
*
* @param <T> the generic type
* @param cloudletReceivedList the new cloudlet received list
*/
protected <T extends Cloudlet> void setCloudletReceivedList(List<T> cloudletReceivedList) {
......@@ -499,6 +507,7 @@ public class DatacenterBroker extends SimEntity {
/**
* Gets the vm list.
*
* @param <T> the generic type
* @return the vm list
*/
@SuppressWarnings("unchecked")
......@@ -509,6 +518,7 @@ public class DatacenterBroker extends SimEntity {
/**
* Sets the vm list.
*
* @param <T> the generic type
* @param vmsCreatedList the vms created list
*/
protected <T extends Vm> void setVmsCreatedList(List<T> vmsCreatedList) {
......
......@@ -142,8 +142,7 @@ public class DatacenterCharacteristics {
/**
* Gets a Machine with at least one empty Pe.
*
* @return a Machine object or <tt>null</tt> if not found
*
* @return a Machine object or if not found
* @pre $none
* @post $none
*/
......@@ -155,9 +154,7 @@ public class DatacenterCharacteristics {
* Gets a Machine with at least a given number of free Pe.
*
* @param peNumber the pe number
*
* @return a Machine object or <tt>null</tt> if not found
*
* @return a Machine object or if not found
* @pre $none
* @post $none
*/
......@@ -169,8 +166,7 @@ public class DatacenterCharacteristics {
* Gets Millions Instructions Per Second (MIPS) Rating of a Processing
* Element (Pe). It is assumed all PEs' rating is same in a given machine.
*
* @return the MIPS Rating or <tt>-1</tt> if no PEs are exists.
*
* @return the MIPS Rating or if no PEs are exists.
* @pre $none
* @post $result >= -1
*/
......@@ -191,9 +187,7 @@ public class DatacenterCharacteristics {
*
* @param id the machine ID
* @param peId the Pe ID
*
* @return the MIPS Rating or <tt>-1</tt> if no PEs are exists.
*
* @return the MIPS Rating or if no PEs are exists.
* @pre id >= 0
* @pre peID >= 0
* @post $result >= -1
......@@ -322,10 +316,8 @@ public class DatacenterCharacteristics {
* @param status Pe status, either <tt>Pe.FREE</tt> or <tt>Pe.BUSY</tt>
* @param hostId Machine ID
* @param peId Pe id
*
* @return <tt>true</tt> if the Pe status has changed, <tt>false</tt>
* @return
* otherwise (Machine id or Pe id might not be exist)
*
* @pre machineID >= 0
* @pre peID >= 0
* @post $none
......@@ -346,27 +338,6 @@ public class DatacenterCharacteristics {
return getCostPerSecond() / getMipsOfOnePe();
}
/**
* Gets the byte size of this class.
*
* @return the byte size
*
* @pre $none
* @post $result > 0
*/
// TODO: check necessity
// public int getByteSize() {
// // this class overall has: 2 ints, 2 Strings, 1 HostList2 and
// // 2 doubles.
// // NOTE: static attributes do not count
// int totalInt = 2 * 4;
// int totalDouble = 2 * 8;
// int totalSize = getArchitecture().length() + getOs().length() +
// getHostList().getByteSize() + totalInt + totalDouble ;
//
// return totalSize;
// }
/**
* Gets the total number of machines.
*
......@@ -394,8 +365,8 @@ public class DatacenterCharacteristics {
/**
* Checks whether all machines of this resource are working properly or not.
*
* @return <tt>true</tt> if all machines are working,
* <tt>false</tt> otherwise
* @return if all machines are working,
* otherwise
*/
public boolean isWorking() {
boolean result = false;
......@@ -535,12 +506,9 @@ public class DatacenterCharacteristics {
/**
* Gets the host list.
*
* @param <T> the generic type
* @return the host list
*/
// protected HostList2<? extends Host> getHostList() {
// return hostList;
// }
@SuppressWarnings("unchecked")
public <T extends Host> List<T> getHostList() {
return (List<T>) hostList;
......@@ -549,6 +517,7 @@ public class DatacenterCharacteristics {
/**
* Sets the host list.
*
* @param <T> the generic type
* @param hostList the new host list
*/
protected <T extends Host> void setHostList(List<T> hostList) {
......
......@@ -122,72 +122,6 @@ public class FederatedDatacenter extends SimEntity {
getCharacteristics().setId(super.getId());
}
/**
* Handles external events that are coming to this PowerDatacenter entity.
* This method also registers the identity of this entity to
* <tt>CloudInformationService</tt> class.
* <p>
* The services or tags available for this resource are:
* <ul>
* <li> {@link cloudsim.CloudSimTags#VM_CREATE} </li>
* <li> {@link cloudsim.CloudSimTags#VM_CREATE_ACK} </li>
* <li> {@link cloudsim.CloudSimTags#VM_DESTROY} </li>
* <li> {@link cloudsim.CloudSimTags#VM_DESTROY_ACK} </li>
* <li> {@link cloudsim.CloudSimTags#VM_MIGRATE} </li>
* <li> {@link cloudsim.CloudSimTags#VM_MIGRATE_ACK} </li>
* </ul>
* <br>
*
* @pre $none
* @post $none
*/
public void body() {
// this resource should register to regional GIS.
// However, if not specified, then register to system GIS (the
// default CloudInformationService) entity.
int cisId = CloudSim.getEntityId(regionalCisName);
if (cisId == -1) {
cisId = CloudSim.getCloudInfoServiceEntityId();
}
// need to wait for few seconds before registering to a regional GIS.
// This is because to allow all routers to fill in their routing tables
else {
super.pause(2);
Log.printLine(super.getName() + ".body(): wait for " +
" 2 seconds before registering to " +
regionalCisName);
}
// send the registration to GIS
sendNow(cisId, CloudSimTags.REGISTER_RESOURCE, getId());
super.pause(8);
federationList = CloudSim.getCloudResourceList();
// Below method is for a child class to override
registerOtherEntity();
// Process events until END_OF_SIMULATION is received from the
// CloudSimShutdown Entity
//SimEvent ev = new SimEvent();
SimEvent ev;
while (CloudSim.running()){
//super.sim_get_next(ev);
ev = getNextEvent();
// if the simulation finishes then exit the loop
if (ev.getTag() == CloudSimTags.END_OF_SIMULATION){
break;
}
// process the received event
processEvent(ev);
}
// remove I/O entities created during construction of this entity
//super.terminateIOEntities();
}
/**
* Overrides this method when making a new and different type of resource.
* This method is called by {@link #body()} to register other type to
......
......@@ -39,8 +39,8 @@ public class HostDynamicWorkload extends Host {
* @param ramProvisioner the ram provisioner
* @param bwProvisioner the bw provisioner
* @param storage the storage
* @param vmScheduler the VM scheduler
* @param peList the pe list
* @param vmScheduler the VM scheduler
*/
public HostDynamicWorkload(
int id,
......@@ -65,25 +65,14 @@ public class HostDynamicWorkload extends Host {
setUtilizationMips(0);
for (Vm vm : getVmList()) {
// if (vm.isInMigration()) {
// continue;
// }
getVmScheduler().deallocatePesForVm(vm);
}
for (Vm vm : getVmList()) {
// if (vm.isInMigration()) {
// continue;
// }
getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips());
}
for (Vm vm : getVmList()) {
// if (vm.isInMigration()) {
// continue;
// }
double totalRequestedMips = vm.getCurrentRequestedTotalMips();
if (totalRequestedMips == 0) {
......@@ -109,33 +98,14 @@ public class HostDynamicWorkload extends Host {
setUtilizationMips(getUtilizationMips() + totalAllocatedMips);
}
// for (Vm vm : getVmList()) {
// if (vm.isInMigration()) {
// continue;
// }
//
// List<Double> requestedMips = vm.getCurrentRequestedMips();
// double totalRequestedMips = vm.getCurrentRequestedTotalMips();
//
// getVmScheduler().allocatePesForVm(vm, requestedMips);
// double totalAllocatedMips = getVmScheduler().getTotalAllocatedMipsForVm(vm);
//
// if (totalAllocatedMips + 0.1 < totalRequestedMips) {
// Log.printLine("Under allocated MIPS for VM #" + vm.getId() + ": requested " + totalRequestedMips + ", allocated " + totalAllocatedMips);
// }
//
// updateUnderAllocatedMips(vm, totalRequestedMips, totalAllocatedMips);
//
// setUtilizationMips(getUtilizationMips() + totalAllocatedMips);
//
// Log.print(String.format("%.2f: Total allocated MIPS for VM #" + vm.getId() + " (Host #" + vm.getHost().getId() + ") is %.2f, was requested %.2f out of total %.2f (%.2f%%)\n", CloudSim.clock(), totalAllocatedMips, totalRequestedMips, vm.getMips(), totalRequestedMips / vm.getMips() * 100));
// }
//TODO: getTotalAllocatedMipsForVm should be done after all the vMs are allocated
return smallerTime;
}
/**
* Gets the completed vms.
*
* @return the completed vms
*/
public List<Vm> getCompletedVms() {
List<Vm> vmsToRemove = new ArrayList<Vm>();
for (Vm vm : getVmList()) {
......
......@@ -157,20 +157,6 @@ public class Pe {
this.status = status;
}
/**
* Gets the byte size of this class.
*
* @return the byte size
*
* @pre $none
* @post $result > 0
*/
// TODO: check necessaty
// public static int getByteSize() {
// int totalInt = 2 * 4; // NOTE: static int doesn't count
// return totalInt;
// }
/**
* Sets the pe provisioner.
*
......
......@@ -77,7 +77,6 @@ public class VmAllocationPolicySimple extends VmAllocationPolicy {
}
if (!getVmTable().containsKey(vm.getUid())) { //if this vm was not created
do {//we still trying until we find a host or until we try all of them
int moreFree = Integer.MIN_VALUE;
int idx = -1;
......@@ -130,38 +129,6 @@ public class VmAllocationPolicySimple extends VmAllocationPolicy {
}
}
/**
* Triggers a migration from a given virtual machine to a selected
* host.
*
* @param vm the vm
*
* @return $true if the migration succeeds; $false otherwise
*
* @pre $none
* @post $none
*/
// TODO: check necessity
// @Override
// public boolean migrateVm(Vm vm, Host destination) {
// //where is this VM running?
// Host source = getHost(vm);
// Vm _vm = source.vmMigrate(vm);
// if (_vm == null) {
// return false;
// }
//
// if (destination == null) {
// return false;
// }
//
// if (destination.getFreePesNumber() >= vm.getPesNumber()) {
// return destination.vmMigrate(vm);
// }
//
// return false;
// }
/**
* Gets the host that is executing the given VM belonging to the
* given user.
......@@ -258,6 +225,9 @@ public class VmAllocationPolicySimple extends VmAllocationPolicy {
return null;
}
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.VmAllocationPolicy#allocateHostForVm(org.cloudbus.cloudsim.Vm, org.cloudbus.cloudsim.Host)
*/
@Override
public boolean allocateHostForVm(Vm vm, Host host) {
if (host.vmCreate(vm)) { //if vm has been succesfully created in the host
......
......@@ -80,6 +80,10 @@ public class VmSchedulerTimeShared extends VmScheduler {
* @return true, if successful
*/
protected boolean allocatePesForVm(String vmUid, List<Double> mipsShareRequested) {
/**
* TODO: add a restriction of the amount of MIPS allocated to a VM. A VM must require
* not more than is the capacity of a PE.
*/
getMipsMapRequested().put(vmUid, mipsShareRequested);
setPesInUse(getPesInUse() + mipsShareRequested.size());
......
......@@ -263,7 +263,6 @@ public class CloudInformationService extends SimEntity {
*
* @param ev a Sim_event object
*
* @see gridsim.CloudInformationService#body()
* @pre ev != null
* @post $none
*/
......
......@@ -63,13 +63,11 @@ public class CloudSim {
/**
* Initialises all the common attributes.
*
* @param numUser number of users
* @param _calendar the _calendar
* @param _traceFlag the _trace flag
*
* @param numUser number of users
* @throws Exception This happens when creating this entity before initialising
* CloudSim package or this entity name is <tt>null</tt> or empty
*
* @pre $none
* @post $none
*/
......@@ -141,12 +139,11 @@ public class CloudSim {
* <p>
* <b>Note</b>: This method should be called after all the entities have
* been setup and added.
* @return
*
* @return the double
* @throws NullPointerException This happens when creating this entity before initialising
* CloudSim package or this entity name is <tt>null</tt> or
* empty.
*
* @see gridsim.CloudSim#init(int, Calendar, boolean)
* @pre $none
* @post $none
......@@ -196,9 +193,8 @@ public class CloudSim {
/**
* Gets a new copy of initial simulation Calendar.
*
* @return a new copy of Calendar object or <tt>null</tt> if CloudSim hasn't
* @return a new copy of Calendar object or if CloudSim hasn't
* been initialized
*
* @see gridsim.CloudSim#init(int, Calendar, boolean, String[], String[],
* String)
* @see gridsim.CloudSim#init(int, Calendar, boolean)
......@@ -218,8 +214,7 @@ public class CloudSim {
/**
* Gets the entity ID of <tt>CloudInformationService</tt>.
*
* @return the Entity ID or <tt>-1</tt> if it is not found
*
* @return the Entity ID or if it is not found
* @pre $none
* @post $result >= -1
*/
......@@ -232,8 +227,7 @@ public class CloudSim {
* of all Cloud hostList.
*
* @return A List containing CloudResource ID (as an Integer object)
* or <tt>null</tt> if a CIS entity hasn't been created before
*
* or if a CIS entity hasn't been created before
* @pre $none
* @post $none
*/
......@@ -279,9 +273,6 @@ public class CloudSim {
/** The pause at. */
private static long pauseAt = Long.MAX_VALUE;
/** The sync obj. */
//private static Object syncObj = new Object();
/** The abrupt terminate. */
private static boolean abruptTerminate = false;
......@@ -332,51 +323,27 @@ public class CloudSim {
* Get the entity with a given id.
*
* @param id the entity's unique id number
*
* @return The entity, or <code>null</code> if it could not be found
*
* @throws SimException If the entity was not found. This error can be left
* unchecked.
* @return The entity, or if it could not be found
*/
public static SimEntity getEntity(int id) {
return entities.get(id);
// SimEntity obj = entities.get(id);
// if (obj == null)
// throw new IllegalArgumentException("Entity " + id +
// " does not exist.");
// else
// return obj;
}
/**
* Get the entity with a given name.
*
* @param name The entity's name
*
* @return The entity
*
* @throws SimException If the entity was not found. This error can be left
* unchecked.
*/
public static SimEntity getEntity(String name) {
return entitiesByName.get(name);
// SimEntity obj = entitiesByName.get(name);
// if (obj == null)
// throw new IllegalArgumentException("Entity " + name +
// " does not exist.");
// else
// return obj;
}
/**
* Get the id of an entity with a given name.
*
* @param name The entity's name
*
* @return The entity's unique id number
*
* @throws SimException If the entity was not found. This error can be left
* unchecked.
*/
public static int getEntityId(String name) {
SimEntity obj = entitiesByName.get(name);
......@@ -391,9 +358,7 @@ public class CloudSim {
* Gets name of the entity given its entity ID.
*
* @param entityID the entity ID
*
* @return the Entity name or <tt>null</tt> if this object does not have one
*
* @return the Entity name or if this object does not have one
* @pre entityID > 0
* @post $none
*/
......@@ -411,9 +376,7 @@ public class CloudSim {
* Gets name of the entity given its entity ID.
*
* @param entityID the entity ID
*
* @return the Entity name or <tt>null</tt> if this object does not have one
*
* @return the Entity name or if this object does not have one
* @pre entityID > 0
* @post $none
*/
......@@ -452,14 +415,13 @@ public class CloudSim {
// Post an event to make this entity
evt = new SimEvent(SimEvent.CREATE, clock, 1, 0, 0, e);
future.addEvent(evt);
}// else {
}
if (e.getId() == -1) { // Only add once!
int id = entities.size();
e.setId(id);
entities.add(e);
entitiesByName.put(e.getName(), e);
}
//}
}
/**
......@@ -475,10 +437,6 @@ public class CloudSim {
} else {
printMessage("Adding: " + e.getName());
}
// int id = entities.size();
// e.setId(id);
// entities.add(e);
// entitiesByName.put(e.getName(), e);
e.startEntity();
}
......@@ -486,7 +444,7 @@ public class CloudSim {
* Internal method used to run one tick of the simulation. This method
* should <b>not</b> be called in simulations.
*
* @return <code>true</code> if the event queue is empty, <code>false</code>
* @return true, if successful
* otherwise
*/
public static boolean runClockTick() {
......@@ -509,8 +467,6 @@ public class CloudSim {
SimEvent first = it.next();
processEvent(first);
future.remove(first);
//it.remove();
//toRemove.add(first);
it = future.iterator();
......@@ -520,7 +476,6 @@ public class CloudSim {
SimEvent next = it.next();
if (next.eventTime() == first.eventTime()) {
processEvent(next);
//it.remove();
toRemove.add(next);
trymore = it.hasNext();
} else {
......@@ -547,9 +502,8 @@ public class CloudSim {
printMessage("Simulation completed.");
}
// Used to hold an entity for some time
/**
* Hold.
* Used to hold an entity for some time.
*
* @param src the src
* @param delay the delay
......@@ -560,9 +514,8 @@ public class CloudSim {
entities.get(src).setState(SimEntity.HOLDING);
}
// Used to pause an entity for some time
/**
* Pause.
* Used to pause an entity for some time.
*
* @param src the src
* @param delay the delay
......@@ -573,9 +526,8 @@ public class CloudSim {
entities.get(src).setState(SimEntity.HOLDING);
}
// Used to send an event from one entity to another
/**
* Send.
* Used to send an event from one entity to another.
*
* @param src the src
* @param dest the dest
......@@ -592,14 +544,10 @@ public class CloudSim {
future.addEvent(e);
}
// Sets an entity's state to be waiting. The predicate used to wait for
// an
// event is now
// passed to Sim_system. Only events that satisfy the predicate will be
// passed to the
// entity. This is done to avoid unnecessary context switches.
/**
* Wait.
* Sets an entity's state to be waiting. The predicate used to wait for an event
* is now passed to Sim_system. Only events that satisfy the predicate will be
* passed to the entity. This is done to avoid unnecessary context switches.
*
* @param src the src
* @param p the p
......@@ -612,11 +560,8 @@ public class CloudSim {
}
}
// Checks if events for a specific entity are present in the deferred
// event
// queue
/**
* Waiting.
* Checks if events for a specific entity are present in the deferred event queue.
*
* @param d the d
* @param p the p
......@@ -636,9 +581,8 @@ public class CloudSim {
return count;
}
// Selects an event matching a predicate
/**
* Select.
* Selects an event matching a predicate.
*
* @param src the src
* @param p the p
......@@ -658,9 +602,8 @@ public class CloudSim {
return ev;
}
// Removes an event from the event queue
/**
* Cancel.
* Removes an event from the event queue.
*
* @param src the src
* @param p the p
......@@ -681,12 +624,9 @@ public class CloudSim {
return ev;
}
// Removes all events that match a given predicate from the future event
// queue
// returns true if at least one event has been cancelled; false
// otherwise
/**
* Cancel all.
* Removes all events that match a given predicate from the future event queue
* returns true if at least one event has been cancelled; false otherwise.
*
* @param src the src
* @param p the p
......@@ -710,30 +650,12 @@ public class CloudSim {
// Private internal methods
//
// Processes an event
/**
* Process event.
* Processes an event.
*
* @param e the e
*/
private static void processEvent(SimEvent e) {
// ADDED TO ALLOW THE SIMULATION TO BE PAUSED
// TODO: check how to pause the simulation
/*
if (clock >= pauseAt)
paused = true;
while (paused) {
try {
syncObj.wait();
} catch (InterruptedException e1) {
// it should not happen, but if does,
// then show it to the user
e1.printStackTrace();
}
}*/
int dest, src;
SimEntity dest_ent;
// Update the system's clock
......@@ -809,19 +731,17 @@ public class CloudSim {
* Check if the simulation is still running. This method should be used by
* entities to check if they should continue executing.
*
* @return <code>true</code> if the simulation is still running,
* <code>false</code> otherwise
* @return if the simulation is still running,
* otherwise
*/
public static boolean running() {
return running;
}
// ADDED TO ALLOW THE SIMULATION TO BE PAUSED AND RESUMED
}
/**
* This method is called if one wants to pause the simulation.
*
* @return <tt>true</tt>if the simulation has been paused or <tt>false</tt>
* @return true, if successful
* otherwise.
*/
public static boolean pauseSimulation() {
......@@ -834,8 +754,7 @@ public class CloudSim {
* time.
*
* @param time the time at which the simulation has to be paused
*
* @return <tt>true</tt>if the simulation has been paused or <tt>false</tt>
* @return true, if successful
* otherwise.
*/
public static boolean pauseSimulation(long time) {
......@@ -851,8 +770,8 @@ public class CloudSim {
* This method is called if one wants to resume the simulation that has
* previously been paused.
*
* @return <tt>true</tt>if the simulation has been restarted or or
* <tt>false</tt> otherwise.
* @return if the simulation has been restarted or or
* otherwise.
*/
public static boolean resumeSimulation() {
paused = false;
......@@ -861,11 +780,8 @@ public class CloudSim {
pauseAt = Long.MAX_VALUE;
}
//syncObj.notify();
return !paused;
}
// END OF METHODS USED TO PAUSE THE SIMULATION
}
/**
* Start the simulation running. This should be called after all the
......@@ -910,7 +826,6 @@ public class CloudSim {
*/
public static void finishSimulation() {
// Allow all entities to exit their body method
if (!abruptTerminate) {
for (SimEntity ent : entities) {
if (ent.getState() != SimEntity.FINISHED) {
......@@ -945,9 +860,8 @@ public class CloudSim {
abruptTerminate = true;
}
// Prints a message about the progress of the simulation
/**
* Prints the message.
* Prints a message about the progress of the simulation.
*
* @param message the message
*/
......@@ -955,6 +869,11 @@ public class CloudSim {
Log.printLine(message);
}
/**
* Checks if is paused.
*
* @return true, if is paused
*/
public static boolean isPaused() {
return paused;
}
......
......@@ -126,21 +126,10 @@ public class HostList {
@SuppressWarnings("unchecked")
public static <T extends Host> T getHostWithFreePe(List<T> hostList, int pesNumber) {
for (T host : hostList) {
// If the machine is failed, do nothing. Otherwise...
//if (!host.getFailed())
if (PeList.getFreePesNumber((List<Pe>) host.getPeList()) >= pesNumber) {
return host;
}
/**************
// Uncomment this if you want more info on the progress of sims
else
{
Log.printLine("HostList2.getMachineWithFreePE(). MachineID: " +
obj.getMachineID() + ". Machine is failed. Try other machine.");
}*/
}
return null;
}
......@@ -167,24 +156,5 @@ public class HostList {
return host.setPeStatus(peId, status);
}
/**
* Gets the byte size of this class.
*
* @return the byte size
*
* @pre $none
* @post $result >= 0
*/
// TODO: check necessity
// public int getByteSize() {
// int byteSize = 0;
//
// for (Host host : this) {
// byteSize += host.getByteSize();
// }
//
// return byteSize;
// }
}
......@@ -202,24 +202,6 @@ public class PeList {
return cnt;
}
/**
* Gets the byte size of PeList internal data members.
*
* @param peList the pe list
* @param resName the res name
* @param hostId the host id
* @param failed the failed
*
* @return the byte size
*
* @pre $none
* @post $result >= 0
*/
// TODO: check necessaty
// public int getByteSize() {
// return size() * Pe.getByteSize();
// }
/**
* Sets the status of PEs of this machine to FAILED.
* NOTE: <tt>resName</tt> and <tt>machineID</tt> are used for debugging
......
......@@ -358,7 +358,7 @@ public class CloudletSchedulerSingleServiceTest {
if (requestedMips2 > totalCurrentMipsForCloudlet) {
requestedMips2 = totalCurrentMipsForCloudlet;
}
// TODO: CloudletSchedulerSingleService.cloudletSubmit change type of cloudlet length from double to int
double expectedCompletiontime2 = 1 + ((CLOUDLET_LENGTH * PES_NUMBER - requestedMips1 * 1)) / requestedMips2;
double actualCompletionTime2 = vmScheduler.updateVmProcessing(1, mipsShare);
assertEquals(expectedCompletiontime2, actualCompletionTime2, 0);
......
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