use of org.ow2.proactive.scheduler.common.exception.UnknownJobException 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);
}
use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.
the class SchedulerFrontend method getTaskResultFromIncarnation.
/**
* {@inheritDoc}
*/
@Override
@ImmediateService
public TaskResult getTaskResultFromIncarnation(JobId jobId, String taskName, int inc) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
// checking permissions
frontendState.checkPermissions("getTaskResultFromIncarnation", frontendState.getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB);
if (inc < 0) {
throw new IllegalArgumentException("Incarnation must be 0 or greater.");
}
jlogger.debug(jobId, "trying to get the task result, incarnation " + inc);
if (inc < 0) {
throw new IllegalArgumentException("Incarnation must be 0 or greater.");
}
try {
TaskResult result = dbManager.loadTaskResult(jobId, taskName, inc);
// handling special statuses
TaskState ts = frontendState.getTaskState(jobId, taskName);
switch(ts.getStatus()) {
case NOT_STARTED:
if (result == null) {
return new TaskResultImpl(frontendState.getTaskId(jobId, taskName), new TaskCouldNotStartException(), new SimpleTaskLogs("", "The task could not start due to dependency failure"), 0);
} else {
Throwable newException = new TaskCouldNotStartException("The task could not start due to dependency failure", result.getException());
((TaskResultImpl) result).setException(newException);
}
break;
case NOT_RESTARTED:
if (result == null) {
return new TaskResultImpl(frontendState.getTaskId(jobId, taskName), new TaskCouldNotRestartException(), new SimpleTaskLogs("", "The task could not be restarted after an error during the previous execution"), 0);
} else {
Throwable newException = new TaskCouldNotRestartException("The task could not be restarted after an error during the previous execution", result.getException());
((TaskResultImpl) result).setException(newException);
}
break;
case SKIPPED:
// result should always be null
return new TaskResultImpl(frontendState.getTaskId(jobId, taskName), new TaskSkippedException(), new SimpleTaskLogs("", "The task was skipped in the workflow"), 0);
}
if (result == null) {
// otherwise the task is not finished
jlogger.info(jobId, taskName + " is not finished");
return null;
} else {
return result;
}
} catch (DatabaseManagerException e) {
throw new UnknownTaskException("Unknown task " + taskName + ", job: " + jobId);
}
}
use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.
the class SchedulerFrontendState method getJobState.
synchronized JobState getJobState(JobId jobId) throws NotConnectedException, UnknownJobException, PermissionException {
checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_JOB);
ClientJobState jobState = jobsMap.get(jobId);
ClientJobState jobStateCopy;
synchronized (jobState) {
try {
jobStateCopy = (ClientJobState) ProActiveMakeDeepCopy.WithProActiveObjectStream.makeDeepCopy(jobState);
} catch (Exception e) {
logger.error("Error when copying job state", e);
throw new IllegalStateException(e);
}
}
return jobStateCopy;
}
use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.
the class SchedulerStateRest method getJobTaskStatesByTagPaginated.
/**
* {@inheritDoc}
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/taskstates/{tasktag}/paginated")
@Produces("application/json")
public RestPage<TaskStateData> getJobTaskStatesByTagPaginated(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("-1") int limit) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
if (limit == -1)
limit = TASKS_PAGE_SIZE;
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/taskstates/" + taskTag + "/paginated");
JobState jobState = s.getJobState(jobId);
TaskStatesPage page = jobState.getTaskByTagPaginated(taskTag, offset, limit);
List<TaskStateData> tasks = map(page.getTaskStates(), TaskStateData.class);
return new RestPage<TaskStateData>(tasks, page.getSize());
} catch (PermissionException e) {
throw new PermissionRestException(e);
} catch (UnknownJobException e) {
throw new UnknownJobRestException(e);
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
}
}
use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.
the class SchedulerStateRest method getJobTaskTagsPrefix.
/**
* Returns a list of the tags of the tasks belonging to job
* <code>jobId</code> and filtered by a prefix pattern
*
* @param sessionId
* a valid session id
* @param jobId
* jobid one wants to list the tasks' tags
* @param prefix
* the prefix used to filter tags
* @return a list of tasks' name
*/
@GET
@Path("jobs/{jobid}/tasks/tags/startsWith/{prefix}")
@Produces("application/json")
public List<String> getJobTaskTagsPrefix(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("prefix") String prefix) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/tags/startswith/" + prefix);
JobState jobState = s.getJobState(jobId);
return jobState.getTags(prefix);
} catch (PermissionException e) {
throw new PermissionRestException(e);
} catch (UnknownJobException e) {
throw new UnknownJobRestException(e);
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
}
}
Aggregations