use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.
the class SchedulerClient method isTaskFinished.
@Override
public boolean isTaskFinished(String jobId, String taskName) throws UnknownJobException, NotConnectedException, PermissionException, UnknownTaskException {
boolean finished = false;
try {
TaskStateData taskStateData = restApi().jobTask(sid, jobId, taskName);
TaskState taskState = taskState(taskStateData);
finished = !taskState.getStatus().isTaskAlive();
} catch (Exception e) {
throwUJEOrNCEOrPEOrUTE(e);
}
return finished;
}
use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.
the class SchedulerClient method getTaskResultsByTag.
@Override
public List<TaskResult> getTaskResultsByTag(JobId jobId, String taskTag) throws NotConnectedException, UnknownJobException, PermissionException {
List<TaskState> taskStates = getJobState(jobId).getTasksByTag(taskTag);
ArrayList<TaskResult> results = new ArrayList<TaskResult>(taskStates.size());
for (TaskState currentState : taskStates) {
String taskName = currentState.getTaskInfo().getName();
try {
TaskResult currentResult = getTaskResult(jobId, taskName);
results.add(currentResult);
} catch (UnknownTaskException ex) {
// never occurs because tasks are filtered by tag so they cannot
// be unknown.
logger.warn("Unknown task.", ex);
}
}
return results;
}
use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.
the class SchedulerClient method getJobState.
@Override
public JobState getJobState(String jobId) throws NotConnectedException, UnknownJobException, PermissionException {
JobState jobState = null;
try {
JobStateData jobStateData = restApi().listJobs(sid, jobId);
jobState = toJobState(jobStateData);
} catch (Exception e) {
throwUJEOrNCEOrPE(e);
}
return jobState;
}
use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.
the class SchedulerProxyUserInterfaceTest method testChangeStartAt.
@Test
public void testChangeStartAt() throws NotConnectedException, UnknownJobException, PermissionException {
JobId jobId = JobIdImpl.makeJobId("66");
String startAt = "2017-07-07T00:00:00+01:00";
when(uischedulerMock.changeStartAt(jobId, startAt)).thenReturn(true);
assertThat(schedulerProxyUserInterface.changeStartAt(jobId, startAt), is(true));
}
use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.
the class LiveJobs method preemptTask.
TerminationData preemptTask(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(), "preempting task " + task.getId());
if (!task.getStatus().isTaskAlive()) {
tlogger.info(task.getId(), "task isn't alive: " + task.getStatus());
return emptyResult(task.getId());
}
RunningTaskData taskData = runningTasksData.remove(TaskIdWrapper.wrap(task.getId()));
if (taskData == null) {
throw new IllegalStateException("Task " + task.getId() + " is not running.");
}
TaskResultImpl taskResult = taskResultCreator.getTaskResult(dbManager, jobData.job, task, new TaskPreemptedException("Preempted by admin"), new SimpleTaskLogs("", "Preempted by admin"));
TerminationData terminationData = createAndFillTerminationData(taskResult, taskData, jobData.job, TerminationData.TerminationStatus.ABORTED);
long waitTime = restartDelay * 1000L;
restartTaskOnError(jobData, task, TaskStatus.PENDING, taskResult, waitTime, terminationData);
return terminationData;
} finally {
jobData.unlock();
}
}
Aggregations