Search in sources :

Example 26 with JobState

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

the class ClientJobStateTest method createJobState.

private JobState createJobState(final JobInfoImpl jobInfo) {
    return new JobState() {

        @Override
        public void update(TaskInfo info) {
        }

        @Override
        public void update(JobInfo jobInfo) {
        }

        @Override
        public JobInfo getJobInfo() {
            return jobInfo;
        }

        @Override
        public List<TaskState> getTasks() {
            List<TaskState> tasks = new ArrayList<>(0);
            tasks.add(new TaskState() {

                @Override
                public void update(TaskInfo taskInfo) {
                }

                @Override
                public List<TaskState> getDependences() {
                    return null;
                }

                @Override
                public TaskInfo getTaskInfo() {
                    TaskInfoImpl taskInfo = new TaskInfoImpl();
                    taskInfo.setJobInfo(jobInfo);
                    taskInfo.setTaskId(TaskIdImpl.createTaskId(jobInfo.getJobId(), "task", 1));
                    return taskInfo;
                }

                @Override
                public int getMaxNumberOfExecutionOnFailure() {
                    return 0;
                }

                @Override
                public TaskState replicate() throws Exception {
                    return null;
                }

                @Override
                public int getIterationIndex() {
                    return 0;
                }

                @Override
                public int getReplicationIndex() {
                    return 0;
                }
            });
            return tasks;
        }

        @Override
        public Map<TaskId, TaskState> getHMTasks() {
            return null;
        }

        @Override
        public String getOwner() {
            return null;
        }

        @Override
        public JobType getType() {
            return null;
        }
    };
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ArrayList(java.util.ArrayList) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) ArrayList(java.util.ArrayList) List(java.util.List) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 27 with JobState

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

the class SchedulerClientExample method main.

public static void main(String[] args) throws Exception {
    // LOGIN IN
    SchedulerRestClient client = new SchedulerRestClient("http://localhost:9191/rest/rest/");
    SchedulerRestInterface scheduler = client.getScheduler();
    String sessionId = scheduler.login("admin", "admin");
    // JOB SUBMISSION
    File xmlJobFile = new File("/home/ybonnaffe/src/cloud_service_provider_conectors/cloudstack/vminfo_job.xml");
    JobIdData xmlJob;
    try (FileInputStream inputStream = new FileInputStream(xmlJobFile)) {
        xmlJob = client.submitXml(sessionId, inputStream);
    }
    System.out.println(xmlJob.getReadableName() + " " + xmlJob.getId());
    // FLAT JOB SUBMISSION
    JobIdData flatJob = scheduler.submitFlat(sessionId, "echo hello", "test-hello", null, null);
    System.out.println("Jobid=" + flatJob);
    String serverlog = scheduler.jobServerLog(sessionId, Long.toString(flatJob.getId()));
    System.out.println(serverlog);
    while (true) {
        JobStateData jobState2 = scheduler.listJobs(sessionId, Long.toString(flatJob.getId()));
        System.out.println(jobState2);
        if (jobState2.getJobInfo().getStatus().name().equals("FINISHED")) {
            break;
        }
        Thread.sleep(100);
    }
    JobResultData jobResultData = scheduler.jobResult(sessionId, Long.toString(flatJob.getId()));
    System.out.println(jobResultData);
    TaskResultData taskresult = scheduler.taskResult(sessionId, Long.toString(flatJob.getId()), "task_1");
    System.out.println(taskresult);
    List<TaskStateData> jobTaskStates = scheduler.getJobTaskStates(sessionId, Long.toString(flatJob.getId())).getList();
    System.out.println(jobTaskStates);
    TaskStateData task_1 = scheduler.jobTask(sessionId, Long.toString(flatJob.getId()), "task_1");
    System.out.println(task_1);
    // OTHER CALLS
    List<SchedulerUserData> users = scheduler.getUsers(sessionId);
    System.out.println(users);
    System.out.println(users.size());
    RestMapPage<Long, ArrayList<UserJobData>> page = scheduler.revisionAndJobsInfo(sessionId, 0, 50, true, true, true, true);
    Map<Long, ArrayList<UserJobData>> map = page.getMap();
    System.out.println(map);
    System.out.println(scheduler.getSchedulerStatus(sessionId));
    System.out.println(scheduler.getUsageOnMyAccount(sessionId, new Date(), new Date()));
    // FAILING CALL
    try {
        JobStateData jobState = scheduler.listJobs(sessionId, "601");
        System.out.println(jobState);
    } catch (UnknownJobRestException e) {
        System.err.println("exception! " + e.getMessage());
        e.printStackTrace();
    }
}
Also used : JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) JobResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) ArrayList(java.util.ArrayList) JobStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobStateData) SchedulerUserData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.SchedulerUserData) FileInputStream(java.io.FileInputStream) Date(java.util.Date) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) File(java.io.File)

Example 28 with JobState

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

the class SchedulerFrontendState method getTaskState.

synchronized TaskState getTaskState(JobId jobId, TaskId taskId) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_TASK);
    if (jobsMap.get(jobId) == null) {
        throw new UnknownJobException(jobId);
    }
    JobState jobState = jobsMap.get(jobId);
    synchronized (jobState) {
        TaskState ts = jobState.getHMTasks().get(taskId);
        if (ts == null) {
            throw new UnknownTaskException(taskId, jobId);
        }
        return ts;
    }
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobState(org.ow2.proactive.scheduler.common.job.JobState) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 29 with JobState

use of org.ow2.proactive.scheduler.common.job.JobState 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 30 with JobState

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

JobState (org.ow2.proactive.scheduler.common.job.JobState)67 Test (org.junit.Test)34 JobId (org.ow2.proactive.scheduler.common.job.JobId)28 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)25 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)23 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)19 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)17 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)17 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)15 ArrayList (java.util.ArrayList)14 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)14 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)14 GET (javax.ws.rs.GET)13 Path (javax.ws.rs.Path)13 Produces (javax.ws.rs.Produces)13 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)13 File (java.io.File)12 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)9 ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)9 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)8