use of org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl in project scheduling by ow2-proactive.
the class CheckEligibleTaskDescriptorScriptTest method testOnlyInternalScriptContainsAPIBinding.
@Test
public void testOnlyInternalScriptContainsAPIBinding() throws InvalidScriptException {
Script s = scriptWithApiBindingGlobal();
Script s2 = scriptWithoutApiBinding();
FlowScript fs = flowScriptWithoutApiBinding();
Mockito.when(((EligibleTaskDescriptorImpl) etd).getInternal()).thenReturn(ist);
Mockito.when(ist.getPreScript()).thenReturn(s2);
Mockito.when(ist.getPostScript()).thenReturn(s2);
Mockito.when(it.getCleaningScript()).thenReturn(s2);
Mockito.when(sec.getScript()).thenReturn(s);
Mockito.when(fe.getEnvScript()).thenReturn(s2);
Mockito.when(it.getFlowScript()).thenReturn(fs);
assertTrue(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
use of org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl in project scheduling by ow2-proactive.
the class TaskResultCreatorTest method createEligibleTaskDescriptor.
private EligibleTaskDescriptor createEligibleTaskDescriptor(Vector<TaskDescriptor> fakeParentVector) {
EligibleTaskDescriptorImpl mockedEligibleTaskDescriptorImpl = mock(EligibleTaskDescriptorImpl.class);
when(mockedEligibleTaskDescriptorImpl.getParents()).thenReturn(fakeParentVector);
return mockedEligibleTaskDescriptorImpl;
}
use of org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl in project scheduling by ow2-proactive.
the class LicenseSchedulingPolicy method removeFinishedTasks.
private void removeFinishedTasks(LinkedBlockingQueue<EligibleTaskDescriptor> eligibleTasksDescriptorsLicense) {
Iterator<EligibleTaskDescriptor> iter = eligibleTasksDescriptorsLicense.iterator();
EligibleTaskDescriptorImpl current_task;
while (iter.hasNext()) {
current_task = (EligibleTaskDescriptorImpl) iter.next();
if (current_task.getInternal().getStatus().equals(TaskStatus.FINISHED)) {
iter.remove();
}
}
}
use of org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl in project scheduling by ow2-proactive.
the class JobDescriptorImpl method doReplicate.
/**
* Complete REPLICATE action on JobDescriptor side
*
* @param initiator Task initiating the REPLICATE action
* @param tree InternalTask tree of replicated tasks
* @param target Target task of the REPLICATE action: first task of the block
* @param oldEnd End task of the replicated block ; original version
* @param newEnd End task of the replicated block ; dup version
*/
public void doReplicate(TaskId initiator, Map<TaskId, InternalTask> tree, InternalTask target, TaskId oldEnd, TaskId newEnd) {
Map<TaskId, EligibleTaskDescriptorImpl> acc = new HashMap<>();
// create new EligibleTasks and accumulate it
for (Entry<TaskId, InternalTask> it : tree.entrySet()) {
TaskId itId = it.getValue().getTaskInfo().getTaskId();
EligibleTaskDescriptorImpl td = new EligibleTaskDescriptorImpl(it.getValue());
acc.put(itId, td);
}
// recreate the dependencies
for (Entry<TaskId, InternalTask> it : tree.entrySet()) {
TaskId itId = it.getValue().getTaskInfo().getTaskId();
EligibleTaskDescriptorImpl down = acc.get(itId);
List<InternalTask> ideps = new ArrayList<>();
int deptype = 0;
if (it.getValue().hasDependences()) {
ideps.addAll(it.getValue().getIDependences());
} else if (it.getValue().getIfBranch() != null) {
deptype = 1;
ideps.add(it.getValue().getIfBranch());
} else if (it.getValue().getJoinedBranches() != null) {
deptype = 2;
ideps.addAll(it.getValue().getJoinedBranches());
}
if (ideps != null && !target.equals(itId)) {
for (InternalTask parent : ideps) {
if (parent == null) {
continue;
}
EligibleTaskDescriptorImpl up = acc.get(parent.getId());
if (up == null) {
continue;
}
switch(deptype) {
case 0:
up.addChild(down);
down.addParent(up);
break;
case 1:
case 2:
branchTasks.put(down.getTaskId(), down);
break;
}
}
}
}
EligibleTaskDescriptorImpl oldTask = (EligibleTaskDescriptorImpl) runningTasks.get(initiator);
EligibleTaskDescriptorImpl newTask = acc.get(target.getId());
if (oldTask == null) {
oldTask = (EligibleTaskDescriptorImpl) eligibleTasks.get(initiator);
}
HashSet<TaskId> excl = new HashSet<>();
EligibleTaskDescriptorImpl endTask = (EligibleTaskDescriptorImpl) findTask(oldTask, oldEnd, excl);
if (endTask == null) {
// findTask cannot walk weak dependencies (IF/ELSE) down, lets walk these branches ourselves
for (TaskDescriptor branch : branchTasks.values()) {
endTask = (EligibleTaskDescriptorImpl) findTask(branch, oldEnd, excl);
if (endTask != null) {
break;
}
}
}
EligibleTaskDescriptorImpl end = acc.get(newEnd);
for (TaskDescriptor t : endTask.getChildren()) {
end.addChild(t);
((EligibleTaskDescriptorImpl) t).addParent(end);
}
newTask.addParent(oldTask);
oldTask.addChild(newTask);
eligibleTasks.put(target.getId(), newTask);
}
use of org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl in project scheduling by ow2-proactive.
the class JobDescriptorImpl method restoreInErrorTasks.
public void restoreInErrorTasks() {
final Iterator<Entry<TaskId, EligibleTaskDescriptor>> iterator = eligibleTasks.entrySet().iterator();
while (iterator.hasNext()) {
Entry<TaskId, EligibleTaskDescriptor> entry = iterator.next();
TaskId taskId = entry.getKey();
EligibleTaskDescriptor task = entry.getValue();
if (((EligibleTaskDescriptorImpl) task).getInternal().getStatus() == TaskStatus.IN_ERROR) {
pausedTasks.put(taskId, task);
iterator.remove();
}
}
}
Aggregations