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);
}
}
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);
}
}
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);
}
}
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());
}
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());
}
Aggregations