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);
}
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();
}
}
}
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);
}
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);
}
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);
}
}
Aggregations