Search in sources :

Example 1 with SchedulerDBManager

use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager in project scheduling by ow2-proactive.

the class TestInMemorySchedulerDB method sanityTestJobContent.

@Test
public void sanityTestJobContent() throws Exception {
    SchedulerDBManager dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task1"));
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task2"));
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task3"));
    InternalJob job = InternalJobFactory.createJob(jobDef, BaseSchedulerDBTest.getDefaultCredentials());
    job.setOwner("test");
    dbManager.newJobSubmitted(job);
    Job content = dbManager.loadInitalJobContent(job.getId());
    Assert.assertTrue(content instanceof TaskFlowJob);
    Assert.assertThat(((TaskFlowJob) content).getTasks().size(), is(3));
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Job(org.ow2.proactive.scheduler.common.job.Job) Test(org.junit.Test) ProActiveTest(org.ow2.tests.ProActiveTest)

Example 2 with SchedulerDBManager

use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager in project scheduling by ow2-proactive.

the class BaseSchedulerDBTest method initTest.

@Before
public void initTest() throws Exception {
    if (System.getProperty("pa.scheduler.home") == null) {
        PASchedulerProperties.SCHEDULER_HOME.updateProperty(ClasspathUtils.findSchedulerHome());
    }
    System.out.println("Scheduler home : " + PASchedulerProperties.SCHEDULER_HOME.getValueAsString());
    PASchedulerProperties.TASK_FORK.updateProperty("true");
    CentralPAPropertyRepository.PA_CLASSLOADING_USEHTTP.setValue(false);
    if (inMemory) {
        dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
    } else {
        Configuration config = new Configuration().configure(new File(this.getClass().getResource("/functionaltests/config/hibernate-unit.cfg.xml").toURI()));
        dbManager = new SchedulerDBManager(config, true);
    }
}
Also used : Configuration(org.hibernate.cfg.Configuration) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) File(java.io.File) Before(org.junit.Before)

Example 3 with SchedulerDBManager

use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager in project scheduling by ow2-proactive.

the class SchedulerStateRecoverHelperTest method testRecoverWithCopyAndSortThrowingRuntimeException.

@Test
public void testRecoverWithCopyAndSortThrowingRuntimeException() throws KeyException, JobCreationException {
    RecoveredSchedulerState recoveredState = new Scenario(createJob(JobStatus.RUNNING)).execute(new SchedulerStateRecoverHelperSupplier() {

        @Override
        public SchedulerStateRecoverHelper get(SchedulerDBManager dbManager) {
            return new SchedulerStateRecoverHelper(dbManager) {

                @Override
                protected List<InternalTask> copyAndSort(List<InternalTask> tasks) {
                    throw new RuntimeException("bouh!");
                }
            };
        }
    }, false);
    assertThat(recoveredState.getFinishedJobs()).hasSize(1);
    assertThat(recoveredState.getPendingJobs()).hasSize(0);
    assertThat(recoveredState.getRunningJobs()).hasSize(0);
    assertThat(recoveredState.getFinishedJobs().get(0).getStatus()).isEqualTo(JobStatus.CANCELED);
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) ImmutableList(com.google.common.collect.ImmutableList) Test(org.junit.Test)

Example 4 with SchedulerDBManager

use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager in project scheduling by ow2-proactive.

the class TestInMemorySchedulerDB method sanityLastUpdatedTimeTest.

@Test
public void sanityLastUpdatedTimeTest() throws Exception {
    SchedulerDBManager dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task1"));
    InternalJob job = InternalJobFactory.createJob(jobDef, BaseSchedulerDBTest.getDefaultCredentials());
    job.setOwner("test");
    dbManager.newJobSubmitted(job);
    List<InternalJob> jobs = dbManager.loadJobs(false, job.getId());
    // when job is submitted, the last updated time is initialized as submitted time
    Assert.assertThat(jobs.size(), is(1));
    Assert.assertThat(jobs.get(0).getJobInfo().getLastUpdatedTime(), is(jobs.get(0).getJobInfo().getSubmittedTime()));
    dbManager.changeJobPriority(job.getId(), JobPriority.HIGH);
    jobs = dbManager.loadJobs(false, job.getId());
    // job's priority was changed, the last update time must be greater than submitted time
    long priorityChangedTime = jobs.get(0).getJobInfo().getLastUpdatedTime();
    Assert.assertThat(priorityChangedTime - jobs.get(0).getJobInfo().getSubmittedTime() > 0, is(true));
    dbManager.jobSetToBeRemoved(job.getId());
    jobs = dbManager.loadJobs(false, job.getId());
    // job's state was changed, the last update time must be greater than submitted time
    Assert.assertThat(jobs.get(0).getJobInfo().getLastUpdatedTime() - priorityChangedTime > 0, is(true));
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test) ProActiveTest(org.ow2.tests.ProActiveTest)

Example 5 with SchedulerDBManager

use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager in project scheduling by ow2-proactive.

the class TestInMemorySchedulerDB method sanityTest.

@Test
public void sanityTest() throws Exception {
    SchedulerDBManager dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task1"));
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task2"));
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task3"));
    InternalJob job = InternalJobFactory.createJob(jobDef, BaseSchedulerDBTest.getDefaultCredentials());
    job.setOwner("test");
    dbManager.newJobSubmitted(job);
    dbManager.readAccount("test");
    dbManager.changeJobPriority(job.getId(), JobPriority.HIGH);
    Assert.assertEquals(1, dbManager.loadNotFinishedJobs(true).size());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test) ProActiveTest(org.ow2.tests.ProActiveTest)

Aggregations

SchedulerDBManager (org.ow2.proactive.scheduler.core.db.SchedulerDBManager)19 Test (org.junit.Test)15 JobId (org.ow2.proactive.scheduler.common.job.JobId)10 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)10 HashMap (java.util.HashMap)9 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)9 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)9 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)9 List (java.util.List)7 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)3 ProActiveTest (org.ow2.tests.ProActiveTest)3 File (java.io.File)2 Map (java.util.Map)2 Configuration (org.hibernate.cfg.Configuration)2 Before (org.junit.Before)2 DatabaseManagerException (org.ow2.proactive.db.DatabaseManagerException)2 SchedulerStateRecoverHelper (org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper)2 JobDescriptorImpl (org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl)2 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)2 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)2