Search in sources :

Example 96 with JobState

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

the class RestSmartProxyTest method testJobSubmission.

private void testJobSubmission(boolean isolateTaskOutput, boolean automaticTransfer) throws Exception {
    TaskFlowJob job = createTestJob(isolateTaskOutput);
    printJobXmlRepresentation(job);
    DataTransferNotifier notifier = new DataTransferNotifier();
    if (automaticTransfer) {
        restSmartProxy.addEventListener(notifier);
    }
    JobId id = restSmartProxy.submit(job, inputLocalFolder.getAbsolutePath(), outputLocalFolder.getAbsolutePath(), isolateTaskOutput, automaticTransfer);
    JobState jobState = waitForJobFinishState(id.toString());
    assertEquals(JobStatus.FINISHED, jobState.getStatus());
    if (!automaticTransfer) {
        for (int i = 0; i < NB_TASKS; i++) {
            restSmartProxy.pullData(id.toString(), TASK_NAME + i, outputLocalFolder.getAbsolutePath());
        }
    } else {
        List<String> taskNames = taskNameList();
        while (!taskNames.isEmpty()) {
            String finishedTask = notifier.finishedTask();
            if (taskNames.contains(finishedTask)) {
                taskNames.remove(finishedTask);
            }
        }
    }
    // check the presence of output files
    for (int i = 0; i < NB_TASKS; i++) {
        String outputFileName = OUTPUT_FILE_BASE_NAME + "_" + i + OUTPUT_FILE_EXT;
        File outputFile = new File(outputLocalFolder, outputFileName);
        Assert.assertTrue(String.format("%s does not exist.", outputFile.getAbsolutePath()), outputFile.exists());
    }
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobState(org.ow2.proactive.scheduler.common.job.JobState) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 97 with JobState

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

the class RestSmartProxyTest method waitForJobFinishState.

private JobState waitForJobFinishState(String jobIdAsString) throws InterruptedException, NotConnectedException, UnknownJobException, PermissionException {
    JobState jobState = restSmartProxy.getJobState(jobIdAsString);
    Thread.sleep(ONE_SECOND);
    while (jobState.getStatus().isJobAlive()) {
        jobState = restSmartProxy.getJobState(jobIdAsString);
        Thread.sleep(ONE_SECOND);
    }
    return jobState;
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState)

Example 98 with JobState

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

the class SchedulerFrontendState method jobUpdatedFullData.

@Override
public void jobUpdatedFullData(JobState jobstate) {
    ClientJobState storedJobState = new ClientJobState(jobstate);
    dispatchJobUpdatedFullData(storedJobState);
}
Also used : ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState)

Example 99 with JobState

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

the class SchedulerFrontendState method prepare.

/**
 * Prepare the job in the frontend
 *
 * @param jobStates
 *            a temporary set of jobs
 * @param js
 *            the current job to be prepared
 * @param finished
 *            if the job is finished or not
 */
private void prepare(Set<JobState> jobStates, ClientJobState js, boolean finished) {
    jobStates.add(js);
    IdentifiedJob ij = toIdentifiedJob(js);
    jobs.put(js.getId(), ij);
    jobsMap.put(js.getId(), js);
    ij.setFinished(finished);
}
Also used : IdentifiedJob(org.ow2.proactive.scheduler.job.IdentifiedJob)

Example 100 with JobState

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

the class SchedulerFrontendState method getTaskPaginated.

TaskStatesPage getTaskPaginated(JobId jobId, int offset, int limit) throws UnknownJobException, NotConnectedException, PermissionException {
    checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_JOB);
    ClientJobState jobState = getClientJobState(jobId);
    if (jobState == null) {
        throw new UnknownJobException(jobId);
    }
    try {
        jobState.readLock();
        try {
            final TaskStatesPage tasksPaginated = jobState.getTasksPaginated(offset, limit);
            final List<TaskState> taskStatesCopy = (List<TaskState>) ProActiveMakeDeepCopy.WithProActiveObjectStream.makeDeepCopy(new ArrayList<>(tasksPaginated.getTaskStates()));
            return new TaskStatesPage(taskStatesCopy, tasksPaginated.getSize());
        } catch (Exception e) {
            logger.error("Error when copying tasks page", e);
            throw new IllegalStateException(e);
        }
    } finally {
        jobState.readUnlock();
    }
}
Also used : UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) AlreadyConnectedException(org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException)

Aggregations

JobState (org.ow2.proactive.scheduler.common.job.JobState)75 Test (org.junit.Test)44 JobId (org.ow2.proactive.scheduler.common.job.JobId)36 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)30 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)26 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)21 File (java.io.File)20 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)19 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)19 ArrayList (java.util.ArrayList)18 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)16 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)14 GET (javax.ws.rs.GET)13 Path (javax.ws.rs.Path)13 Produces (javax.ws.rs.Produces)13 ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)13 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)13 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)13 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)10 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)10