Bug fixes:

Datacenter: send ack for cloudlet submission when requested
FederatedDatacenter: send ack for cloudlet submission when requested; 
DatacenterBroker.java: avoid utilization of uninitialized VMs; removal of schedulingInterval field; schedule of internal events.
parent 18ba23d4
...@@ -769,6 +769,16 @@ public class Datacenter extends SimEntity { ...@@ -769,6 +769,16 @@ public class Datacenter extends SimEntity {
send(getId(), estimatedFinishTime, CloudSimTags.VM_DATACENTER_EVENT); send(getId(), estimatedFinishTime, CloudSimTags.VM_DATACENTER_EVENT);
} }
if (ack) {
int[] data = new int[3];
data[0] = getId();
data[1] = cl.getCloudletId();
data[2] = CloudSimTags.TRUE;
// unique tag = operation tag
int tag = CloudSimTags.CLOUDLET_SUBMIT_ACK;
sendNow(cl.getUserId(), tag, data);
}
} }
catch (ClassCastException c) { catch (ClassCastException c) {
Log.printLine(getName() + ".processCloudletSubmit(): " + "ClassCastException error."); Log.printLine(getName() + ".processCloudletSubmit(): " + "ClassCastException error.");
......
...@@ -354,7 +354,7 @@ public class DatacenterBroker extends SimEntity { ...@@ -354,7 +354,7 @@ public class DatacenterBroker extends SimEntity {
if (cloudlet.getVmId() == -1) { //if user didn't bind this cloudlet and it has not been executed yet if (cloudlet.getVmId() == -1) { //if user didn't bind this cloudlet and it has not been executed yet
vm = getVmsCreatedList().get(vmIndex); vm = getVmsCreatedList().get(vmIndex);
} else { //submit to the specific vm } else { //submit to the specific vm
vm = VmList.getById(getVmList(), cloudlet.getVmId()); vm = VmList.getById(getVmsCreatedList(), cloudlet.getVmId());
if (vm == null) { // vm was not created if (vm == null) { // vm was not created
Log.printLine(CloudSim.clock()+": "+getName()+ ": Postponing execution of cloudlet "+cloudlet.getCloudletId()+": bount VM not available"); Log.printLine(CloudSim.clock()+": "+getName()+ ": Postponing execution of cloudlet "+cloudlet.getCloudletId()+": bount VM not available");
continue; continue;
......
...@@ -58,13 +58,12 @@ public class FederatedDatacenter extends SimEntity { ...@@ -58,13 +58,12 @@ public class FederatedDatacenter extends SimEntity {
/** The vm list. */ /** The vm list. */
private List<? extends Vm> vmList; private List<? extends Vm> vmList;
/** The scheduling interval. */
private double schedulingInterval;
protected CloudCoordinator coordinator; protected CloudCoordinator coordinator;
protected List<Integer> federationList; protected List<Integer> federationList;
protected List<Sensor<Double>> sensorsList; protected List<Sensor<Double>> sensorsList;
private int delay = 60*60;
/** /**
* Allocates a new PowerDatacenter object. * Allocates a new PowerDatacenter object.
* *
...@@ -101,7 +100,6 @@ public class FederatedDatacenter extends SimEntity { ...@@ -101,7 +100,6 @@ public class FederatedDatacenter extends SimEntity {
setDebts(new HashMap<Integer,Double>()); setDebts(new HashMap<Integer,Double>());
setStorageList(storageList); setStorageList(storageList);
setVmList(new ArrayList<Vm>()); setVmList(new ArrayList<Vm>());
setSchedulingInterval(schedulingInterval);
// If this resource doesn't have any PEs then no useful at all // If this resource doesn't have any PEs then no useful at all
if (getCharacteristics().getPesNumber() == 0) { if (getCharacteristics().getPesNumber() == 0) {
...@@ -282,6 +280,7 @@ public class FederatedDatacenter extends SimEntity { ...@@ -282,6 +280,7 @@ public class FederatedDatacenter extends SimEntity {
updateCloudletProcessing(); updateCloudletProcessing();
checkCloudletCompletion(); checkCloudletCompletion();
coordinator.updateDatacenter(); coordinator.updateDatacenter();
send(getId(), delay, COORDINATOR_CALL);
} }
/** /**
...@@ -776,7 +775,8 @@ public class FederatedDatacenter extends SimEntity { ...@@ -776,7 +775,8 @@ public class FederatedDatacenter extends SimEntity {
CloudletScheduler scheduler = vm.getCloudletScheduler(); CloudletScheduler scheduler = vm.getCloudletScheduler();
double estimatedFinishTime = scheduler.cloudletSubmit(cl,fileTransferTime); double estimatedFinishTime = scheduler.cloudletSubmit(cl,fileTransferTime);
if (estimatedFinishTime > 0.0 && estimatedFinishTime < getSchedulingInterval()) { //if this cloudlet is in the exec queue //if (estimatedFinishTime > 0.0 && estimatedFinishTime < getSchedulingInterval()) { //if this cloudlet is in the exec queue
if (estimatedFinishTime > 0.0) { //if this cloudlet is in the exec queue
//double estimatedFinishTime = (cl.getCloudletTotalLength()/(capacity*cl.getPesNumber())); //time to process the cloudlet //double estimatedFinishTime = (cl.getCloudletTotalLength()/(capacity*cl.getPesNumber())); //time to process the cloudlet
//Log.printLine(estimatedFinishTime+"="+gl.getCloudletLength()+"/("+capacity+"*"+gl.getNumPE()+")"); //Log.printLine(estimatedFinishTime+"="+gl.getCloudletLength()+"/("+capacity+"*"+gl.getNumPE()+")");
estimatedFinishTime += fileTransferTime; estimatedFinishTime += fileTransferTime;
...@@ -785,6 +785,16 @@ public class FederatedDatacenter extends SimEntity { ...@@ -785,6 +785,16 @@ public class FederatedDatacenter extends SimEntity {
send(getId(), estimatedFinishTime, CloudSimTags.VM_DATACENTER_EVENT); send(getId(), estimatedFinishTime, CloudSimTags.VM_DATACENTER_EVENT);
} }
if (ack) {
int[] data = new int[3];
data[0] = getId();
data[1] = cl.getCloudletId();
data[2] = CloudSimTags.TRUE;
// unique tag = operation tag
int tag = CloudSimTags.CLOUDLET_SUBMIT_ACK;
sendNow(cl.getUserId(), tag, data);
}
} }
catch (ClassCastException c) { catch (ClassCastException c) {
Log.printLine(getName() + ".processCloudletSubmit(): " + "ClassCastException error."); Log.printLine(getName() + ".processCloudletSubmit(): " + "ClassCastException error.");
...@@ -919,16 +929,15 @@ public class FederatedDatacenter extends SimEntity { ...@@ -919,16 +929,15 @@ public class FederatedDatacenter extends SimEntity {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
Host host = list.get(i); Host host = list.get(i);
double time = host.updateVmsProcessing(CloudSim.clock());//inform VMs to update processing double time = host.updateVmsProcessing(CloudSim.clock());//inform VMs to update processing
//what time do we expect that the next cloudlet will finish? //what time do we expect that the next cloudlet will finish?
if (time < smallerTime) { if (time < smallerTime) {
smallerTime = time; smallerTime = time;
} }
} }
//schedules an event to the next time, if valid //schedules an event to the next time, if valid
if (smallerTime > CloudSim.clock() + 0.01 && smallerTime != Double.MAX_VALUE && smallerTime < getSchedulingInterval()) { //if (smallerTime > CloudSim.clock() + 0.01 && smallerTime != Double.MAX_VALUE && smallerTime < getSchedulingInterval()) {
schedule(getId(), (long) (smallerTime - CloudSim.clock()), CloudSimTags.VM_DATACENTER_EVENT); if (smallerTime > CloudSim.clock() + 0.01 && smallerTime != Double.MAX_VALUE) {
schedule(getId(), (smallerTime - CloudSim.clock()), CloudSimTags.VM_DATACENTER_EVENT);
} }
setLastProcessTime(CloudSim.clock()); setLastProcessTime(CloudSim.clock());
} }
...@@ -1106,6 +1115,9 @@ public class FederatedDatacenter extends SimEntity { ...@@ -1106,6 +1115,9 @@ public class FederatedDatacenter extends SimEntity {
gisID = CloudSim.getCloudInfoServiceEntityId(); gisID = CloudSim.getCloudInfoServiceEntityId();
} }
//schedule an internal event for coordinator
send(getId(), delay, COORDINATOR_CALL);
// send the registration to GIS // send the registration to GIS
sendNow(gisID, CloudSimTags.REGISTER_RESOURCE, getId()); sendNow(gisID, CloudSimTags.REGISTER_RESOURCE, getId());
// Below method is for a child class to override // Below method is for a child class to override
...@@ -1254,24 +1266,6 @@ public class FederatedDatacenter extends SimEntity { ...@@ -1254,24 +1266,6 @@ public class FederatedDatacenter extends SimEntity {
this.vmList = vmList; this.vmList = vmList;
} }
/**
* Gets the scheduling interval.
*
* @return the scheduling interval
*/
protected double getSchedulingInterval() {
return schedulingInterval;
}
/**
* Sets the scheduling interval.
*
* @param schedulingInterval the new scheduling interval
*/
protected void setSchedulingInterval(double schedulingInterval) {
this.schedulingInterval = schedulingInterval;
}
public void addSensor(Sensor<Double> sensor){ public void addSensor(Sensor<Double> sensor){
sensor.setDatacenter(this); sensor.setDatacenter(this);
this.sensorsList.add(sensor); this.sensorsList.add(sensor);
......
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