Commit 50eda753 authored by rodrigo.calheiros's avatar rodrigo.calheiros

Bugfixes.

parent 41ed465a
...@@ -145,7 +145,6 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler { ...@@ -145,7 +145,6 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
nextEvent = estimatedFinishTime; nextEvent = estimatedFinishTime;
} }
} }
setPreviousTime(currentTime); setPreviousTime(currentTime);
return nextEvent; return nextEvent;
} }
...@@ -187,7 +186,7 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler { ...@@ -187,7 +186,7 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
for (ResCloudlet rcl : getCloudletPausedList()) { for (ResCloudlet rcl : getCloudletPausedList()) {
if (rcl.getCloudletId() == cloudletId) { if (rcl.getCloudletId() == cloudletId) {
getCloudletPausedList().remove(rcl); getCloudletPausedList().remove(rcl);
rcl.getCloudlet(); return rcl.getCloudlet();
} }
} }
...@@ -383,7 +382,6 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler { ...@@ -383,7 +382,6 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
} else {// no enough free PEs: go to the waiting queue } else {// no enough free PEs: go to the waiting queue
ResCloudlet rcl = new ResCloudlet(cloudlet); ResCloudlet rcl = new ResCloudlet(cloudlet);
rcl.setCloudletStatus(Cloudlet.QUEUED); rcl.setCloudletStatus(Cloudlet.QUEUED);
getCloudletWaitingList().add(rcl); getCloudletWaitingList().add(rcl);
return 0.0; return 0.0;
} }
...@@ -407,7 +405,6 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler { ...@@ -407,7 +405,6 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
long length = cloudlet.getCloudletLength(); long length = cloudlet.getCloudletLength();
length += extraSize; length += extraSize;
cloudlet.setCloudletLength(length); cloudlet.setCloudletLength(length);
return cloudlet.getCloudletLength() / capacity; return cloudlet.getCloudletLength() / capacity;
} }
......
...@@ -93,6 +93,10 @@ public class Datacenter extends SimEntity { ...@@ -93,6 +93,10 @@ public class Datacenter extends SimEntity {
setStorageList(storageList); setStorageList(storageList);
setVmList(new ArrayList<Vm>()); setVmList(new ArrayList<Vm>());
setSchedulingInterval(schedulingInterval); setSchedulingInterval(schedulingInterval);
for (Host host: getCharacteristics().getHostList()) {
host.setDatacenter(this);
}
// 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) {
......
...@@ -100,7 +100,7 @@ public class FederatedDatacenter extends SimEntity { ...@@ -100,7 +100,7 @@ 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>());
// 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) {
throw new Exception(super.getName() + " : Error - this entity has no PEs. Therefore, can't process any Cloudlets."); throw new Exception(super.getName() + " : Error - this entity has no PEs. Therefore, can't process any Cloudlets.");
......
...@@ -56,6 +56,9 @@ public class Host { ...@@ -56,6 +56,9 @@ public class Host {
/** The vms migrating in. */ /** The vms migrating in. */
private List<Vm> vmsMigratingIn; private List<Vm> vmsMigratingIn;
/** THe datacenter where the host is placed */
private Datacenter datacenter;
/** /**
* Instantiates a new host. * Instantiates a new host.
...@@ -582,5 +585,22 @@ public class Host { ...@@ -582,5 +585,22 @@ public class Host {
protected void setVmsMigratingIn(List<Vm> vmsMigratingIn) { protected void setVmsMigratingIn(List<Vm> vmsMigratingIn) {
this.vmsMigratingIn = vmsMigratingIn; this.vmsMigratingIn = vmsMigratingIn;
} }
/**
* Gets the data center.
* @return the data center where the host runs
*/
public Datacenter getDatacenter(){
return this.datacenter;
}
/**
* Sets the data center.
*
* @param datacenter the data center from this host
*/
public void setDatacenter(Datacenter datacenter) {
this.datacenter = datacenter;
}
} }
...@@ -346,6 +346,7 @@ public class ResCloudlet { ...@@ -346,6 +346,7 @@ public class ResCloudlet {
startExecTime = clock; startExecTime = clock;
cloudlet.setExecStartTime(startExecTime); cloudlet.setExecStartTime(startExecTime);
} }
} }
catch(Exception e) { catch(Exception e) {
success = false; success = false;
......
...@@ -543,6 +543,24 @@ public class CloudSim { ...@@ -543,6 +543,24 @@ public class CloudSim {
SimEvent e = new SimEvent(SimEvent.SEND, clock + delay, src, dest, tag, data); SimEvent e = new SimEvent(SimEvent.SEND, clock + delay, src, dest, tag, data);
future.addEvent(e); future.addEvent(e);
} }
/**
* Used to send an event from one entity to another, with priority in the queue.
*
* @param src the src
* @param dest the dest
* @param delay the delay
* @param tag the tag
* @param data the data
*/
public static void sendFirst(int src, int dest, double delay, int tag, Object data) {
if (delay < 0) {
throw new IllegalArgumentException("Send delay can't be negative.");
}
SimEvent e = new SimEvent(SimEvent.SEND, clock + delay, src, dest, tag, data);
future.addEventFirst(e);
}
/** /**
* Sets an entity's state to be waiting. The predicate used to wait for an event * Sets an entity's state to be waiting. The predicate used to wait for an event
......
...@@ -41,6 +41,16 @@ public class FutureQueue { ...@@ -41,6 +41,16 @@ public class FutureQueue {
newEvent.setSerial(serial++); newEvent.setSerial(serial++);
sortedSet.add(newEvent); sortedSet.add(newEvent);
} }
/**
* Add a new event to the head of the queue.
*
* @param newEvent The event to be put in the queue.
*/
public void addEventFirst(SimEvent newEvent) {
newEvent.setSerial(0);
sortedSet.add(newEvent);
}
/** /**
* Returns an iterator to the queue. * Returns an iterator to the queue.
......
...@@ -183,6 +183,109 @@ public abstract class SimEntity implements Cloneable { ...@@ -183,6 +183,109 @@ public abstract class SimEntity implements Cloneable {
public void scheduleNow(String dest, int tag) { public void scheduleNow(String dest, int tag) {
schedule(dest, 0, tag, null); schedule(dest, 0, tag, null);
} }
/**
* Send a high priority event to another entity by id number, with data. Note that the
* tag <code>9999</code> is reserved.
*
* @param dest The unique id number of the destination entity
* @param delay How long from the current simulation time the event
* should be sent
* @param tag An user-defined number representing the type of event.
* @param data The data to be sent with the event.
*/
public void scheduleFirst(int dest, double delay, int tag, Object data) {
if (!CloudSim.running()) {
return;
}
CloudSim.sendFirst(id, dest, delay, tag, data);
}
/**
* Send a high priority event to another entity by id number and with <b>no</b> data.
* Note that the tag <code>9999</code> is reserved.
*
* @param dest The unique id number of the destination entity
* @param delay How long from the current simulation time the event
* should be sent
* @param tag An user-defined number representing the type of event.
*/
public void scheduleFirst(int dest, double delay, int tag) {
scheduleFirst(dest, delay, tag, null);
}
/**
* Send a high priority event to another entity through a port with a given name, with
* data. Note that the tag <code>9999</code> is reserved.
*
* @param dest The name of the port to send the event through
* @param delay How long from the current simulation time the event
* should be sent
* @param tag An user-defined number representing the type of event.
* @param data The data to be sent with the event.
*/
public void scheduleFirst(String dest, double delay, int tag, Object data) {
scheduleFirst(CloudSim.getEntityId(dest), delay, tag, data);
}
/**
* Send a high priority event to another entity through a port with a given name, with
* <b>no</b> data. Note that the tag <code>9999</code> is reserved.
*
* @param dest The name of the port to send the event through
* @param delay How long from the current simulation time the event should be
* sent
* @param tag An user-defined number representing the type of event.
*/
public void scheduleFirst(String dest, double delay, int tag) {
scheduleFirst(dest, delay, tag, null);
}
/**
* Send a high priority event to another entity by id number, with data. Note that the
* tag <code>9999</code> is reserved.
*
* @param dest The unique id number of the destination entity
* @param tag An user-defined number representing the type of event.
* @param data The data to be sent with the event.
*/
public void scheduleFirstNow(int dest, int tag, Object data) {
scheduleFirst(dest, 0, tag, data);
}
/**
* Send a high priority event to another entity by id number and with <b>no</b> data.
* Note that the tag <code>9999</code> is reserved.
*
* @param dest The unique id number of the destination entity
* @param tag An user-defined number representing the type of event.
*/
public void scheduleFirstNow(int dest, int tag) {
scheduleFirst(dest, 0, tag, null);
}
/**
* Send a high priority event to another entity through a port with a given name, with
* data. Note that the tag <code>9999</code> is reserved.
*
* @param dest The name of the port to send the event through
* @param tag An user-defined number representing the type of event.
* @param data The data to be sent with the event.
*/
public void scheduleFirstNow(String dest, int tag, Object data) {
scheduleFirst(CloudSim.getEntityId(dest), 0, tag, data);
}
/**
* Send a high priority event to another entity through a port with a given name, with
* <b>no</b> data. Note that the tag <code>9999</code> is reserved.
*
* @param dest The name of the port to send the event through
* @param tag An user-defined number representing the type of event.
*/
public void scheduleFirstNow(String dest, int tag) {
scheduleFirst(dest, 0, tag, null);
}
/** /**
* Set the entity to be inactive for a time period. * Set the entity to be inactive for a time period.
......
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