use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.
the class SchedulerDBManager method loadJobResult.
@SuppressWarnings("unchecked")
private JobResultImpl loadJobResult(Session session, Query query, JobData job, JobId jobId) {
JobResultImpl jobResult = new JobResultImpl();
jobResult.setJobInfo(job.createJobInfo(jobId));
DBTaskId currentTaskId = null;
List<Object[]> resultList = (List<Object[]>) query.list();
if (resultList.isEmpty()) {
return jobResult;
}
int counter = 0;
for (Object[] result : resultList) {
TaskResultData resultData = (TaskResultData) result[0];
DBTaskId dbTaskId = (DBTaskId) result[1];
String taskName = (String) result[2];
Boolean preciousResult = (Boolean) result[3];
boolean nextTask = !dbTaskId.equals(currentTaskId);
if (nextTask) {
TaskId taskId = TaskIdImpl.createTaskId(jobId, taskName, dbTaskId.getTaskId());
jobResult.addTaskResult(taskName, resultData.toTaskResult(taskId), preciousResult);
currentTaskId = dbTaskId;
}
if (++counter % 100 == 0) {
session.clear();
}
}
return jobResult;
}
use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.
the class TaskData method createTaskData.
static TaskData createTaskData(JobData jobRuntimeData, InternalScriptTask task) {
TaskData taskData = new TaskData();
TaskData.DBTaskId taskId = new DBTaskId();
taskId.setJobId(jobRuntimeData.getId());
taskId.setTaskId(task.getTaskInfo().getTaskId().longValue());
taskData.setId(taskId);
taskData.setDescription(task.getDescription());
taskData.setTag(task.getTag());
taskData.setParallelEnvironment(task.getParallelEnvironment());
taskData.setFlowBlock(task.getFlowBlock());
taskData.setRestartMode(task.getRestartTaskOnError());
taskData.setPreciousLogs(task.isPreciousLogs());
taskData.setPreciousResult(task.isPreciousResult());
taskData.setRunAsMe(task.isRunAsMe());
taskData.setWallTime(task.getWallTime());
taskData.setOnTaskErrorString(task.getOnTaskErrorProperty().getValue());
taskData.setMaxNumberOfExecution(task.getMaxNumberOfExecution());
taskData.setJobData(jobRuntimeData);
taskData.setNumberOfExecutionOnFailureLeft(PASchedulerProperties.NUMBER_OF_EXECUTION_ON_FAILURE.getValueAsInt());
taskData.setNumberOfExecutionLeft(task.getMaxNumberOfExecution());
taskData.setGenericInformation(task.getGenericInformation());
HashMap<String, TaskDataVariable> variables = new HashMap<>();
for (Map.Entry<String, TaskVariable> entry : task.getVariables().entrySet()) {
variables.put(entry.getKey(), TaskDataVariable.create(entry.getKey(), entry.getValue(), taskData));
}
taskData.setVariables(variables);
// set the scheduledTime if the START_AT property exists
Map<String, String> genericInfos = taskData.getGenericInformation();
if (genericInfos != null && genericInfos.containsKey(CommonAttribute.GENERIC_INFO_START_AT_KEY)) {
long scheduledTime = ISO8601DateUtil.toDate(genericInfos.get(CommonAttribute.GENERIC_INFO_START_AT_KEY)).getTime();
taskData.setScheduledTime(scheduledTime);
task.setScheduledTime(scheduledTime);
}
taskData.updateMutableAttributes(task);
if (task.getSelectionScripts() != null) {
List<SelectionScriptData> scripts = new ArrayList<>(task.getSelectionScripts().size());
for (SelectionScript selectionScript : task.getSelectionScripts()) {
scripts.add(SelectionScriptData.createForSelectionScript(selectionScript, taskData));
}
taskData.setSelectionScripts(scripts);
}
if (task.getExecutableContainer() != null) {
taskData.setScript(ScriptData.createForScript(((ScriptExecutableContainer) task.getExecutableContainer()).getScript(), taskData));
}
if (task.getPreScript() != null) {
taskData.setPreScript(ScriptData.createForScript(task.getPreScript(), taskData));
}
if (task.getPostScript() != null) {
taskData.setPostScript(ScriptData.createForScript(task.getPostScript(), taskData));
}
if (task.getCleaningScript() != null) {
taskData.setCleanScript(ScriptData.createForScript(task.getCleaningScript(), taskData));
}
if (task.getFlowScript() != null) {
taskData.setFlowScript(ScriptData.createForFlowScript(task.getFlowScript(), taskData));
}
List<SelectorData> selectorsData = new ArrayList<>();
if (task.getInputFilesList() != null) {
for (InputSelector selector : task.getInputFilesList()) {
selectorsData.add(SelectorData.createForInputSelector(selector, taskData));
}
}
if (task.getOutputFilesList() != null) {
for (OutputSelector selector : task.getOutputFilesList()) {
selectorsData.add(SelectorData.createForOutputSelector(selector, taskData));
}
}
taskData.setDataspaceSelectors(selectorsData);
ForkEnvironment forkEnvironment = task.getForkEnvironment();
if (forkEnvironment != null) {
taskData.setAdditionalClasspath(forkEnvironment.getAdditionalClasspath());
taskData.setJavaHome(forkEnvironment.getJavaHome());
taskData.setJvmArguments(forkEnvironment.getJVMArguments());
taskData.setWorkingDir(forkEnvironment.getWorkingDir());
if (forkEnvironment.getEnvScript() != null) {
taskData.setEnvScript(ScriptData.createForScript(forkEnvironment.getEnvScript(), taskData));
}
Map<String, String> systemEnvironment = forkEnvironment.getSystemEnvironment();
if (systemEnvironment != null) {
List<EnvironmentModifierData> envModifiers = new ArrayList<>(systemEnvironment.size());
for (Map.Entry<String, String> entry : systemEnvironment.entrySet()) {
envModifiers.add(EnvironmentModifierData.create(new PropertyModifier(entry.getKey(), entry.getValue()), taskData));
}
taskData.setEnvModifiers(envModifiers);
}
}
taskData.initTaskType(task);
return taskData;
}
use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.
the class TestJobRuntimeData method testChangePriority.
@Test
public void testChangePriority() throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setPriority(JobPriority.LOW);
InternalJob jobData = defaultSubmitJobAndLoadInternal(false, new TaskFlowJob());
dbManager.changeJobPriority(jobData.getId(), JobPriority.HIGH);
jobData = loadInternalJob(false, jobData.getId());
Assert.assertEquals(JobPriority.HIGH, jobData.getPriority());
}
use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.
the class TestMultipleTasks method testDependencies.
@Test
public void testDependencies() throws Exception {
TaskFlowJob job = new TaskFlowJob();
JavaTask task1 = createDefaultTask("task1");
job.addTask(task1);
JavaTask task2 = createDefaultTask("task2");
job.addTask(task2);
task1.addDependence(task2);
JavaTask task3 = createDefaultTask("task3");
job.addTask(task3);
task2.addDependence(task3);
InternalJob jobData = defaultSubmitJobAndLoadInternal(true, job);
Assert.assertEquals(3, jobData.getITasks().size());
InternalTask taskData1 = jobData.getTask("task1");
InternalTask taskData2 = jobData.getTask("task2");
InternalTask taskData3 = jobData.getTask("task3");
Assert.assertEquals(1, taskData1.getDependences().size());
Assert.assertEquals(1, taskData2.getDependences().size());
Assert.assertNull(taskData3.getDependences());
Assert.assertEquals(taskData2.getId(), taskData1.getDependences().get(0).getId());
Assert.assertEquals(taskData3.getId(), taskData2.getDependences().get(0).getId());
Assert.assertEquals(taskData2.getTaskInfo().getTaskId(), taskData1.getDependences().get(0).getTaskInfo().getTaskId());
Assert.assertEquals(taskData3.getTaskInfo().getTaskId(), taskData2.getDependences().get(0).getTaskInfo().getTaskId());
}
use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.
the class TestTaskRuntimeData method testTaskRuntimeData.
@Test
public void testTaskRuntimeData() throws Exception {
TaskFlowJob job = new TaskFlowJob();
JavaTask task1 = createDefaultTask("task1");
task1.setMaxNumberOfExecution(5);
job.addTask(task1);
InternalJob jobData = defaultSubmitJobAndLoadInternal(true, job);
Assert.assertEquals(1, jobData.getITasks().size());
InternalTask runtimeData = jobData.getITasks().get(0);
Assert.assertEquals("task1", runtimeData.getName());
Assert.assertEquals(TaskStatus.SUBMITTED, runtimeData.getStatus());
Assert.assertEquals(5, runtimeData.getNumberOfExecutionLeft());
Assert.assertEquals(PASchedulerProperties.NUMBER_OF_EXECUTION_ON_FAILURE.getValueAsInt(), runtimeData.getNumberOfExecutionOnFailureLeft());
Assert.assertNull(runtimeData.getDependences());
}
Aggregations