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();
}
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;
}
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());
}
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"));
}
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);
}
}
}
Aggregations