Search in sources :

Example 21 with TaskInfo

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

the class TestMultipleHostsRequest method testMultipleHostsRequest.

@Test
public void testMultipleHostsRequest() throws Throwable {
    String task1Name = "task1";
    switch(OperatingSystem.getOperatingSystem()) {
        case windows:
            // set system Property for executable path
            System.setProperty(executablePathPropertyName, new File(executablePathWindows.toURI()).getAbsolutePath());
            break;
        case unix:
            SchedulerTHelper.setExecutable(new File(executablePath.toURI()).getAbsolutePath());
            // set system Property for executable path
            System.setProperty(executablePathPropertyName, new File(executablePath.toURI()).getAbsolutePath());
            break;
        default:
            throw new IllegalStateException("Unsupported operating system");
    }
    // test submission and event reception
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    JobId id = schedulerHelper.submitJob(job);
    schedulerHelper.addExtraNodes(3);
    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, task1Name);
    TaskInfo tInfo = schedulerHelper.waitForEventTaskFinished(id, task1Name);
    log(schedulerHelper.getSchedulerInterface().getTaskResult(id, "task1").getOutput().getAllLogs(false));
    assertEquals(TaskStatus.FINISHED, tInfo.getStatus());
    schedulerHelper.waitForEventJobFinished(id);
    JobResult res = schedulerHelper.getJobResult(id);
    // check that there is one exception in results
    assertTrue(res.getExceptionResults().isEmpty());
    // remove job
    schedulerHelper.removeJob(id);
    schedulerHelper.waitForEventJobRemoved(id);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) File(java.io.File) Test(org.junit.Test)

Example 22 with TaskInfo

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

the class SchedulerFrontend method getTaskIds.

@Override
public Page<TaskId> getTaskIds(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit) throws NotConnectedException, PermissionException {
    RestPageParameters params = new RestPageParameters(frontendState, "getTaskIds", from, to, mytasks, running, pending, finished, offset, limit, taskTag, SortSpecifierContainer.EMPTY_CONTAINER);
    Page<TaskInfo> pTaskInfo;
    pTaskInfo = dbManager.getTasks(params.getFrom(), params.getTo(), params.getTag(), params.getOffset(), params.getLimit(), params.getUserName(), params.isPending(), params.isRunning(), params.isFinished());
    List<TaskId> lTaskId = new ArrayList<TaskId>(pTaskInfo.getList().size());
    for (TaskInfo taskInfo : pTaskInfo.getList()) {
        lTaskId.add(taskInfo.getTaskId());
    }
    return new Page<TaskId>(lTaskId, pTaskInfo.getSize());
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ArrayList(java.util.ArrayList) Page(org.ow2.proactive.scheduler.common.Page)

Example 23 with TaskInfo

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

the class ClientJobState method update.

@Override
public void update(JobInfo info) {
    if (!getId().equals(info.getJobId())) {
        throw new IllegalArgumentException("This job info is not applicable for this job. (expected id is '" + getId() + "' but was '" + info.getJobId() + "'");
    }
    // update job info
    this.jobInfo = new JobInfoImpl((JobInfoImpl) info);
    // update skipped tasks
    if (this.jobInfo.getTasksSkipped() != null) {
        for (TaskId id : tasks.keySet()) {
            if (this.jobInfo.getTasksSkipped().contains(id)) {
                TaskInfoImpl taskInfo = (TaskInfoImpl) tasks.get(id).getTaskInfo();
                taskInfo.setStatus(TaskStatus.SKIPPED);
            }
        }
    }
    // additions and modifications can be caused by control flow actions
    if (this.jobInfo.getModifiedTasks() != null) {
        addTasks(this.jobInfo.getModifiedTasks());
    }
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl)

Example 24 with TaskInfo

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

the class RestSmartProxyTest method testInErrorEventsReception.

@Test(timeout = TEN_MINUTES)
public void testInErrorEventsReception() throws Exception {
    System.out.println("Begin testInErrorEventsReception ");
    TaskFlowJob job = createInErrorJob();
    final Semaphore semaphore = new Semaphore(0);
    printJobXmlRepresentation(job);
    final MutableBoolean taskHasBeenInError = new MutableBoolean(false);
    final MutableBoolean taskMarkedAsFinished = new MutableBoolean(false);
    SchedulerEventListenerExtended listener = new SchedulerEventListenerExtended() {

        @Override
        public void schedulerStateUpdatedEvent(SchedulerEvent eventType) {
            System.out.println("RestSmartProxyTest.schedulerStateUpdatedEvent " + eventType);
        }

        @Override
        public void jobSubmittedEvent(JobState job) {
            System.out.println("RestSmartProxyTest.jobSubmittedEvent");
        }

        @Override
        public void jobStateUpdatedEvent(NotificationData<JobInfo> notification) {
            JobStatus status = notification.getData().getStatus();
            System.out.println("RestSmartProxyTest.jobStateUpdatedEvent, eventType=" + notification.getEventType() + ", jobStatus=" + status);
            if (status == JobStatus.IN_ERROR) {
                semaphore.release();
            }
        }

        @Override
        public void taskStateUpdatedEvent(NotificationData<TaskInfo> notification) {
            TaskStatus status = notification.getData().getStatus();
            System.out.println("RestSmartProxyTest.taskStateUpdatedEvent, taskStatus=" + status);
            if (status == TaskStatus.WAITING_ON_ERROR || status == TaskStatus.IN_ERROR) {
                // IN_ERROR previously
                taskHasBeenInError.setTrue();
            }
            if (status == TaskStatus.FINISHED && taskHasBeenInError.isTrue()) {
                taskMarkedAsFinished.setTrue();
            }
        }

        @Override
        public void usersUpdatedEvent(NotificationData<UserIdentification> notification) {
            System.out.println("RestSmartProxyTest.usersUpdatedEvent " + notification.getData());
        }

        @Override
        public void pullDataFinished(String jobId, String taskName, String localFolderPath) {
            System.out.println("RestSmartProxyTest.pullDataFinished");
        }

        @Override
        public void pullDataFailed(String jobId, String taskName, String remoteFolder_URL, Throwable t) {
            System.out.println("RestSmartProxyTest.pullDataFailed");
        }

        @Override
        public void jobUpdatedFullDataEvent(JobState job) {
            System.out.println("RestSmartProxyTest.jobUpdatedFullDataEvent");
        }
    };
    restSmartProxy.addEventListener(listener);
    JobId jobId = restSmartProxy.submit(job, inputLocalFolder.getAbsolutePath(), pushUrl, outputLocalFolder.getAbsolutePath(), pullUrl, false, false);
    // the next line blocks until jobStateUpdatedEvent is called on the
    // listener
    // with job status set to IN_ERROR
    semaphore.acquire();
    String jobIdAsString = jobId.value();
    System.out.println("Finish in-error task");
    restSmartProxy.finishInErrorTask(jobIdAsString, inerrorTaskName);
    waitForJobFinishState(jobIdAsString);
    assertThat(taskHasBeenInError.booleanValue()).isTrue();
    assertThat(taskMarkedAsFinished.booleanValue()).isTrue();
    System.out.println("End testInErrorEventsReception");
}
Also used : JobStatus(org.ow2.proactive.scheduler.common.job.JobStatus) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) JobState(org.ow2.proactive.scheduler.common.job.JobState) SchedulerEventListenerExtended(org.ow2.proactive.scheduler.smartproxy.common.SchedulerEventListenerExtended) Semaphore(java.util.concurrent.Semaphore) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) JobId(org.ow2.proactive.scheduler.common.job.JobId) SchedulerEvent(org.ow2.proactive.scheduler.common.SchedulerEvent) NotificationData(org.ow2.proactive.scheduler.common.NotificationData) Test(org.junit.Test)

Example 25 with TaskInfo

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

the class DataUtility method taskInfo.

public static TaskInfo taskInfo(TaskInfoData d) {
    TaskInfoImpl impl = new TaskInfoImpl();
    JobIdData jobIdData = d.getJobId();
    if (jobIdData != null) {
        JobId jobId = jobId(jobIdData);
        impl.setJobId(jobId);
        TaskId taskId = taskId(jobId, d.getTaskId());
        impl.setTaskId(taskId);
    }
    impl.setExecutionDuration(d.getExecutionDuration());
    impl.setExecutionHostName(d.getExecutionHostName());
    impl.setInErrorTime(d.getInErrorTime());
    impl.setFinishedTime(d.getFinishedTime());
    impl.setNumberOfExecutionLeft(d.getNumberOfExecutionLeft());
    impl.setNumberOfExecutionOnFailureLeft(d.getNumberOfExecutionOnFailureLeft());
    impl.setStartTime(d.getStartTime());
    impl.setStatus(TaskStatus.valueOf(d.getTaskStatus().name()));
    impl.setName(d.getTaskId().getReadableName());
    impl.setProgress(d.getProgress());
    return impl;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskIdImpl.createTaskId(org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId)

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