use of es.bsc.es.bsc.compss.scheduler.types.SchedulingEvent in project compss by bsc-wdc.
the class FullGraphResourceScheduler method rescheduleTasks.
public LinkedList<Gap<P, T, I>> rescheduleTasks(long updateId, PriorityQueue<AllocatableAction<P, T, I>> readyActions, PriorityActionSet<P, T, I> selectableActions, LinkedList<AllocatableAction<P, T, I>> runningActions, PriorityQueue<AllocatableAction<P, T, I>> rescheduledActions) {
/*
*
* ReadyActions contains those actions that have no dependencies with other actions scheduled on the node, but
* they have data dependencies with tasks on other resources. They are sorted by the expected time when these
* dependencies will be solved.
*
* SelectableActions contains those actions that have no data dependencies with other actions but they wait for
* resources to be released.
*
* Running actions contains a list of Actions that are executing or potentially executing at the moment.
*
* All Actions that need to be rescheduled have the onOptimization and scheduled flags on.
*
* Those actions that are running or could potentially be started ( no dependencies with other actions in the
* resource) are already locked to avoid their start without being on the runningActions set.
*/
LocalOptimizationState<P, T, I> state = new LocalOptimizationState<>(updateId, myWorker.getDescription());
Gap<P, T, I> gap = state.peekFirstGap();
ResourceDescription gapResource = gap.getResources();
PriorityQueue<SchedulingEvent<P, T, I>> schedulingQueue = new PriorityQueue<SchedulingEvent<P, T, I>>();
// For every running action we create a start event on their real start timeStamp
for (AllocatableAction<P, T, I> action : runningActions) {
manageRunningAction(action, state);
FullGraphSchedulingInformation<P, T, I> actionDSI = (FullGraphSchedulingInformation<P, T, I>) action.getSchedulingInfo();
schedulingQueue.offer(new SchedulingEvent.End<P, T, I>(actionDSI.getExpectedEnd(), action));
}
while (!selectableActions.isEmpty() && !gapResource.isDynamicUseless()) {
AllocatableAction<P, T, I> top = selectableActions.peek();
state.replaceAction(top);
if (state.canActionRun()) {
selectableActions.poll();
// Start the current action
FullGraphSchedulingInformation<P, T, I> topDSI = (FullGraphSchedulingInformation<P, T, I>) top.getSchedulingInfo();
topDSI.lock();
topDSI.clearPredecessors();
manageRunningAction(top, state);
if (tryToLaunch(top)) {
schedulingQueue.offer(new SchedulingEvent.End<P, T, I>(topDSI.getExpectedEnd(), top));
}
} else {
break;
}
}
while (!schedulingQueue.isEmpty() || !readyActions.isEmpty()) {
while (!schedulingQueue.isEmpty()) {
SchedulingEvent<P, T, I> e = schedulingQueue.poll();
/*
* Start Event: - sets the expected start and end times - adds resource dependencies with the previous
* actions - if there's a gap before the dependency -tries to fill it with other tasks - if all the
* resources released by the predecessor are used later - the action is unlocked
*
* End Event:
*/
LinkedList<SchedulingEvent<P, T, I>> result = e.process(state, this, readyActions, selectableActions, rescheduledActions);
for (SchedulingEvent<P, T, I> r : result) {
schedulingQueue.offer(r);
}
}
if (!readyActions.isEmpty()) {
AllocatableAction<P, T, I> topAction = readyActions.poll();
FullGraphSchedulingInformation<P, T, I> topActionDSI = (FullGraphSchedulingInformation<P, T, I>) topAction.getSchedulingInfo();
topActionDSI.lock();
topActionDSI.setToReschedule(false);
schedulingQueue.offer(new SchedulingEvent.Start<P, T, I>(topActionDSI.getExpectedStart(), topAction));
}
}
for (Gap<P, T, I> g : state.getGaps()) {
state.removeTmpGap(g);
}
return state.getGaps();
}
Aggregations