Search in sources :

Example 31 with NotConnectedException

use of org.ow2.proactive.resourcemanager.exception.NotConnectedException in project scheduling by ow2-proactive.

the class SchedulerClient method getJobInfo.

@Override
public JobInfo getJobInfo(String jobId) throws UnknownJobException, NotConnectedException, PermissionException {
    JobInfoData jobInfoData = null;
    try {
        jobInfoData = restApi().jobInfo(sid, jobId);
    } catch (NotConnectedRestException e) {
        throw new NotConnectedException(e);
    } catch (PermissionRestException e) {
        throw new PermissionException(e);
    } catch (UnknownJobRestException e) {
        throw new UnknownJobException(e);
    }
    JobInfoImpl jobInfoImpl = new JobInfoImpl();
    JobId newJobId = JobIdImpl.makeJobId(jobId);
    jobInfoImpl.setJobId(newJobId);
    jobInfoImpl.setJobOwner(jobInfoData.getJobOwner());
    jobInfoImpl.setFinishedTime(jobInfoData.getFinishedTime());
    jobInfoImpl.setRemovedTime(jobInfoData.getRemovedTime());
    jobInfoImpl.setStartTime(jobInfoData.getStartTime());
    jobInfoImpl.setInErrorTime(jobInfoData.getInErrorTime());
    jobInfoImpl.setSubmittedTime(jobInfoData.getSubmittedTime());
    jobInfoImpl.setNumberOfFinishedTasks(jobInfoData.getNumberOfFinishedTasks());
    jobInfoImpl.setNumberOfPendingTasks(jobInfoData.getNumberOfPendingTasks());
    jobInfoImpl.setNumberOfRunningTasks(jobInfoData.getNumberOfRunningTasks());
    jobInfoImpl.setNumberOfInErrorTasks(jobInfoData.getNumberOfInErrorTasks());
    jobInfoImpl.setNumberOfFaultyTasks(jobInfoData.getNumberOfFaultyTasks());
    jobInfoImpl.setTotalNumberOfTasks(jobInfoData.getTotalNumberOfTasks());
    jobInfoImpl.setJobPriority(JobPriority.findPriority(jobInfoData.getPriority().toString()));
    jobInfoImpl.setJobStatus(JobStatus.findPriority(jobInfoData.getStatus().toString()));
    if (jobInfoData.isToBeRemoved())
        jobInfoImpl.setToBeRemoved();
    jobInfoImpl.setGenericInformation(jobInfoData.getGenericInformation());
    jobInfoImpl.setVariables(jobInfoData.getVariables());
    return jobInfoImpl;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) JobInfoData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobInfoData) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) JobInfoImpl(org.ow2.proactive.scheduler.rest.data.JobInfoImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 32 with NotConnectedException

use of org.ow2.proactive.resourcemanager.exception.NotConnectedException 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;
}
Also used : TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) IOException(java.io.IOException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) TimeoutException(java.util.concurrent.TimeoutException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)

Example 33 with NotConnectedException

use of org.ow2.proactive.resourcemanager.exception.NotConnectedException 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;
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) ArrayList(java.util.ArrayList) DataUtility.toTaskResult(org.ow2.proactive.scheduler.rest.data.DataUtility.toTaskResult) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 34 with NotConnectedException

use of org.ow2.proactive.resourcemanager.exception.NotConnectedException in project scheduling by ow2-proactive.

the class SchedulerClient method getTaskStates.

@Override
public Page<TaskState> getTaskStates(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit, SortSpecifierContainer sortParams) throws NotConnectedException, PermissionException {
    RestPage<TaskStateData> page = null;
    SortSpecifierContainer sortContainer = new SortSpecifierContainer(sortParams.toString());
    try {
        page = restApi().getTaskStates(sid, from, to, mytasks, running, pending, finished, offset, limit, sortContainer);
    } catch (NotConnectedRestException e) {
        throw new NotConnectedException(e);
    } catch (PermissionRestException e) {
        throw new PermissionException(e);
    }
    List<TaskState> lTaskStates = new ArrayList<TaskState>(page.getList().size());
    for (TaskStateData taskStateData : page.getList()) {
        lTaskStates.add(new TaskStateImpl(taskStateData));
    }
    return new Page<TaskState>(lTaskStates, page.getSize());
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) ArrayList(java.util.ArrayList) TaskStateImpl(org.ow2.proactive.scheduler.rest.data.TaskStateImpl) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) Page(org.ow2.proactive.scheduler.common.Page) RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 35 with NotConnectedException

use of org.ow2.proactive.resourcemanager.exception.NotConnectedException 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;
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState) DataUtility.toJobState(org.ow2.proactive.scheduler.rest.data.DataUtility.toJobState) JobStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobStateData) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) IOException(java.io.IOException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) TimeoutException(java.util.concurrent.TimeoutException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)

Aggregations

NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)68 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)64 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)51 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)48 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)46 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)40 Path (javax.ws.rs.Path)39 Produces (javax.ws.rs.Produces)37 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)36 GET (javax.ws.rs.GET)28 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)27 JobState (org.ow2.proactive.scheduler.common.job.JobState)21 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)19 GZIP (org.jboss.resteasy.annotations.GZIP)18 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)18 IOException (java.io.IOException)17 ArrayList (java.util.ArrayList)17 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)17 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)16 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)16