Search in sources :

Example 61 with JobId

use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.

the class SchedulerTHelper method removeJob.

/**
 * Remove a job from Scheduler database.
 * connect as user if needed (if not yet connected as user).
 * @param id of the job to remove from database.
 * @throws Exception if an error occurs at job removal.
 */
public void removeJob(JobId id) throws Exception {
    Scheduler userInt = getSchedulerInterface();
    userInt.removeJob(id);
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler)

Example 62 with JobId

use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.

the class SchedulerTHelper method submitJob.

public JobId submitJob(String jobDescPath) throws Exception {
    Job jobToSubmit = JobFactory.getFactory().createJob(jobDescPath);
    Scheduler userInt = getSchedulerInterface();
    return userInt.submit(jobToSubmit);
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler)

Example 63 with JobId

use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.

the class TestGenericInformation method testWithReplication.

public void testWithReplication() throws Throwable {
    JobId jobId = schedulerHelper.submitJob(createJobWithReplication());
    SchedulerTHelper.log("Job submitted, id " + jobId.toString());
    schedulerHelper.waitForEventJobFinished(jobId);
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    JobState js = scheduler.getJobState(jobId);
    for (TaskState taskState : js.getTasks()) {
        checkTaskState(taskState);
    }
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 64 with JobId

use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.

the class TestTaskIdOrderSameAsDeclarationOrder method task_ids_should_be_ordered_as_task_declaration_order.

@Test
public void task_ids_should_be_ordered_as_task_declaration_order() throws Throwable {
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    JobId id = schedulerHelper.submitJob(job);
    JobState jobState = schedulerHelper.waitForEventJobSubmitted(id);
    List<TaskState> sortedTasksById = sortTasksById(jobState);
    assertEquals("premiere", sortedTasksById.get(0).getName());
    assertEquals("deuxieme", sortedTasksById.get(1).getName());
    assertEquals("troisieme", sortedTasksById.get(2).getName());
    // remove job
    schedulerHelper.waitForEventJobFinished(id);
    schedulerHelper.removeJob(id);
    schedulerHelper.waitForEventJobRemoved(id);
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobState(org.ow2.proactive.scheduler.common.job.JobState) File(java.io.File) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 65 with JobId

use of org.ow2.proactive.scheduler.common.job.JobId 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

JobId (org.ow2.proactive.scheduler.common.job.JobId)179 Test (org.junit.Test)121 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)73 File (java.io.File)58 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)57 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)55 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)55 JobState (org.ow2.proactive.scheduler.common.job.JobState)51 ArrayList (java.util.ArrayList)45 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)43 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)42 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)40 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)38 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)37 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)36 Path (javax.ws.rs.Path)35 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)35 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)34 Produces (javax.ws.rs.Produces)33 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)33