use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class RunningTaskRecoveryWithRecoveredNodeTestBase method action.
@Test
public void action() throws Throwable {
nodes = schedulerHelper.createRMNodeStarterNodes(RunningTaskRecoveryWithForkedTaskExecutorTest.class.getSimpleName(), NB_NODES);
JobId jobid = schedulerHelper.submitJob(new File(JOB_DESCRIPTOR.toURI()).getAbsolutePath());
schedulerHelper.waitForEventJobRunning(jobid);
TaskState taskState = schedulerHelper.getSchedulerInterface().getJobState(jobid).getTasks().get(0);
schedulerHelper.waitForEventTaskRunning(taskState.getJobId(), taskState.getName());
taskState = schedulerHelper.getSchedulerInterface().getJobState(jobid).getTasks().get(0);
String firstExecutionHostInfo = taskState.getTaskInfo().getExecutionHostName();
// wait and restart scheduler
Thread.sleep(RESTART_SCHEDULER_INTER_TIME_IN_MILLISECONDS);
TestScheduler.kill();
Thread.sleep(RESTART_SCHEDULER_INTER_TIME_IN_MILLISECONDS);
schedulerHelper = new SchedulerTHelper(false, new File(getSchedulerReStartConfigurationURL().toURI()).getAbsolutePath(), new File(RM_CONFIGURATION_RESTART.toURI()).getAbsolutePath(), null, false);
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
TestListenJobLogs.TestAppender appender = new TestListenJobLogs.TestAppender(LOGGER_NAME);
String loggerName = Log4JTaskLogs.JOB_LOGGER_PREFIX + jobid;
logForwardingService.removeAllAppenders(LOGGER_NAME);
logForwardingService.addAppender(loggerName, appender);
scheduler.listenJobLogs(jobid, logForwardingService.getAppenderProvider());
System.out.println("Number of nodes: " + schedulerHelper.getResourceManager().getState().getAllNodes().size());
for (String freeNodeUrl : schedulerHelper.getResourceManager().getState().getFreeNodes()) {
// previous executing node should not be free when the nodes are added back to the rm
Assert.assertFalse(firstExecutionHostInfo.contains(freeNodeUrl));
}
// we should have just one running task
JobState jobState = scheduler.getJobState(jobid);
Assert.assertEquals(0, jobState.getNumberOfPendingTasks());
Assert.assertEquals(1, jobState.getNumberOfRunningTasks());
taskState = jobState.getTasks().get(0);
Assert.assertEquals(firstExecutionHostInfo, taskState.getTaskInfo().getExecutionHostName());
appender.waitForLoggingEvent(LOG_EVENT_TIMEOUT, TASK_LOG_OUTPUT_STARTING_STRING + MAXIMUM_STEP_IN_TASK_LOOP);
schedulerHelper.waitForEventJobFinished(jobid);
TaskResult taskResult = scheduler.getJobResult(jobid).getResult(TASK_NAME);
Assert.assertFalse(taskResult.hadException());
Assert.assertEquals(OK_TASK_RESULT_VALUE, taskResult.value());
String logs = taskResult.getOutput().getStdoutLogs();
for (int i = 0; i < MAXIMUM_STEP_IN_TASK_LOOP; i++) {
Assert.assertTrue(logs.contains(TASK_LOG_OUTPUT_STARTING_STRING + i));
}
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class TestScriptTask method forkedTasks.
private void forkedTasks() throws Throwable {
TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
JobId id = schedulerHelper.submitJob(job);
schedulerHelper.waitForEventJobFinished(id);
JobResult jobResult = schedulerHelper.getJobResult(id);
// Hello Work script task
TaskResult simpleTaskResult = jobResult.getResult("simple");
assertEquals(true, simpleTaskResult.value());
assertTrue(simpleTaskResult.getOutput().getAllLogs(false).contains("hello"));
// return binding should be used as task result
TaskResult returnTaskResult = jobResult.getResult("return");
assertEquals("42", returnTaskResult.value().toString());
// results binding should be avaible in dependent tasks
TaskResult resultFromDependentTaskTaskResult = jobResult.getResult("results_from_dependent_task");
assertEquals("42", resultFromDependentTaskTaskResult.value().toString());
// pas properties are exposed in the script task
TaskResult propertiesTaskResult = jobResult.getResult("properties");
String logs = propertiesTaskResult.getOutput().getAllLogs(false);
assertThat(logs, containsString("PA_JOB_ID=" + jobResult.getJobId().value()));
assertThat(logs, containsString("PA_JOB_NAME=" + jobResult.getName()));
assertThat(logs, containsString("PA_TASK_ID=" + propertiesTaskResult.getTaskId().value()));
assertThat(logs, containsString("PA_TASK_NAME=" + propertiesTaskResult.getTaskId().getReadableName()));
assertThat(logs, containsString("PA_TASK_ITERATION=0"));
assertThat(logs, containsString("PA_TASK_REPLICATION=0"));
// the script can be a file
TaskResult fileTaskResult = jobResult.getResult("file");
assertTrue(fileTaskResult.getOutput().getAllLogs(false).contains("Beginning of clean script"));
TaskResult fileAndArgsTaskResult = jobResult.getResult("file_and_args");
assertTrue(fileAndArgsTaskResult.getOutput().getAllLogs(false).contains("My_Magic_Arg"));
// dataspaces binding should be available
TaskResult dataspacesTaskResult = jobResult.getResult("dataspaces");
String dataspacesLogs = dataspacesTaskResult.getOutput().getAllLogs(false);
System.out.println(dataspacesLogs);
String schedulerHome = System.getProperty("pa.scheduler.home");
assertTrue(dataspacesLogs.contains("global=" + schedulerHome));
assertTrue(dataspacesLogs.contains("user=" + schedulerHome));
assertTrue(dataspacesLogs.contains("input=" + schedulerHome));
assertTrue(dataspacesLogs.contains("output=" + schedulerHome));
TaskResult multiNodeTaskResult = jobResult.getResult("multi-node");
String mnLogs = multiNodeTaskResult.getOutput().getAllLogs(false);
assertTrue("Invalid binding for nodesurl", mnLogs.contains("nodesurl=" + (SchedulerStartForFunctionalTest.RM_NODE_NUMBER - 1)));
// script task should be forked by default, ie it will not kill the scheduler on system.exit
JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(id);
TaskResult killJVMTaskResult = jobResult.getResult("killJVM");
assertTrue(killJVMTaskResult.getException() instanceof ForkedJvmProcessException);
TaskState killJVMTaskState = jobState.getHMTasks().get(killJVMTaskResult.getTaskId());
assertEquals(TaskStatus.FAULTY, killJVMTaskState.getStatus());
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerDBManagerTest method testUpdateTaskState.
@Test
public void testUpdateTaskState() throws Exception {
InternalJob job = createTestJob("test", "tag", 1);
service.submitJob(job);
InternalTask internalTask = job.getITasks().get(0);
internalTask.setStatus(TaskStatus.ABORTED);
dbManager.updateTaskState(internalTask);
Page<TaskState> tasks = dbManager.getTaskStates(0, 10, null, 0, 10, null, true, true, true, new SortSpecifierContainer());
assertThat(tasks.getSize()).isEqualTo(1);
TaskState taskState = tasks.getList().get(0);
assertThat(taskState.getStatus()).isEqualTo(TaskStatus.ABORTED);
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerEfficiencyMetricsTest method test.
@Test(timeout = 3600000)
public void test() throws Exception {
ProActiveConfiguration.load();
RMFactory.setOsJavaProperty();
schedulerHelper = new SchedulerTHelper(false, SCHEDULER_CONFIGURATION_START.getPath(), RM_CONFIGURATION_START.getPath(), null);
schedulerHelper.createNodeSourceWithInfiniteTimeout("local", taskNumber);
final TaskFlowJob job = createJob(taskNumber, TASK_DURATION);
long start = System.currentTimeMillis();
jobId = schedulerHelper.submitJob(job);
long submited = System.currentTimeMillis();
schedulerHelper.waitForEventJobFinished(jobId);
final JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobId);
final long finished = jobState.getFinishedTime();
long latestTaskStart = Long.MIN_VALUE;
for (TaskState taskState : jobState.getTasks()) {
if (taskState.getStartTime() > latestTaskStart) {
latestTaskStart = taskState.getStartTime();
}
}
long TCT = submited - start;
long TST = latestTaskStart - submited;
long TTT = finished - latestTaskStart - TASK_DURATION;
logAndAssert("TaskCreationTimeTest", TCT);
logAndAssert("TaskSchedulingTimeTest", TST);
logAndAssert("TaskTerminationTimeTest", TTT);
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class AbstractSmartProxy method syncAwaitedJob.
/**
* This method will synchronize this proxy with a remote Scheduler for the
* given job
*
* @param id job ID
*/
private void syncAwaitedJob(String id) {
AwaitedJob awaitedJob = jobTracker.getAwaitedJob(id);
try {
JobState js = getJobState(id);
for (TaskState ts : js.getTasks()) {
String tname = ts.getName();
AwaitedTask at = awaitedJob.getAwaitedTask(tname);
if ((at != null) && (!at.isTransferring())) {
TaskResult tres = null;
try {
tres = getTaskResult(id, tname);
if (tres != null) {
log.debug("Synchonizing task " + tname + " of job " + id);
taskStateUpdatedEvent(new NotificationData<>(SchedulerEvent.TASK_RUNNING_TO_FINISHED, ts.getTaskInfo()));
}
} catch (NotConnectedException e) {
e.printStackTrace();
} catch (UnknownJobException e) {
log.error("Could not retrieve output data for job " + id + " because this job is not known by the Scheduler. \n ", e);
} catch (UnknownTaskException e) {
log.error("Could not retrieve output data for task " + tname + " of job " + id + " because this task is not known by the Scheduler. \n ", e);
} catch (Exception e) {
log.error("Unexpected error while getting the output data for task " + tname + " of job " + id, e);
}
}
}
if (js.isFinished()) {
jobStateUpdatedEvent(new NotificationData<>(SchedulerEvent.JOB_RUNNING_TO_FINISHED, js.getJobInfo()));
}
} catch (NotConnectedException e) {
log.error("A connection error occured while trying to download output data of Job " + id + ". This job will remain in the list of awaited jobs. Another attempt to dowload the output data will be made next time the application is initialized. ", e);
} catch (UnknownJobException e) {
log.error("Could not retrieve output data for job " + id + " because this job is not known by the Scheduler. \n ", e);
log.warn("Job " + id + " will be removed from the known job list. The system will not attempt again to retrieve data for this job. You could try to manually copy the data from the location " + awaitedJob.getPullURL());
jobTracker.removeAwaitedJob(id);
} catch (PermissionException e) {
log.error("Could not retrieve output data for job " + id + " because you don't have permmission to access this job. You need to use the same connection credentials you used for submitting the job. \n Another attempt to dowload the output data for this job will be made next time the application is initialized. ", e);
}
}
Aggregations