Search in sources :

Example 16 with ClientJobState

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

the class SchedulerFrontendState method getTaskState.

TaskState getTaskState(JobId jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_TASK);
    return Lambda.withLockException2(stateReadLock, () -> {
        ClientJobState jobState = getClientJobState(jobId);
        if (jobState == null) {
            throw new UnknownJobException(jobId);
        }
        TaskId taskId = null;
        for (TaskId t : getJobTasks(jobId)) {
            if (t.getReadableName().equals(taskName)) {
                taskId = t;
            }
        }
        if (taskId == null) {
            throw new UnknownTaskException(taskName, jobId);
        }
        try {
            jobState.readLock();
            TaskState ts = jobState.getHMTasks().get(taskId);
            if (ts == null) {
                throw new UnknownTaskException(taskId, jobId);
            }
            return ts;
        } finally {
            jobState.readUnlock();
        }
    }, UnknownJobException.class, UnknownTaskException.class);
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState)

Example 17 with ClientJobState

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

the class SchedulerFrontendState method taskStateUpdated.

@Override
public void taskStateUpdated(String owner, NotificationData<TaskInfo> notification) {
    ClientJobState jobState = getClientJobState(notification.getData().getJobId());
    if (jobState != null) {
        try {
            jobState.writeLock();
            jobState.update(notification.getData());
            switch(notification.getEventType()) {
                case TASK_PENDING_TO_RUNNING:
                case TASK_RUNNING_TO_FINISHED:
                case TASK_WAITING_FOR_RESTART:
                case TASK_IN_ERROR:
                case TASK_SKIPPED:
                case TASK_REPLICATED:
                case TASK_IN_ERROR_TO_FINISHED:
                    dispatchTaskStateUpdated(owner, notification);
                    break;
                case TASK_PROGRESS:
                case TASK_VISU_ACTIVATED:
                    // so if task is not finished, send event
                    if (notification.getData().getFinishedTime() <= 0) {
                        dispatchTaskStateUpdated(owner, notification);
                    }
                    break;
                default:
                    logger.warn("**WARNING** - Unconsistent update type received from Scheduler Core : " + notification.getEventType());
            }
        } finally {
            jobState.writeUnlock();
        }
    }
}
Also used : ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState)

Example 18 with ClientJobState

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

the class SchedulerFrontendState method jobSubmitted.

@Override
public void jobSubmitted(JobState job) {
    Lambda.withLock(stateWriteLock, () -> {
        ClientJobState storedJobState = new ClientJobState(job);
        jobsMap.put(job.getId(), storedJobState);
        schedulerState.update(storedJobState);
    });
    dispatchJobSubmitted(job);
}
Also used : ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState)

Example 19 with ClientJobState

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

the class SchedulerFrontendState method getIdentifiedJob.

IdentifiedJob getIdentifiedJob(JobId jobId) throws UnknownJobException {
    return Lambda.withLockException1(stateReadLock, () -> {
        IdentifiedJob identifiedJob = jobs.get(jobId);
        if (identifiedJob == null) {
            ClientJobState clientJobState = getClientJobState(jobId);
            if (clientJobState != null) {
                identifiedJob = toIdentifiedJob(clientJobState);
                // because wherenever there is job in jobsMap, but not in jobs, it is always finished
                identifiedJob.setFinished(true);
            } else {
                String msg = "The job represented by this ID '" + jobId + "' is unknown !";
                logger.info(msg);
                throw new UnknownJobException(msg);
            }
        }
        return identifiedJob;
    }, UnknownJobException.class);
}
Also used : UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) IdentifiedJob(org.ow2.proactive.scheduler.job.IdentifiedJob)

Example 20 with ClientJobState

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

the class SchedulerFrontendState method recover.

/**
 * Called to recover the front end state. This method may have to rebuild
 * the different list of userIdentification and job/user association.
 */
private void recover(SchedulerStateImpl sState) {
    Vector<ClientJobState> pendingJobs = sState.getPendingJobs();
    Vector<ClientJobState> runningJobs = sState.getRunningJobs();
    Vector<ClientJobState> finishedJobs = sState.getFinishedJobs();
    // default state = started
    Set<JobState> jobStates = new HashSet<>(pendingJobs.size() + runningJobs.size() + finishedJobs.size());
    if (logger.isInfoEnabled()) {
        logger.info("#Pending jobs: " + pendingJobs.size() + " #Running jobs: " + runningJobs.size() + " #Finished jobs: " + finishedJobs.size());
    }
    for (ClientJobState js : pendingJobs) {
        prepare(jobStates, js, false);
    }
    for (ClientJobState js : runningJobs) {
        prepare(jobStates, js, false);
    }
    for (ClientJobState js : finishedJobs) {
        prepare(jobStates, js, true);
    }
}
Also used : ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobState(org.ow2.proactive.scheduler.common.job.JobState) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState)

Aggregations

ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)19 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)6 Test (org.junit.Test)5 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)5 AlreadyConnectedException (org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException)3 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)3 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)3 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)3 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)3 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)3 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)3 SchedulerJMXHelper (org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper)3 RuntimeDataMBeanImpl (org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBeanImpl)3 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)3 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)3 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)3 Vector (java.util.Vector)2 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)2 JobState (org.ow2.proactive.scheduler.common.job.JobState)2 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)2