Search in sources :

Example 6 with RestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException in project scheduling by ow2-proactive.

the class SchedulerStateRest method registerService.

@Override
public void registerService(String sessionId, String jobId, int serviceInstanceid, boolean enableActions) throws RestException {
    Scheduler s = checkAccess(sessionId, "POST jobs/" + jobId + PATH_SERVICES);
    Session ss = sessionStore.get(sessionId);
    try {
        ss.getScheduler().registerService(jobId, serviceInstanceid, enableActions);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) Session(org.ow2.proactive_grid_cloud_portal.common.Session)

Example 7 with RestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException in project scheduling by ow2-proactive.

the class SchedulerStateRest method detachService.

@Override
public void detachService(String sessionId, String jobId, int serviceInstanceid) throws RestException {
    Scheduler s = checkAccess(sessionId, "DELETE jobs/" + jobId + PATH_SERVICES);
    Session ss = sessionStore.get(sessionId);
    try {
        ss.getScheduler().detachService(jobId, serviceInstanceid);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) Session(org.ow2.proactive_grid_cloud_portal.common.Session)

Example 8 with RestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException in project scheduling by ow2-proactive.

the class SchedulerStateRest method getTaskStatesByTag.

@Override
public RestPage<TaskStateData> getTaskStatesByTag(String sessionId, String taskTag, long from, long to, boolean mytasks, String statusFilter, int offset, int limit, SortSpecifierContainer sortParams) throws RestException {
    Scheduler s = checkAccess(sessionId, "tasks/tag/" + taskTag);
    PageBoundaries boundaries = Pagination.getTasksPageBoundaries(offset, limit, TASKS_PAGE_SIZE);
    Page<TaskState> page = null;
    // sortParams will be null
    if (sortParams == null) {
        sortParams = new SortSpecifierContainer();
    }
    try {
        final Set<TaskStatus> statuses = TaskStatus.expandAggregatedStatusesToRealStatuses(Stream.of(statusFilter.split(";")).collect(Collectors.toList()));
        page = s.getTaskStates(taskTag, from, to, mytasks, statuses, boundaries.getOffset(), boundaries.getLimit(), sortParams);
        List<TaskStateData> tasks = map(page.getList(), TaskStateData.class);
        return new RestPage<>(tasks, page.getSize());
    } catch (SchedulerException e) {
        throw RestException.wrapExceptionToRest(e);
    }
}
Also used : PageBoundaries(org.ow2.proactive.scheduler.common.util.PageBoundaries)

Example 9 with RestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException in project scheduling by ow2-proactive.

the class SchedulerClient method getTaskStates.

@Override
public Page<TaskState> getTaskStates(String taskTag, long from, long to, boolean mytasks, Set<TaskStatus> statusFilter, int offset, int limit, SortSpecifierContainer sortParams) throws SchedulerException {
    RestPage<TaskStateData> page = null;
    SortSpecifierContainer sortContainer = new SortSpecifierContainer(sortParams.toString());
    try {
        page = restApi().getTaskStates(sid, from, to, mytasks, TaskStatus.statusFilterString(statusFilter), offset, limit, sortContainer);
    } catch (RestException e) {
        throw RestException.unwrapRestException(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 : SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) ArrayList(java.util.ArrayList) TaskStateImpl(org.ow2.proactive.scheduler.rest.data.TaskStateImpl) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) Page(org.ow2.proactive.scheduler.common.Page) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 10 with RestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException in project scheduling by ow2-proactive.

the class SchedulerClient method getTaskIds.

@Override
public Page<TaskId> getTaskIds(String taskTag, long from, long to, boolean mytasks, Set<TaskStatus> taskStatuses, int offset, int limit) throws SchedulerException {
    RestPage<TaskStateData> page = null;
    try {
        page = restApi().getTaskStates(sid, from, to, mytasks, statusesToString(taskStatuses), offset, limit, null);
    } catch (RestException e) {
        throw RestException.unwrapRestException(e);
    }
    List<TaskId> lTaskIds = new ArrayList<TaskId>(page.getList().size());
    for (TaskStateData taskStateData : page.getList()) {
        TaskInfoData taskInfo = taskStateData.getTaskInfo();
        TaskIdData taskIdData = taskInfo.getTaskId();
        JobId jobId = new JobIdImpl(taskInfo.getJobId().getId(), taskInfo.getJobId().getReadableName());
        TaskId taskId = TaskIdImpl.createTaskId(jobId, taskIdData.getReadableName(), taskIdData.getId());
        lTaskIds.add(taskId);
    }
    return new Page<TaskId>(lTaskIds, page.getSize());
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ArrayList(java.util.ArrayList) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) Page(org.ow2.proactive.scheduler.common.Page) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Aggregations

NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)8 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)7 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)7 HttpSession (javax.servlet.http.HttpSession)6 RestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException)6 Logger (org.apache.log4j.Logger)5 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)5 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)5 Session (org.ow2.proactive_grid_cloud_portal.common.Session)5 SchedulerRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException)3 URISyntaxException (java.net.URISyntaxException)2 KeyException (java.security.KeyException)2 ArrayList (java.util.ArrayList)2 LoginException (javax.security.auth.login.LoginException)2 Level (org.apache.log4j.Level)2 RMException (org.ow2.proactive.resourcemanager.exception.RMException)2 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)2 Page (org.ow2.proactive.scheduler.common.Page)2 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)2 SchedulerProxyUserInterface (org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface)2