Search in sources :

Example 91 with Scheduler

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

the class RunningTaskRecoveryWithDownNodeTest method action.

@Test
public void action() throws Throwable {
    this.createNodes();
    JobId jobid = this.submitJob();
    this.waitForAllTasksToRun(jobid);
    this.killSchedulerAndNodes();
    long timeForSchedulerToBeUp = this.recordSchedulerRestartTime();
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    JobState jobState = scheduler.getJobState(jobid);
    this.checkTasks(jobState);
    this.waitForJobToFinish(jobid);
    this.checkJobResult(jobid, scheduler);
    this.checkSchedulerStateRecoveryDoesNotWaitTaskPingAttemptTimesFrequency(timeForSchedulerToBeUp);
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TestScheduler(functionaltests.utils.TestScheduler) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 92 with Scheduler

use of org.ow2.proactive.scheduler.common.Scheduler 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));
    }
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) TestListenJobLogs(functionaltests.job.log.TestListenJobLogs) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TestScheduler(functionaltests.utils.TestScheduler) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) 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 93 with Scheduler

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

the class TestOperationsWhenUnlinked method checkJobResult.

private void checkJobResult(Scheduler scheduler, JobId jobId, int expectedTasksNumber) throws Throwable {
    JobResult jobResult = scheduler.getJobResult(jobId);
    assertEquals("Unexpected number of task results", expectedTasksNumber, jobResult.getAllResults().size());
    for (TaskResult taskResult : jobResult.getAllResults().values()) {
        log("Task " + taskResult.getTaskId());
        if (taskResult.getException() != null) {
            fail("Unexpected task result exception:" + taskResult.getException());
        }
        assertEquals(taskResult.value(), "Nothing");
    }
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult)

Example 94 with Scheduler

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

the class TestOperationsWhenUnlinked method testSubmitAndPause.

@Test
public void testSubmitAndPause() throws Throwable {
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    log("Submitting job");
    JobId jobId1 = scheduler.submit(createJob());
    log("Killing RM");
    rmHelper.killRM();
    log("Waiting RM_DOWN event");
    schedulerHelper.waitForEventSchedulerState(SchedulerEvent.RM_DOWN, EVENT_TIMEOUT);
    log("Submitting new job");
    JobId jobId2 = scheduler.submit(createJob());
    if (!scheduler.pauseJob(jobId2)) {
        fail("Failed to pause job " + jobId2);
    }
    if (!scheduler.resumeJob(jobId2)) {
        fail("Failed to resume job " + jobId2);
    }
    log("Creating new RM");
    rmHelper = new RMTHelper();
    rmHelper.startRM(null, pnp_port);
    ResourceManager rm = rmHelper.getResourceManager();
    testNode = RMTHelper.createNode("test-node");
    String nodeUrl = testNode.getNode().getNodeInformation().getURL();
    rm.addNode(nodeUrl);
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
    log("Linking new RM");
    if (!scheduler.linkResourceManager(rmHelper.getLocalUrl())) {
        fail("Failed to link another RM");
    }
    log("Waiting when jobs finish");
    schedulerHelper.waitForEventJobFinished(jobId1, EVENT_TIMEOUT);
    schedulerHelper.waitForEventJobFinished(jobId2, EVENT_TIMEOUT);
    checkJobResult(scheduler, jobId1, 1);
    checkJobResult(scheduler, jobId2, 1);
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) JobId(org.ow2.proactive.scheduler.common.job.JobId) ProActiveTest(org.ow2.tests.ProActiveTest)

Example 95 with Scheduler

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

the class TestOperationsWhenUnlinked method createConfigAndStart.

@Before
public void createConfigAndStart() throws Exception {
    if (TestScheduler.isStarted()) {
        SchedulerTHelper.log("Killing previous scheduler.");
        TestScheduler.kill();
    }
    // set property SCHEDULER_RMCONNECTION_AUTO_CONNECT to false so that RM failure is detected more fast
    File configurationFile = new File(SchedulerTestConfiguration.SCHEDULER_DEFAULT_CONFIGURATION.toURI());
    Properties properties = new Properties();
    properties.load(new FileInputStream(configurationFile));
    config = tmpFolder.newFile("scheduler_config.ini");
    properties.put(PASchedulerProperties.SCHEDULER_RMCONNECTION_AUTO_CONNECT.getKey(), "false");
    properties.store(new FileOutputStream(config), null);
    rmHelper = new RMTHelper();
    rmHelper.startRM(null, pnp_port);
    schedulerHelper = new SchedulerTHelper(false, config.getAbsolutePath(), null, rmHelper.getLocalUrl());
}
Also used : FileOutputStream(java.io.FileOutputStream) Properties(java.util.Properties) PASchedulerProperties(org.ow2.proactive.scheduler.core.properties.PASchedulerProperties) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

Scheduler (org.ow2.proactive.scheduler.common.Scheduler)97 JobId (org.ow2.proactive.scheduler.common.job.JobId)51 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)49 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)46 Path (javax.ws.rs.Path)45 Produces (javax.ws.rs.Produces)43 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)42 Test (org.junit.Test)39 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)38 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)36 File (java.io.File)34 GET (javax.ws.rs.GET)34 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)31 SchedulerRestInterface (org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface)31 CLIException (org.ow2.proactive_grid_cloud_portal.cli.CLIException)30 JobState (org.ow2.proactive.scheduler.common.job.JobState)29 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)28 GZIP (org.jboss.resteasy.annotations.GZIP)23 KeyException (java.security.KeyException)20 CredData (org.ow2.proactive.authentication.crypto.CredData)19