Search in sources :

Example 1 with FlowBlock

use of org.ow2.proactive.scheduler.common.task.flow.FlowBlock in project scheduling by ow2-proactive.

the class TagTest method createReplicateTask.

private InternalScriptTask createReplicateTask(String name, InternalTask[] dependences, FlowBlock block, String matchingBlock, int nbRuns) throws InvalidScriptException {
    InternalScriptTask result = createTask(name, dependences, block, matchingBlock);
    FlowScript replicate = FlowScript.createReplicateFlowScript("runs = " + nbRuns + ";");
    result.setFlowScript(replicate);
    return result;
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript)

Example 2 with FlowBlock

use of org.ow2.proactive.scheduler.common.task.flow.FlowBlock in project scheduling by ow2-proactive.

the class FlowChecker method dfsBlocks.

/**
 * Find matching start and end blocks in a task tree using depth first search
 *
 * @param tree task tree to search
 * @param done already treated tasks; multiple dependencies: multiple passes
 * @param env accumulates the previously read start tags
 * @param join stacks previous join targets
 * @throws FlowError
 */
private void dfsBlocks(TaskTree tree, Set<String> done, Stack<TaskTree> env, Stack<TaskTree> join) throws FlowError {
    if (tree.joins.size() > 0 && !tree.joinTrigger) {
        return;
    }
    if (tree.targetOf != null && !done.contains(tree.targetOf.element.getName())) {
        return;
    }
    FlowBlock fb = tree.element.getFlowBlock();
    String name = tree.element.getName();
    if (done.contains(name)) {
        return;
    } else {
        done.add(name);
    }
    switch(fb) {
        case START:
            // push new opening tag in the environment
            env.push(tree);
            break;
        case END:
            // close the last opened block
            TaskTree start = null;
            try {
                start = env.pop();
            } catch (EmptyStackException e) {
                throw new FlowError("Unmatched end block", FlowErrorType.BLOCK, name);
            }
            Block blk = new Block(start, tree);
            blocks.add(blk);
            break;
        case NONE:
            break;
    }
    List<TaskTree> children = new ArrayList<>();
    children.addAll(tree.children);
    if (tree.children.size() == 0) {
        if (tree.element.getFlowScript() != null && tree.element.getFlowScript().getActionType().equals(FlowActionType.IF.toString())) {
            if (tree.targetJoin != null) {
                join.add(tree.targetJoin);
            }
            for (TaskTree t : tree.targets) {
                children.add(t);
            }
        } else if (join.size() > 0) {
            TaskTree pop = join.pop();
            children.add(pop);
            pop.joinTrigger = true;
        }
    }
    // recursive call
    for (TaskTree child : children) {
        dfsBlocks(child, done, env, join);
    }
}
Also used : EmptyStackException(java.util.EmptyStackException) FlowBlock(org.ow2.proactive.scheduler.common.task.flow.FlowBlock) ArrayList(java.util.ArrayList) FlowBlock(org.ow2.proactive.scheduler.common.task.flow.FlowBlock)

Example 3 with FlowBlock

use of org.ow2.proactive.scheduler.common.task.flow.FlowBlock in project scheduling by ow2-proactive.

the class TagTest method createTask.

private InternalScriptTask createTask(String name, InternalTask[] dependences, FlowBlock block, String matchingBlock) {
    InternalScriptTask result = new InternalScriptTask(job);
    result.setName(name);
    if (dependences != null && dependences.length > 0) {
        for (InternalTask dep : dependences) {
            result.addDependence(dep);
        }
    }
    if (block != null) {
        result.setFlowBlock(block);
        result.setMatchingBlock(matchingBlock);
    }
    job.addTask(result);
    return result;
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask)

Example 4 with FlowBlock

use of org.ow2.proactive.scheduler.common.task.flow.FlowBlock in project scheduling by ow2-proactive.

the class TagTest method createLoopTask.

private InternalScriptTask createLoopTask(String name, String scriptContent, InternalTask[] dependences, String targetName, boolean block) throws InvalidScriptException {
    FlowBlock fb = null;
    if (block) {
        fb = FlowBlock.END;
    }
    InternalScriptTask result = createTask(name, dependences, fb, targetName);
    FlowScript loop = FlowScript.createLoopFlowScript(scriptContent, targetName);
    result.setFlowScript(loop);
    return result;
}
Also used : FlowBlock(org.ow2.proactive.scheduler.common.task.flow.FlowBlock) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript)

Aggregations

InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)3 FlowBlock (org.ow2.proactive.scheduler.common.task.flow.FlowBlock)2 FlowScript (org.ow2.proactive.scheduler.common.task.flow.FlowScript)2 ArrayList (java.util.ArrayList)1 EmptyStackException (java.util.EmptyStackException)1 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)1