use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException in project scheduling by ow2-proactive.
the class SchedulerClient method getJobInfo.
@Override
public JobInfo getJobInfo(String jobId) throws SchedulerException {
JobInfoData jobInfoData = null;
try {
jobInfoData = restApi().jobInfo(sid, jobId);
} catch (RestException e) {
throw RestException.unwrapRestException(e);
}
JobInfoImpl jobInfoImpl = new JobInfoImpl();
JobId newJobId = JobIdImpl.makeJobId(jobId);
jobInfoImpl.setJobId(newJobId);
jobInfoImpl.setJobOwner(jobInfoData.getJobOwner());
jobInfoImpl.setProjectName(jobInfoData.getProjectName());
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());
jobInfoImpl.setDetailedVariables(jobInfoData.getDetailedVariables());
jobInfoImpl.setSignals(jobInfoData.getSignals());
jobInfoImpl.setDetailedSignals(jobInfoData.getDetailedSignals());
jobInfoImpl.setVisualizationConnectionStrings(jobInfoData.getVisualizationConnectionStrings());
jobInfoImpl.setVisualizationIcons(jobInfoData.getVisualizationIcons());
jobInfoImpl.setAttachedServices(jobInfoData.getAttachedServices());
jobInfoImpl.setExternalEndpointUrls(jobInfoData.getExternalEndpointUrls());
jobInfoImpl.setParentId(jobInfoData.getParentId());
jobInfoImpl.setChildrenCount(jobInfoData.getChildrenCount());
return jobInfoImpl;
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException in project scheduling by ow2-proactive.
the class CommonRest method portalsAccesses.
@Override
public List<String> portalsAccesses(String sessionId, List<String> portals) throws RestException {
Scheduler scheduler = checkAccess(sessionId);
if (portals == null || portals.isEmpty()) {
throw new RestException("Invalid \"portals\" parameter : " + portals);
}
List<String> answer = new ArrayList<>(portals.size());
for (String portal : portals) {
try {
checkPermission(scheduler.getSubject(), new PortalAccessPermission(portal), "Acess to portal " + portal + " is disabled");
answer.add(portal);
} catch (PermissionException e) {
// access to portal is disabled, thus the answer will not contain it.
} catch (NotConnectedException e) {
throw new NotConnectedRestException(YOU_ARE_NOT_CONNECTED_TO_THE_SCHEDULER_YOU_SHOULD_LOG_ON_FIRST);
}
}
return answer;
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException in project scheduling by ow2-proactive.
the class RMRest method acquireNodes.
@Override
public Set<String> acquireNodes(String sessionId, String sourceName, int numberNodes, boolean synchronous, long timeout, String nodeConfigJson) throws NotConnectedException, RestException {
if (numberNodes <= 0) {
throw new IllegalArgumentException("Invalid number of nodes: " + numberNodes);
}
ResourceManager rm = checkAccess(sessionId);
if (sourceName == null) {
throw new IllegalArgumentException("Node source name should not be null.");
}
Optional<RMNodeSourceEvent> nodeSource = rm.getExistingNodeSourcesList().stream().filter(ns -> sourceName.equals(ns.getSourceName())).findAny();
if (!nodeSource.isPresent()) {
throw new IllegalArgumentException(String.format("Specified node source [%s] not exist.", sourceName));
}
if (!NODE_SOURCE_DEPLOYED_STATUS.equals(nodeSource.get().getNodeSourceStatus())) {
throw new IllegalArgumentException(String.format("Specified node source [%s] is not deployed.", sourceName));
}
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> nodeConfig;
try {
nodeConfig = mapper.readValue(nodeConfigJson, new TypeReference<Map<String, ?>>() {
});
} catch (Exception e) {
throw new IllegalArgumentException("Error during parsing the node configuration: " + nodeConfigJson, e);
}
if (synchronous) {
String acquireRequestId = "tmp:" + UUID.randomUUID().toString();
setRequestIdInNodeConfig(nodeConfig, acquireRequestId);
rm.acquireNodes(sourceName, numberNodes, timeout * 1000, nodeConfig);
waitUntil(timeout, "Nodes are not deployed within the specified timeout.", () -> rm.getNodesByTag(acquireRequestId).size() == numberNodes);
return orThrowRpe(rm.getNodesByTag(acquireRequestId));
} else {
rm.acquireNodes(sourceName, numberNodes, timeout * 1000, nodeConfig);
return new HashSet<>();
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException in project scheduling by ow2-proactive.
the class RMRest method getNodeTags.
@Override
public Set<String> getNodeTags(String sessionId) throws NotConnectedException, RestException {
try {
ResourceManager rm = checkAccess(sessionId);
Set<String> allTags = new HashSet<>();
for (String nodeUrl : rm.listNodeUrls()) {
allTags.addAll(rm.getNodeTags(nodeUrl));
}
return allTags;
} catch (RMException e) {
throw new RestException(e);
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException in project scheduling by ow2-proactive.
the class SchedulerStateRest method enableRemoteVisualization.
@Override
public void enableRemoteVisualization(String sessionId, String jobId, String taskName, String connectionString) throws RestException {
Scheduler s = checkAccess(sessionId, "PUT jobs/" + jobId + PATH_TASKS + taskName + "/visualization");
Session ss = sessionStore.get(sessionId);
try {
ss.getScheduler().enableRemoteVisualization(jobId, taskName, connectionString);
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
} catch (PermissionException e) {
throw new PermissionRestException(e);
} catch (UnknownJobException e) {
throw new UnknownJobRestException(e);
} catch (UnknownTaskException e) {
throw new UnknownTaskRestException(e);
}
}
Aggregations