Search in sources :

Example 11 with EligibleTaskDescriptorImpl

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));
}
Also used : SimpleScript(org.ow2.proactive.scripting.SimpleScript) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Script(org.ow2.proactive.scripting.Script) EligibleTaskDescriptorImpl(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Test(org.junit.Test)

Example 12 with EligibleTaskDescriptorImpl

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;
}
Also used : EligibleTaskDescriptorImpl(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl)

Example 13 with EligibleTaskDescriptorImpl

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();
        }
    }
}
Also used : EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) EligibleTaskDescriptorImpl(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl)

Example 14 with EligibleTaskDescriptorImpl

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);
}
Also used : TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 15 with EligibleTaskDescriptorImpl

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();
        }
    }
}
Also used : Entry(java.util.Map.Entry) TaskId(org.ow2.proactive.scheduler.common.task.TaskId)

Aggregations

EligibleTaskDescriptorImpl (org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl)9 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)9 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)8 TaskDescriptor (org.ow2.proactive.scheduler.common.TaskDescriptor)6 EligibleTaskDescriptor (org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor)5 HashMap (java.util.HashMap)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 Entry (java.util.Map.Entry)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Test (org.junit.Test)2 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)2 IOException (java.io.IOException)1 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)1 Node (org.objectweb.proactive.core.node.Node)1 TopologyDisabledException (org.ow2.proactive.resourcemanager.frontend.topology.TopologyDisabledException)1 JobId (org.ow2.proactive.scheduler.common.job.JobId)1 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)1 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)1