Search in sources :

Example 11 with TaskInfo

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

the class TaskResultCreatorTest method getMockedInternalTask.

private InternalTask getMockedInternalTask() {
    InternalTask mockedInternalTask = mock(InternalScriptTask.class);
    TaskInfo mockedTaskInfo = this.getMockedTaskInfo();
    when(mockedInternalTask.getTaskInfo()).thenReturn(mockedTaskInfo);
    when(mockedInternalTask.getId()).thenReturn(this.createTaskID());
    when(mockedInternalTask.handleResultsArguments()).thenReturn(true);
    return mockedInternalTask;
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask)

Example 12 with TaskInfo

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

the class TaskResultCreatorTest method getMockedTaskInfo.

private TaskInfo getMockedTaskInfo() {
    TaskInfo mockedTaskInfo = mock(TaskInfo.class);
    when(mockedTaskInfo.getJobId()).thenReturn(this.createJobId());
    when(mockedTaskInfo.getTaskId()).thenReturn(this.createTaskID());
    return mockedTaskInfo;
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo)

Example 13 with TaskInfo

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

the class JobDescriptorImplTest method testThatDoLoopPausesNewlyCreatedTasksIfJobIsPaused.

@Test
public void testThatDoLoopPausesNewlyCreatedTasksIfJobIsPaused() {
    JobDescriptorImpl pausedJob = createEmptyJobDescriptor();
    pausedJob.getInternal().setStatus(JobStatus.PAUSED);
    // Create mocks for the loop root task
    TaskId runningRootTaskId = TaskIdImpl.createTaskId(new JobIdImpl(1L, "Root"), "FirstLoopTask", 1L);
    EligibleTaskDescriptorImpl mockLoopStartCurrentlyRunningTask = mock(EligibleTaskDescriptorImpl.class);
    InternalTask mockInternalLoopRootTask = mock(InternalTask.class);
    when(mockInternalLoopRootTask.getId()).thenReturn(runningRootTaskId);
    when(mockLoopStartCurrentlyRunningTask.getTaskId()).thenReturn(runningRootTaskId);
    when(mockLoopStartCurrentlyRunningTask.getInternal()).thenReturn(mockInternalLoopRootTask);
    when(mockLoopStartCurrentlyRunningTask.getChildren()).thenReturn(new Vector<TaskDescriptor>());
    // Create mocks for the new loop task
    TaskId newLoopTaskId = TaskIdImpl.createTaskId(new JobIdImpl(1L, "Root"), "SecondLoopTask", 2L);
    EligibleTaskDescriptorImpl mockLoopNewCreatedTaskForLoop = mock(EligibleTaskDescriptorImpl.class);
    InternalTask mockInternalNewLoopTask = mock(InternalTask.class);
    TaskInfo mockNewTaskTaskInfo = mock(TaskInfo.class);
    when(mockNewTaskTaskInfo.getTaskId()).thenReturn(newLoopTaskId);
    when(mockInternalNewLoopTask.getId()).thenReturn(newLoopTaskId);
    when(mockInternalNewLoopTask.getStatus()).thenReturn(TaskStatus.SUBMITTED);
    when(mockInternalNewLoopTask.getTaskInfo()).thenReturn(mockNewTaskTaskInfo);
    when(mockLoopNewCreatedTaskForLoop.getTaskId()).thenReturn(newLoopTaskId);
    when(mockLoopNewCreatedTaskForLoop.getInternal()).thenReturn(mockInternalNewLoopTask);
    // Put the root loop task into running tasks, because it just terminated
    pausedJob.getRunningTasks().put(mockLoopStartCurrentlyRunningTask.getTaskId(), mockLoopStartCurrentlyRunningTask);
    // Put the new loop task into the Map, this is clue so that the test works
    HashMap<TaskId, InternalTask> workflowTree = new HashMap<>();
    workflowTree.put(newLoopTaskId, mockInternalNewLoopTask);
    pausedJob.doLoop(mockLoopStartCurrentlyRunningTask.getTaskId(), workflowTree, mockLoopNewCreatedTaskForLoop.getInternal(), mockLoopNewCreatedTaskForLoop.getInternal());
    verify(mockInternalNewLoopTask).setStatus(TaskStatus.PAUSED);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) HashMap(java.util.HashMap) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Test(org.junit.Test)

Example 14 with TaskInfo

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

the class AbstractSmartProxy method updateTask.

/**
 * Check if the task concerned by this notification is awaited. Retrieve
 * corresponding data if needed
 *
 * @param notification
 */
protected void updateTask(NotificationData<TaskInfo> notification) {
    // am I interested in this task?
    TaskInfo taskInfoData = notification.getData();
    JobId id = taskInfoData.getJobId();
    TaskId tid = taskInfoData.getTaskId();
    String tname = tid.getReadableName();
    TaskStatus status = taskInfoData.getStatus();
    AwaitedJob aj = jobTracker.getAwaitedJob(id.toString());
    if (aj == null)
        return;
    AwaitedTask at = aj.getAwaitedTask(tname);
    if (at == null)
        return;
    at.setTaskId(tid.toString());
    jobTracker.putAwaitedJob(id.toString(), aj);
    switch(status) {
        case ABORTED:
        case NOT_RESTARTED:
        case NOT_STARTED:
        case SKIPPED:
            {
                log.debug("The task " + tname + " from job " + id + " couldn't start. No data will be transfered");
                jobTracker.removeAwaitedTask(id.toString(), tname);
                break;
            }
        case FINISHED:
            {
                log.debug("The task " + tname + " from job " + id + " is finished.");
                if (aj.isAutomaticTransfer()) {
                    log.debug("Transferring data for finished task " + tname + " from job " + id);
                    try {
                        downloadTaskOutputFiles(aj, id.toString(), tname, aj.getLocalOutputFolder());
                    } catch (Throwable t) {
                        log.error("Error while handling data for finished task " + tname + " for job " + id + ", task will be removed");
                        jobTracker.removeAwaitedTask(id.toString(), tname);
                    }
                }
                break;
            }
        case FAILED:
        case FAULTY:
            {
                log.debug("The task " + tname + " from job " + id + " is faulty.");
                jobTracker.removeAwaitedTask(id.toString(), tname);
                break;
            }
    }
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 15 with TaskInfo

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

the class TestJobNativeSubmission method testJobNativeSubmission.

@Test
public void testJobNativeSubmission() throws Throwable {
    // test submission and event reception
    TaskFlowJob job = new TaskFlowJob();
    NativeTask successfulTask = new NativeTask();
    successfulTask.setName("successfulTask");
    if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
        successfulTask.setCommandLine("cmd", "/C", "ping 127.0.0.1 -n 10", ">", "NUL");
    } else {
        successfulTask.setCommandLine("ping", "-c", "5", "127.0.0.1");
    }
    job.addTask(successfulTask);
    NativeTask invalidCommandTask = new NativeTask();
    invalidCommandTask.setName("invalidCommandTask");
    invalidCommandTask.addDependence(successfulTask);
    invalidCommandTask.setCommandLine("invalid_command");
    job.addTask(invalidCommandTask);
    // SCHEDULING-1987
    NativeTask taskReadingInput = new NativeTask();
    taskReadingInput.setName("taskReadingInput");
    if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
        // wait for y/n
        taskReadingInput.setCommandLine("choice");
    } else {
        // cat hangs for user's input
        taskReadingInput.setCommandLine("cat");
    }
    job.addTask(taskReadingInput);
    JobId id = schedulerHelper.submitJob(job);
    log("Job submitted, id " + id.toString());
    log("Waiting for jobSubmitted Event");
    JobState receivedState = schedulerHelper.waitForEventJobSubmitted(id);
    assertEquals(receivedState.getId(), id);
    log("Waiting for job running");
    JobInfo jInfo = schedulerHelper.waitForEventJobRunning(id);
    assertEquals(jInfo.getJobId(), id);
    assertEquals(JobStatus.RUNNING, jInfo.getStatus());
    schedulerHelper.waitForEventTaskRunning(id, successfulTask.getName());
    TaskInfo tInfo = schedulerHelper.waitForEventTaskFinished(id, successfulTask.getName());
    assertEquals(TaskStatus.FINISHED, tInfo.getStatus());
    schedulerHelper.waitForEventTaskRunning(id, invalidCommandTask.getName());
    tInfo = schedulerHelper.waitForEventTaskFinished(id, invalidCommandTask.getName());
    assertEquals(TaskStatus.FAULTY, tInfo.getStatus());
    TaskInfo taskReadingInputInfo = schedulerHelper.waitForEventTaskFinished(id, taskReadingInput.getName());
    if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
        // choice fails when input is closed
        assertEquals(TaskStatus.FAULTY, taskReadingInputInfo.getStatus());
    } else {
        assertEquals(TaskStatus.FINISHED, taskReadingInputInfo.getStatus());
    }
    schedulerHelper.waitForEventJobFinished(id);
    // remove job
    schedulerHelper.removeJob(id);
    schedulerHelper.waitForEventJobRemoved(id);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) Test(org.junit.Test)

Aggregations

TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)26 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)15 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)14 JobId (org.ow2.proactive.scheduler.common.job.JobId)10 Test (org.junit.Test)8 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)7 JobState (org.ow2.proactive.scheduler.common.job.JobState)7 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)6 ArrayList (java.util.ArrayList)5 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)5 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)4 TaskStatus (org.ow2.proactive.scheduler.common.task.TaskStatus)4 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)4 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)4 File (java.io.File)3 TaskAbortedException (org.ow2.proactive.scheduler.common.exception.TaskAbortedException)3 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)3 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)3 TaskInfoData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData)3 Page (org.ow2.proactive.scheduler.common.Page)2