Search in sources :

Example 11 with TaskData

use of org.ow2.proactive.scheduler.core.db.TaskData in project scheduling by ow2-proactive.

the class TaskDBUtils method fetchTaskData.

private static List<TaskData> fetchTaskData(Session session, DBTaskDataParameters params) {
    Set<TaskStatus> taskStatuses = params.getStatuses();
    boolean hasUser = params.hasUser();
    boolean hasTag = params.hasTag();
    boolean hasDateFrom = params.hasDateFrom();
    boolean hasDateTo = params.hasDateTo();
    String queryPrefix = "select T from TaskData T where ";
    Query query = getQuery(session, params, taskStatuses, hasUser, hasTag, hasDateFrom, hasDateTo, params.getSortParams(), queryPrefix);
    query.setMaxResults(params.getLimit());
    query.setFirstResult(params.getOffset());
    return query.list();
}
Also used : Query(org.hibernate.Query) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus)

Example 12 with TaskData

use of org.ow2.proactive.scheduler.core.db.TaskData in project scheduling by ow2-proactive.

the class TaskResultData method createTaskResultData.

static TaskResultData createTaskResultData(TaskData taskRuntimeData, TaskResultImpl result) {
    TaskResultData resultData = new TaskResultData();
    resultData.setTaskRuntimeData(taskRuntimeData);
    resultData.setLogs(result.getOutput());
    resultData.setPreviewerClassName(result.getPreviewerClassName());
    resultData.setMetadata(result.getMetadata());
    resultData.setPropagatedVariables(result.getPropagatedVariables());
    resultData.setSerializedException(result.getSerializedException());
    resultData.setSerializedValue(result.getSerializedValue());
    resultData.setResultTime(System.currentTimeMillis());
    resultData.setRaw(result.isRaw());
    FlowAction flowAction = result.getAction();
    if (flowAction != null) {
        FlowActionData actionData = new FlowActionData();
        actionData.setDupNumber(flowAction.getDupNumber());
        actionData.setTarget(flowAction.getTarget());
        actionData.setTargetContinuation(flowAction.getTargetContinuation());
        actionData.setTargetElse(flowAction.getTargetElse());
        actionData.setType(flowAction.getType());
        resultData.setFlowAction(actionData);
    }
    return resultData;
}
Also used : FlowAction(org.ow2.proactive.scheduler.common.task.flow.FlowAction)

Example 13 with TaskData

use of org.ow2.proactive.scheduler.core.db.TaskData in project scheduling by ow2-proactive.

the class TestTaskAttributes method testTaskVariables.

@Test
public void testTaskVariables() throws Exception {
    JavaTask task = createDefaultTask("task");
    Map<String, TaskVariable> variables;
    InternalTask taskData;
    variables = new HashMap<>();
    task.setVariables(variables);
    taskData = saveSingleTask(task).getTask(task.getName());
    Assert.assertNotNull(taskData.getVariables());
    Assert.assertTrue(taskData.getVariables().isEmpty());
    variables = new HashMap<>();
    TaskVariable v1 = new TaskVariable();
    v1.setName("p1");
    v1.setValue("v1");
    TaskVariable v2 = new TaskVariable();
    v2.setName("p2");
    v2.setValue("v2");
    variables.put("p1", v1);
    variables.put("p2", v2);
    TaskVariable v3 = new TaskVariable();
    v3.setName("emptyvar");
    variables.put("emptyvar", v3);
    task.setVariables(variables);
    taskData = saveSingleTask(task).getTask(task.getName());
    Assert.assertEquals(3, taskData.getVariables().size());
    Assert.assertEquals("p1", taskData.getVariables().get("p1").getName());
    Assert.assertEquals("p2", taskData.getVariables().get("p2").getName());
    Assert.assertEquals("v1", taskData.getVariables().get("p1").getValue());
    Assert.assertEquals("v2", taskData.getVariables().get("p2").getValue());
    Assert.assertEquals("emptyvar", taskData.getVariables().get("emptyvar").getName());
    Assert.assertNull(taskData.getVariables().get("emptyvar").getValue());
    StringBuilder longString = buildLongString();
    variables = new HashMap<>();
    TaskVariable longVariable = new TaskVariable();
    longVariable.setName("longProperty");
    longVariable.setValue(longString.toString());
    variables.put("longProperty", longVariable);
    task.setVariables(variables);
    taskData = saveSingleTask(task).getTask(task.getName());
    Assert.assertEquals(1, taskData.getVariables().size());
    Assert.assertEquals(longString.toString(), taskData.getVariables().get("longProperty").getValue());
}
Also used : InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) Test(org.junit.Test)

Example 14 with TaskData

use of org.ow2.proactive.scheduler.core.db.TaskData in project scheduling by ow2-proactive.

the class TestTaskAttributes method testForkEnv.

@Test
public void testForkEnv() throws Exception {
    JavaTask task = createDefaultTask("task");
    ForkEnvironment env = new ForkEnvironment();
    task.setForkEnvironment(env);
    InternalTask taskData = saveSingleTask(task).getTask(task.getName());
    Assert.assertNotNull(taskData.getForkEnvironment());
    env = new ForkEnvironment();
    env.setEnvScript(new SimpleScript("forkenvscript", "js", new String[] { "p1", "p2" }));
    task.setForkEnvironment(env);
    taskData = saveSingleTask(task).getTask(task.getName());
    Assert.assertNotNull(taskData.getForkEnvironment().getEnvScript());
    Assert.assertArrayEquals(new String[] { "p1", "p2" }, task.getForkEnvironment().getEnvScript().getParameters());
    env = new ForkEnvironment();
    env.setJavaHome("javahome");
    env.setWorkingDir("workingdir");
    env.addAdditionalClasspath("classpath");
    env.addJVMArgument("jvmargument");
    env.addSystemEnvironmentVariable("var1", "value1");
    StringBuilder longString = buildLongString();
    env.addSystemEnvironmentVariable("longvar", longString.toString());
    task.setForkEnvironment(env);
    taskData = saveSingleTask(task).getTask(task.getName());
    Assert.assertEquals("javahome", taskData.getForkEnvironment().getJavaHome());
    Assert.assertEquals("workingdir", taskData.getForkEnvironment().getWorkingDir());
    Assert.assertEquals(1, taskData.getForkEnvironment().getAdditionalClasspath().size());
    Assert.assertEquals("classpath", taskData.getForkEnvironment().getAdditionalClasspath().get(0));
    Assert.assertEquals(1, taskData.getForkEnvironment().getJVMArguments().size());
    Assert.assertEquals("jvmargument", taskData.getForkEnvironment().getJVMArguments().get(0));
    Assert.assertEquals(2, taskData.getForkEnvironment().getSystemEnvironment().size());
    Assert.assertEquals("value1", taskData.getForkEnvironment().getSystemEnvironment().get("var1"));
    Assert.assertEquals(longString.toString(), taskData.getForkEnvironment().getSystemEnvironment().get("longvar"));
}
Also used : InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) SimpleScript(org.ow2.proactive.scripting.SimpleScript) Test(org.junit.Test)

Example 15 with TaskData

use of org.ow2.proactive.scheduler.core.db.TaskData in project scheduling by ow2-proactive.

the class TestTaskAttributes method testParallelEnv.

@Test
public void testParallelEnv() throws Exception {
    JavaTask task = createDefaultTask("task");
    ParallelEnvironment env = new ParallelEnvironment(5);
    task.setParallelEnvironment(env);
    InternalTask taskData = saveSingleTask(task).getTask(task.getName());
    Assert.assertEquals(5, taskData.getParallelEnvironment().getNodesNumber());
    Assert.assertNull(taskData.getParallelEnvironment().getTopologyDescriptor());
    TopologyDescriptor[] descs = { TopologyDescriptor.ARBITRARY, TopologyDescriptor.BEST_PROXIMITY, TopologyDescriptor.DIFFERENT_HOSTS_EXCLUSIVE, TopologyDescriptor.MULTIPLE_HOSTS_EXCLUSIVE, TopologyDescriptor.SINGLE_HOST, TopologyDescriptor.SINGLE_HOST_EXCLUSIVE, new ThresholdProximityDescriptor(123) };
    for (TopologyDescriptor desc : descs) {
        task = createDefaultTask("task");
        env = new ParallelEnvironment(10, desc);
        task.setParallelEnvironment(env);
        taskData = saveSingleTask(task).getTask(task.getName());
        Assert.assertEquals(10, taskData.getParallelEnvironment().getNodesNumber());
        Assert.assertEquals(taskData.getParallelEnvironment().getTopologyDescriptor().getClass(), desc.getClass());
        if (desc instanceof ThresholdProximityDescriptor) {
            Assert.assertEquals(((ThresholdProximityDescriptor) taskData.getParallelEnvironment().getTopologyDescriptor()).getThreshold(), 123);
        }
    }
}
Also used : InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ThresholdProximityDescriptor(org.ow2.proactive.topology.descriptor.ThresholdProximityDescriptor) TopologyDescriptor(org.ow2.proactive.topology.descriptor.TopologyDescriptor) Test(org.junit.Test)

Aggregations

InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)20 Test (org.junit.Test)12 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)7 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)7 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)5 JobId (org.ow2.proactive.scheduler.common.job.JobId)5 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)5 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)5 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 SimpleTaskLogs (org.ow2.proactive.scheduler.common.task.SimpleTaskLogs)4 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)4 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)4 Query (org.hibernate.Query)3 DBTaskId (org.ow2.proactive.scheduler.core.db.TaskData.DBTaskId)3 List (java.util.List)2 TaskAbortedException (org.ow2.proactive.scheduler.common.exception.TaskAbortedException)2 TaskPreemptedException (org.ow2.proactive.scheduler.common.exception.TaskPreemptedException)2 TaskRestartedException (org.ow2.proactive.scheduler.common.exception.TaskRestartedException)2