Commit 7b66bab7 authored by Anton Beloglazov's avatar Anton Beloglazov

- Performance optimization

parent c1b660b9
......@@ -543,7 +543,7 @@ public class CloudSim {
SimEvent e = new SimEvent(SimEvent.SEND, clock + delay, src, dest, tag, data);
future.addEvent(e);
}
/**
* Used to send an event from one entity to another, with priority in the queue.
*
......@@ -620,6 +620,25 @@ public class CloudSim {
return ev;
}
/**
* Find first deferred event matching a predicate.
*
* @param src the src
* @param p the p
* @return the sim event
*/
public static SimEvent findFirstDeferred(int src, Predicate p) {
SimEvent ev = null;
Iterator<SimEvent> iterator = deferred.iterator();
while (iterator.hasNext()) {
ev = iterator.next();
if (ev.getDestination() == src && p.match(ev)) {
break;
}
}
return ev;
}
/**
* Removes an event from the event queue.
*
......
......@@ -87,7 +87,7 @@ public class PowerDatacenter extends Datacenter {
// if some time passed since last processing
if (currentTime > getLastProcessTime()) {
double minTime = updateCloudetProcessingWithoutSchedulingFutureEvents();
double minTime = updateCloudetProcessingWithoutSchedulingFutureEventsForce();
if (!isDisableMigrations()) {
List<Map<String, Object>> migrationMap = getVmAllocationPolicy().optimizeAllocation(getVmList());
......@@ -131,6 +131,18 @@ public class PowerDatacenter extends Datacenter {
* @return the double
*/
protected double updateCloudetProcessingWithoutSchedulingFutureEvents() {
if (CloudSim.clock() > getLastProcessTime()) {
return updateCloudetProcessingWithoutSchedulingFutureEventsForce();
}
return 0;
}
/**
* Update cloudet processing without scheduling future events.
*
* @return the double
*/
protected double updateCloudetProcessingWithoutSchedulingFutureEventsForce() {
double currentTime = CloudSim.clock();
double minTime = Double.MAX_VALUE;
double timeDiff = currentTime - getLastProcessTime();
......@@ -191,7 +203,10 @@ public class PowerDatacenter extends Datacenter {
protected void processVmMigrate(SimEvent ev, boolean ack) {
updateCloudetProcessingWithoutSchedulingFutureEvents();
super.processVmMigrate(ev, ack);
updateCloudetProcessingWithoutSchedulingFutureEvents();
SimEvent event = CloudSim.findFirstDeferred(getId(), new PredicateType(CloudSimTags.VM_MIGRATE));
if (event == null || event.eventTime() > CloudSim.clock()) {
updateCloudetProcessingWithoutSchedulingFutureEventsForce();
}
}
/* (non-Javadoc)
......
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