use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.
the class SchedulerFrontend method restartInErrorTask.
/**
* {@inheritDoc}
*/
@Override
@ImmediateService
public boolean restartInErrorTask(String jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
// checking permissions
final JobId jobIdObject = JobIdImpl.makeJobId(jobId);
frontendState.checkPermissions("restartTaskOnError", frontendState.getIdentifiedJob(jobIdObject), YOU_DO_NOT_HAVE_PERMISSION_TO_RESTART_THIS_TASK);
return schedulingService.restartInErrorTask(jobIdObject, taskName);
}
use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.
the class SchedulerFrontend method finishInErrorTask.
/**
* {@inheritDoc}
*/
@Override
@ImmediateService
public boolean finishInErrorTask(String jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
// checking permissions
final JobId jobIdObject = JobIdImpl.makeJobId(jobId);
frontendState.checkPermissions("finishTaskInError", frontendState.getIdentifiedJob(jobIdObject), YOU_DO_NOT_HAVE_PERMISSION_TO_FINISH_THIS_TASK);
return schedulingService.finishInErrorTask(jobIdObject, taskName);
}
use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.
the class SchedulerFrontendState method getTaskState.
synchronized 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);
if (jobsMap.get(jobId) == 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);
}
JobState jobState = jobsMap.get(jobId);
synchronized (jobState) {
TaskState ts = jobState.getHMTasks().get(taskId);
if (ts == null) {
throw new UnknownTaskException(taskId, jobId);
}
return ts;
}
}
use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.
the class LiveJobs method restartInErrorTask.
void restartInErrorTask(JobId jobId, String taskName) throws UnknownTaskException {
JobData jobData = lockJob(jobId);
try {
InternalTask task = jobData.job.getTask(taskName);
tlogger.info(task.getId(), "restarting in-error task " + task.getId());
jobData.job.restartInErrorTask(task);
dbManager.updateJobAndTasksState(jobData.job);
updateJobInSchedulerState(jobData.job, SchedulerEvent.JOB_RESTARTED_FROM_ERROR);
} finally {
jobData.unlock();
}
}
use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.
the class LiveJobs method restartTask.
TerminationData restartTask(JobId jobId, String taskName, int restartDelay) throws UnknownJobException, UnknownTaskException {
JobData jobData = lockJob(jobId);
if (jobData == null) {
throw new UnknownJobException(jobId);
}
try {
InternalTask task = jobData.job.getTask(taskName);
tlogger.info(task.getId(), "restarting task " + task.getId());
if (!task.getStatus().isTaskAlive()) {
tlogger.warn(task.getId(), "task isn't alive: " + task.getStatus());
return emptyResult(task.getId());
}
TaskIdWrapper taskIdWrapper = TaskIdWrapper.wrap(task.getId());
RunningTaskData taskData = runningTasksData.remove(taskIdWrapper);
if (taskData == null) {
throw new IllegalStateException("Task " + task.getId() + " is not running.");
}
TaskResultImpl taskResult = taskResultCreator.getTaskResult(dbManager, jobData.job, task, new TaskRestartedException("Aborted by user"), new SimpleTaskLogs("", "Aborted by user"));
TerminationData terminationData = createAndFillTerminationData(taskResult, taskData, jobData.job, TerminationData.TerminationStatus.ABORTED);
task.decreaseNumberOfExecutionLeft();
if (task.getNumberOfExecutionLeft() <= 0 && onErrorPolicyInterpreter.requiresCancelJobOnError(task)) {
endJob(jobData, terminationData, task, taskResult, "An error occurred in your task and the maximum number of executions has been reached. " + "You also ask to cancel the job in such a situation !", JobStatus.CANCELED);
return terminationData;
} else if (task.getNumberOfExecutionLeft() > 0) {
long waitTime = restartDelay * 1000l;
restartTaskOnError(jobData, task, TaskStatus.WAITING_ON_ERROR, taskResult, waitTime, terminationData);
return terminationData;
}
terminateTask(jobData, task, true, taskResult, terminationData);
return terminationData;
} finally {
jobData.unlock();
}
}
Aggregations