Search in sources :

Example 51 with JobInfo

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

the class SchedulerDBManagerTest method testUpdateJobAndTasksState.

@Test
public void testUpdateJobAndTasksState() throws Exception {
    InternalJob job = createTestJob("test", "tag", 1);
    service.submitJob(job);
    job.setStatus(JobStatus.KILLED);
    job.setNumberOfFailedTasks(2);
    job.setNumberOfFaultyTasks(3);
    job.setNumberOfInErrorTasks(5);
    job.setInErrorTime(7);
    InternalTask internalTask = job.getITasks().get(0);
    internalTask.setStatus(TaskStatus.IN_ERROR);
    internalTask.setInErrorTime(11);
    dbManager.updateJobAndTasksState(job);
    Page<JobInfo> jobs = dbManager.getJobs(0, 10, null, true, true, true, null);
    assertThat(jobs.getSize()).isEqualTo(1);
    JobInfo jobInfo = jobs.getList().get(0);
    assertThat(jobInfo.getStatus()).isEqualTo(JobStatus.KILLED);
    assertThat(jobInfo.getNumberOfFailedTasks()).isEqualTo(2);
    assertThat(jobInfo.getNumberOfFaultyTasks()).isEqualTo(3);
    assertThat(jobInfo.getNumberOfInErrorTasks()).isEqualTo(5);
    assertThat(jobInfo.getInErrorTime()).isEqualTo(7);
    Page<TaskState> tasks = dbManager.getTaskStates(0, 10, null, 0, 10, null, true, true, true, new SortSpecifierContainer());
    assertThat(tasks.getSize()).isEqualTo(1);
    TaskState taskState = tasks.getList().get(0);
    assertThat(taskState.getStatus()).isEqualTo(TaskStatus.IN_ERROR);
    assertThat(taskState.getTaskInfo().getInErrorTime()).isEqualTo(11);
}
Also used : SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Example 52 with JobInfo

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

the class TestLoadJobsPagination method checkJobs.

private void checkJobs(List<JobInfo> jobs, Integer... expectedIds) {
    List<Integer> ids = new ArrayList<>();
    for (JobInfo job : jobs) {
        ids.add(Integer.valueOf(job.getJobId().value()));
    }
    Assert.assertEquals(Arrays.asList(expectedIds), ids);
}
Also used : JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ArrayList(java.util.ArrayList)

Example 53 with JobInfo

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

the class SchedulerRuntimeDataMBeanTest method testAsAdmin.

private void testAsAdmin() throws Exception {
    final SchedulerAuthenticationInterface auth = schedulerHelper.getSchedulerAuth();
    final HashMap<String, Object> env = new HashMap<>(1);
    env.put(JMXConnector.CREDENTIALS, new Object[] { TestUsers.DEMO.username, TestUsers.DEMO.password });
    JMXConnector adminJmxConnector = JMXConnectorFactory.connect(new JMXServiceURL(auth.getJMXConnectorURL(JMXTransportProtocol.RMI)), env);
    List<JobInfo> existingFinishedJobs = schedulerHelper.getSchedulerInterface().getJobs(0, 1000, new JobFilterCriteria(false, false, true, true), null).getList();
    int nbFinishedTasks = 0;
    int nbTotalTasks = 0;
    for (JobInfo existingFinishedJob : existingFinishedJobs) {
        nbFinishedTasks += existingFinishedJob.getNumberOfFinishedTasks();
        nbTotalTasks += existingFinishedJob.getTotalNumberOfTasks();
    }
    try {
        MBeanServerConnection connection = adminJmxConnector.getMBeanServerConnection();
        final ObjectName beanName = new ObjectName(SchedulerJMXHelper.RUNTIMEDATA_MBEAN_NAME);
        RuntimeDataMBean bean = JMX.newMXBeanProxy(connection, beanName, RuntimeDataMBean.class);
        checkDataConsistent(bean);
        JobId jobId;
        jobId = schedulerHelper.submitJob(createJobWithFailingTask());
        schedulerHelper.waitForEventTaskWaitingForRestart(jobId, "task1");
        checkDataConsistent(bean);
        schedulerHelper.waitForEventTaskWaitingForRestart(jobId, "task1");
        checkDataConsistent(bean);
        schedulerHelper.waitForEventJobFinished(jobId, 60000);
        checkDataConsistent(bean);
        checkTasksData(bean, 0, 0, 1 + nbFinishedTasks, 1 + nbTotalTasks);
        checkJobData(bean, jobId);
        jobId = schedulerHelper.submitJob(createJobWithMultinodeTask(100));
        Thread.sleep(5000);
        checkDataConsistent(bean);
        checkTasksData(bean, 1, 0, 1 + nbFinishedTasks, 2 + nbTotalTasks);
        schedulerHelper.getSchedulerInterface().killJob(jobId);
        checkDataConsistent(bean);
        checkTasksData(bean, 0, 0, 1 + nbFinishedTasks, 2 + nbTotalTasks);
    } finally {
        adminJmxConnector.close();
    }
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) JobFilterCriteria(org.ow2.proactive.scheduler.common.JobFilterCriteria) HashMap(java.util.HashMap) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) RuntimeDataMBean(org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBean) ObjectName(javax.management.ObjectName) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) JMXConnector(javax.management.remote.JMXConnector) MBeanServerConnection(javax.management.MBeanServerConnection) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 54 with JobInfo

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

the class TestErrorAndFailure method testErrorAndFailure.

@Test
public void testErrorAndFailure() throws Throwable {
    String javaCmd = System.getProperty("java.home") + "/bin/java";
    log("Test 1 : Creating job...");
    // creating job
    TaskFlowJob submittedJob = new TaskFlowJob();
    submittedJob.setName(this.getClass().getSimpleName() + "_12_tasks");
    submittedJob.setDescription("12 tasks job testing the behavior of error code and normal task ending.");
    submittedJob.setMaxNumberOfExecution(10);
    NativeTask finalTask = new NativeTask();
    finalTask.setName("TestMerge");
    finalTask.setCommandLine(new String[] { javaCmd, "-cp", TestScheduler.testClasspath(), NativeTestWithRandomDefault.class.getName(), "final" });
    for (int i = 1; i < 6; i++) {
        NativeTask task = new NativeTask();
        task.setName("Test" + i);
        task.setCommandLine(new String[] { javaCmd, "-cp", TestScheduler.testClasspath(), NativeTestWithRandomDefault.class.getName(), "0" });
        finalTask.addDependence(task);
        submittedJob.addTask(task);
    }
    submittedJob.addTask(finalTask);
    // test submission and event reception
    JobId id = schedulerHelper.submitJob(submittedJob);
    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);
    assertEquals(jInfo.getJobId(), id);
    // TODO how to check that ?
    for (Task t : submittedJob.getTasks()) {
        log("Waiting for task running : " + t.getName());
        schedulerHelper.waitForEventTaskRunning(id, t.getName());
    }
    for (Task t : submittedJob.getTasks()) {
        log("Waiting for task finished : " + t.getName());
        schedulerHelper.waitForEventTaskFinished(id, t.getName());
    }
    log("Waiting for job finished");
    jInfo = schedulerHelper.waitForEventJobFinished(id);
    assertEquals(JobStatus.FINISHED, jInfo.getStatus());
    // check job results
    JobResult res = schedulerHelper.getJobResult(id);
    // Check the results
    Map<String, TaskResult> results = res.getAllResults();
    // check that number of results correspond to number of tasks
    assertEquals(submittedJob.getTasks().size(), results.size());
    // remove jobs and check its event
    schedulerHelper.removeJob(id);
    log("Waiting for job removed");
    jInfo = schedulerHelper.waitForEventJobRemoved(id);
    assertEquals(JobStatus.FINISHED, jInfo.getStatus());
    assertEquals(jInfo.getJobId(), id);
}
Also used : Task(org.ow2.proactive.scheduler.common.task.Task) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) NativeTestWithRandomDefault(org.ow2.proactive.scheduler.examples.NativeTestWithRandomDefault) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) Test(org.junit.Test)

Example 55 with JobInfo

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

the class SchedulerFrontendState method jobStateUpdated.

@Override
public synchronized void jobStateUpdated(String owner, NotificationData<JobInfo> notification) {
    ClientJobState js = jobsMap.get(notification.getData().getJobId());
    synchronized (js) {
        js.update(notification.getData());
        switch(notification.getEventType()) {
            case JOB_PENDING_TO_RUNNING:
                sState.pendingToRunning(js);
                break;
            case JOB_PAUSED:
            case JOB_IN_ERROR:
            case JOB_RESUMED:
            case JOB_RESTARTED_FROM_ERROR:
            case JOB_CHANGE_PRIORITY:
            case TASK_REPLICATED:
            case TASK_SKIPPED:
                break;
            case JOB_PENDING_TO_FINISHED:
                sState.pendingToFinished(js);
                // set this job finished, user can get its result
                jobs.get(notification.getData().getJobId()).setFinished(true);
                break;
            case JOB_RUNNING_TO_FINISHED:
                sState.runningToFinished(js);
                // set this job finished, user can get its result
                jobs.get(notification.getData().getJobId()).setFinished(true);
                break;
            case JOB_REMOVE_FINISHED:
                // removing jobs from the global list : this job is no more managed
                sState.removeFinished(js);
                jobsMap.remove(js.getId());
                jobs.remove(notification.getData().getJobId());
                logger.debug("HOUSEKEEPING removed the finished job " + js.getId() + " from the SchedulerFrontEndState");
                break;
            default:
                logger.warn("**WARNING** - Unconsistent update type received from Scheduler Core : " + notification.getEventType());
                return;
        }
        dispatchJobStateUpdated(owner, notification);
        new JobEmailNotification(js, notification).checkAndSend();
    }
}
Also used : ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState)

Aggregations

JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)31 JobId (org.ow2.proactive.scheduler.common.job.JobId)20 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)9 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)9 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)9 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)9 JobState (org.ow2.proactive.scheduler.common.job.JobState)8 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)8 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)8 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)8 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)7 File (java.io.File)6 HashMap (java.util.HashMap)5 JobFilterCriteria (org.ow2.proactive.scheduler.common.JobFilterCriteria)5 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)5 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)5 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)5 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)5 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)5