Search in sources :

Example 86 with Scheduler

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

the class TestSmartProxy method init.

@Before
public void init() throws Exception {
    // because of https://issues.jenkins-ci.org/browse/JENKINS-29285, test is unstable on windows
    assumeTrue(OperatingSystem.getOperatingSystem() != OperatingSystem.windows);
    // log all data transfer related events
    ProActiveLogger.getLogger(SchedulerProxyUserInterface.class).setLevel(Level.DEBUG);
    workLocalFolder = new File(workFolderPath);
    inputLocalFolder = new File(workLocalFolder, "input");
    outputLocalFolder = new File(workLocalFolder, "output");
    inputLocalFolder.mkdirs();
    outputLocalFolder.mkdirs();
    // ----------------- start Data Server -------------
    // this simulates a remote data server
    // dataServerURI =
    // dataProvider.deployProActiveDataServer(dataServerFolderPath, "data");
    dataServerURI = (new File(dataServerFolderPath)).toURI().toURL().toExternalForm();
    // start scheduler and nodes
    schedulerHelper.getSchedulerAuth();
    schedProxy = SmartProxyImpl.getActiveInstance();
    schedProxy.cleanDatabase();
    String schedulerUrl = SchedulerTHelper.getLocalUrl();
    schedProxy.setSessionName(TEST_SESSION_NAME);
    schedProxy.init(new ConnectionInfo(schedulerUrl, TestUsers.DEMO.username, TestUsers.DEMO.password, null, true));
    eventListener = new MyEventListener();
    MyEventListener myListenerRemoteReference = PAActiveObject.turnActive(eventListener);
    schedProxy.addEventListener(myListenerRemoteReference);
}
Also used : SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) ConnectionInfo(org.ow2.proactive.authentication.ConnectionInfo) File(java.io.File) Before(org.junit.Before)

Example 87 with Scheduler

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

the class TestKillWhenInStoppedState method testTaskAndJobKilling.

@Test
public void testTaskAndJobKilling() throws Exception {
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    test(SchedulerStatus.FROZEN);
    if (!scheduler.resume()) {
        Assert.fail("Failed to resume scheduler");
    }
    test(SchedulerStatus.PAUSED);
    if (!scheduler.resume()) {
        Assert.fail("Failed to resume scheduler");
    }
    test(SchedulerStatus.STOPPED);
    if (!scheduler.start()) {
        Assert.fail("Failed to start scheduler");
    }
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) Test(org.junit.Test)

Example 88 with Scheduler

use of org.ow2.proactive.scheduler.common.Scheduler 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 89 with Scheduler

use of org.ow2.proactive.scheduler.common.Scheduler 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 90 with Scheduler

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

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