Search in sources :

Example 96 with JobId

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

the class TestMultipleHostsRequest method testMultipleHostsRequest.

@Test
public void testMultipleHostsRequest() throws Throwable {
    String task1Name = "task1";
    switch(OperatingSystem.getOperatingSystem()) {
        case windows:
            // set system Property for executable path
            System.setProperty(executablePathPropertyName, new File(executablePathWindows.toURI()).getAbsolutePath());
            break;
        case unix:
            SchedulerTHelper.setExecutable(new File(executablePath.toURI()).getAbsolutePath());
            // set system Property for executable path
            System.setProperty(executablePathPropertyName, new File(executablePath.toURI()).getAbsolutePath());
            break;
        default:
            throw new IllegalStateException("Unsupported operating system");
    }
    // test submission and event reception
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    JobId id = schedulerHelper.submitJob(job);
    schedulerHelper.addExtraNodes(3);
    log("Job submitted, id " + id.toString());
    log("Waiting for jobSubmitted Event");
    JobState receivedState = schedulerHelper.waitForEventJobSubmitted(id);
    assertEquals(receivedState.getId(), id);
    log("Waiting for job running");
    JobInfo jInfo = schedulerHelper.waitForEventJobRunning(id);
    assertEquals(jInfo.getJobId(), id);
    assertEquals(JobStatus.RUNNING, jInfo.getStatus());
    schedulerHelper.waitForEventTaskRunning(id, task1Name);
    TaskInfo tInfo = schedulerHelper.waitForEventTaskFinished(id, task1Name);
    log(schedulerHelper.getSchedulerInterface().getTaskResult(id, "task1").getOutput().getAllLogs(false));
    assertEquals(TaskStatus.FINISHED, tInfo.getStatus());
    schedulerHelper.waitForEventJobFinished(id);
    JobResult res = schedulerHelper.getJobResult(id);
    // check that there is one exception in results
    assertTrue(res.getExceptionResults().isEmpty());
    // remove job
    schedulerHelper.removeJob(id);
    schedulerHelper.waitForEventJobRemoved(id);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) File(java.io.File) Test(org.junit.Test)

Example 97 with JobId

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

the class TestJobSchedulingStarvationAndPriority method computeMinMaxStartingTime.

/**
 * Computes min start time and max start time for all tasks which match a given pattern
 * If a task in the set did not start, then the set max will be Long.MAX_VALUE
 */
Pair<Long, Long> computeMinMaxStartingTime(Scheduler scheduler, JobId jobId, String taskNameFilter) throws Exception {
    long min = Long.MAX_VALUE;
    long max = -1;
    for (TaskState state : scheduler.getJobState(jobId).getTasks()) {
        if (state.getName().matches(taskNameFilter)) {
            long startTime = state.getStartTime() > -1 ? state.getStartTime() : Long.MAX_VALUE;
            min = Math.min(min, startTime);
            max = Math.max(max, startTime);
        }
    }
    return new ImmutablePair<>(min, max);
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 98 with JobId

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

the class SchedulerFrontend method restartAllInErrorTasks.

@Override
public boolean restartAllInErrorTasks(String jobId) throws NotConnectedException, UnknownJobException, PermissionException {
    final JobId jobIdObject = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("restartAllInErrorTasks", frontendState.getIdentifiedJob(jobIdObject), YOU_DO_NOT_HAVE_PERMISSION_TO_RESTART_IN_ERROR_TASKS_IN_THIS_JOB);
    return schedulingService.restartAllInErrorTasks(jobIdObject);
}
Also used : JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 99 with JobId

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

the class SchedulerFrontend method getTaskServerLogs.

@Override
@ImmediateService
public String getTaskServerLogs(String jobId, String taskName) throws UnknownJobException, UnknownTaskException, NotConnectedException, PermissionException {
    JobId id = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("getTaskServerLogs", frontendState.getIdentifiedJob(id), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_LOGS_OF_THIS_JOB);
    for (TaskId taskId : frontendState.getJobTasks(id)) {
        if (taskId.getReadableName().equals(taskName)) {
            return ServerJobAndTaskLogs.getTaskLog(taskId);
        }
    }
    throw new UnknownTaskException("Unknown task " + taskName + " in job " + jobId);
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) JobId(org.ow2.proactive.scheduler.common.job.JobId) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 100 with JobId

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

the class SchedulerFrontend method submit.

/**
 * {@inheritDoc}
 */
@Override
@ImmediateService
public JobId submit(Job userJob) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("New job submission requested : " + userJob.getName());
        }
        // check if the scheduler is stopped
        if (!schedulingService.isSubmitPossible()) {
            String msg = "Scheduler is stopped, cannot submit job";
            logger.info(msg);
            throw new SubmissionClosedException(msg);
        }
        UserIdentificationImpl ident = frontendState.checkPermission("submit", YOU_DO_NOT_HAVE_PERMISSION_TO_SUBMIT_A_JOB);
        InternalJob job = frontendState.createJob(userJob, ident);
        schedulingService.submitJob(job);
        frontendState.jobSubmitted(job, ident);
        return job.getId();
    } catch (Exception e) {
        logger.warn("Error when submitting job.", e);
        throw e;
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) TaskCouldNotRestartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotRestartException) 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) TaskCouldNotStartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotStartException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) DatabaseManagerException(org.ow2.proactive.db.DatabaseManagerException) TaskSkippedException(org.ow2.proactive.scheduler.common.exception.TaskSkippedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Aggregations

JobId (org.ow2.proactive.scheduler.common.job.JobId)179 Test (org.junit.Test)121 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)73 File (java.io.File)58 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)57 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)55 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)55 JobState (org.ow2.proactive.scheduler.common.job.JobState)51 ArrayList (java.util.ArrayList)45 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)43 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)42 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)40 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)38 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)37 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)36 Path (javax.ws.rs.Path)35 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)35 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)34 Produces (javax.ws.rs.Produces)33 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)33