Search in sources :

Example 21 with JobId

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

the class TestKillTaskWhileExecutingScripts method submitAndCheckJob.

private void submitAndCheckJob(Job job, String tname) throws Exception {
    // test submission and event reception
    FileUtils.deleteQuietly(EndlessExecutable.STARTED_FILE);
    JobId id = schedulerHelper.submitJob(job);
    log("Job submitted, id " + id.toString());
    log("Waiting for jobSubmitted Event");
    Job receivedJob = schedulerHelper.waitForEventJobSubmitted(id);
    assertEquals(receivedJob.getId(), id);
    log("Waiting for job running");
    JobInfo jInfo = schedulerHelper.waitForEventJobRunning(id);
    log("Waiting for task " + tname + " running");
    schedulerHelper.waitForEventTaskRunning(id, tname);
    assertEquals(jInfo.getJobId(), id);
    log("Waiting until file marker is created");
    while (!EndlessExecutable.STARTED_FILE.exists()) {
        Thread.sleep(50);
    }
    log("Kill job");
    assertTrue(schedulerHelper.killJob(id.toString()));
    schedulerHelper.checkNodesAreClean();
}
Also used : JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) Job(org.ow2.proactive.scheduler.common.job.Job) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 22 with JobId

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

the class TestForkedTaskWorkingDir method javaTaskTaskRestartedAnotherNode.

/*
     * SCHEDULING-2129 Mapping for a given space URI is already registered
     * 
     * Run a task, kill the node,let it restart on another node and check the the shared scratch
     * space was correctly setup by transferring a file created in working dir from the task
     */
private void javaTaskTaskRestartedAnotherNode() throws Exception {
    FileLock blockTaskFromTest = new FileLock();
    Path blockTaskFromTestPath = blockTaskFromTest.lock();
    FileLock blockTestBeforeKillingNode = new FileLock();
    Path blockTestBeforeKillingNodePath = blockTestBeforeKillingNode.lock();
    TaskFlowJob job = createFileInLocalSpaceJob(blockTaskFromTestPath.toString(), blockTestBeforeKillingNodePath.toString());
    JobId idJ1 = schedulerHelper.submitJob(job);
    SchedulerTHelper.log("Wait until task is in the middle of the run");
    final String taskNodeUrl = findNodeRunningTask();
    schedulerHelper.waitForEventTaskRunning(idJ1, "task1");
    FileLock.waitUntilUnlocked(blockTestBeforeKillingNodePath);
    SchedulerTHelper.log("Kill the node running the task");
    schedulerHelper.killNode(taskNodeUrl);
    SchedulerTHelper.log("Let the task finish");
    blockTaskFromTest.unlock();
    SchedulerTHelper.log("Waiting for job 1 to finish");
    schedulerHelper.waitForEventJobFinished(idJ1);
    String userSpaceUri = URI.create(schedulerHelper.getSchedulerInterface().getUserSpaceURIs().get(0)).getPath();
    assertTrue("Could not find expected output file", new File(userSpaceUri, "output_file.txt").exists());
}
Also used : Path(java.nio.file.Path) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) FileLock(org.ow2.proactive.scheduler.util.FileLock) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 23 with JobId

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

the class TestLicensePolicy method testLicensePolicy.

/**
 * Tests that two independent tasks do not run at the same time, due to license limitation.
 *
 * @throws Exception
 */
@Test
public void testLicensePolicy() throws Throwable {
    JobId jobId = schedulerHelper.submitJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    log("Waiting for job finished");
    schedulerHelper.waitForEventJobFinished(jobId);
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    TaskState taskState0 = scheduler.getJobState(jobId).getTasks().get(0);
    TaskState taskState1 = scheduler.getJobState(jobId).getTasks().get(1);
    boolean tasksExecutedOneByOne = (taskState0.getFinishedTime() < taskState1.getStartTime()) || (taskState1.getFinishedTime() < taskState0.getStartTime());
    Assert.assertTrue(tasksExecutedOneByOne);
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) 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 24 with JobId

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

the class RunningTaskRecoveryWhenNodesAreReservedInBatchTest method printJobStateAndReturnNumberOfRunningTasks.

private void printJobStateAndReturnNumberOfRunningTasks(JobId jobid) throws Exception {
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    JobState jobState;
    int numberOfPendingTasks;
    int numberOfRunningTasks;
    jobState = scheduler.getJobState(jobid);
    numberOfPendingTasks = jobState.getNumberOfPendingTasks();
    numberOfRunningTasks = jobState.getNumberOfRunningTasks();
    int numberOfFinishedTasks = jobState.getNumberOfFinishedTasks();
    int numberOfInErrorTasks = jobState.getNumberOfInErrorTasks();
    SchedulerTHelper.log("Number of pending tasks " + numberOfPendingTasks);
    SchedulerTHelper.log("Number of running tasks " + numberOfRunningTasks);
    SchedulerTHelper.log("Number of finished tasks " + numberOfFinishedTasks);
    SchedulerTHelper.log("Number of in error tasks " + numberOfInErrorTasks);
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TestScheduler(functionaltests.utils.TestScheduler) JobState(org.ow2.proactive.scheduler.common.job.JobState)

Example 25 with JobId

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

the class RunningTaskRecoveryWhenNodesAreReservedInBatchTest method action.

@Test
public void action() throws Throwable {
    nodes = schedulerHelper.createRMNodeStarterNodes(RunningTaskRecoveryWhenNodesAreReservedInBatchTest.class.getSimpleName(), NB_NODES);
    for (int i = 0; i < NB_NODES; i++) {
        schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
    }
    JobId jobid = schedulerHelper.submitJob(new File(JOB_DESCRIPTOR.toURI()).getAbsolutePath());
    schedulerHelper.waitForEventJobRunning(jobid);
    schedulerHelper.waitForEventTaskFinished(jobid, "Groovy_Task");
    JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobid);
    SchedulerTHelper.log("Total number of tasks: " + jobState.getTotalNumberOfTasks());
    List<TaskState> tasks = jobState.getTasks();
    TaskState fifthTask = tasks.get(5);
    SchedulerTHelper.log("Wait for the fifth task running");
    // we wait for the fifth task to be running so that when we kill the
    // scheduler we have a mix of pending/submitted/running tasks
    schedulerHelper.waitForEventTaskRunning(fifthTask.getJobId(), fifthTask.getName());
    SchedulerTHelper.log("Fifth task is running");
    // restart scheduler
    printRmStateAndReturnNotFreeNodeNumber();
    printJobStateAndReturnNumberOfRunningTasks(jobid);
    TestScheduler.kill();
    schedulerHelper = new SchedulerTHelper(false, new File(SCHEDULER_CONFIGURATION_RESTART.toURI()).getAbsolutePath(), new File(RM_CONFIGURATION_RESTART.toURI()).getAbsolutePath(), null, false);
    SchedulerTHelper.log("Wait for job to finish");
    JobInfo jobInfo = schedulerHelper.waitForEventJobFinished(jobid);
    assertThat(jobInfo.getNumberOfFailedTasks()).isEqualTo(0);
    assertThat(jobInfo.getNumberOfInErrorTasks()).isEqualTo(0);
    // wait for all nodes released
    while (printRmStateAndReturnNotFreeNodeNumber() != 0) {
        schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    }
    // all nodes should be free now
    int notFreeNodeNumber = printRmStateAndReturnNotFreeNodeNumber();
    assertThat(notFreeNodeNumber).isEqualTo(0);
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) 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)

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