Search in sources :

Example 1 with RestException

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;
}
Also used : JobInfoImpl(org.ow2.proactive.scheduler.rest.data.JobInfoImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 2 with RestException

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;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) RestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)

Example 3 with RestException

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<>();
    }
}
Also used : LoginException(javax.security.auth.login.LoginException) RMStateDelta(org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta) CredData(org.ow2.proactive.authentication.crypto.CredData) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) IntrospectionException(javax.management.IntrospectionException) PAFuture(org.objectweb.proactive.api.PAFuture) KeyException(java.security.KeyException) RMListenerProxy(org.ow2.proactive.resourcemanager.common.util.RMListenerProxy) ScriptResult(org.ow2.proactive.scripting.ScriptResult) URISyntaxException(java.net.URISyntaxException) Path(javax.ws.rs.Path) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) ConfigurableField(org.ow2.proactive.resourcemanager.nodesource.common.ConfigurableField) BooleanSupplier(java.util.function.BooleanSupplier) InetAddress(java.net.InetAddress) Logger(org.apache.log4j.Logger) Matcher(java.util.regex.Matcher) NSState(org.ow2.proactive.resourcemanager.common.NSState) NodeFactory(org.objectweb.proactive.core.node.NodeFactory) URI(java.net.URI) StringEscapeUtils(org.apache.commons.lang3.StringEscapeUtils) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) ReflectionException(javax.management.ReflectionException) RMActiveObjectCreationException(org.ow2.proactive.resourcemanager.exception.RMActiveObjectCreationException) RMState(org.ow2.proactive.resourcemanager.common.RMState) ExceptionUtils.getStackTrace(org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace) RMNodeHistory(org.ow2.proactive.resourcemanager.common.event.RMNodeHistory) ObjectName(javax.management.ObjectName) Collectors(java.util.stream.Collectors) RMException(org.ow2.proactive.resourcemanager.exception.RMException) RMStateFull(org.ow2.proactive.resourcemanager.common.event.dto.RMStateFull) MalformedObjectNameException(javax.management.MalformedObjectNameException) JSONObject(org.json.simple.JSONObject) Response(javax.ws.rs.core.Response) NodeException(org.objectweb.proactive.core.node.NodeException) TypeReference(org.codehaus.jackson.type.TypeReference) TopologyData(org.ow2.proactive.resourcemanager.frontend.topology.TopologyData) Pattern(java.util.regex.Pattern) TopologyImpl(org.ow2.proactive.resourcemanager.frontend.topology.TopologyImpl) RMJMXBeans(org.ow2.proactive.resourcemanager.core.jmx.RMJMXBeans) PluginDescriptorData(org.ow2.proactive.resourcemanager.frontend.PluginDescriptorData) RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) MBeanInfoViewer(org.ow2.proactive.utils.console.MBeanInfoViewer) java.util(java.util) AttributeNotFoundException(javax.management.AttributeNotFoundException) ScriptException(org.ow2.proactive.scripting.ScriptException) GET(javax.ws.rs.GET) TargetType(org.ow2.proactive.resourcemanager.utils.TargetType) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) NodeSourceConfiguration(org.ow2.proactive.resourcemanager.nodesource.common.NodeSourceConfiguration) AttributeList(javax.management.AttributeList) JSONArray(org.json.simple.JSONArray) UserData(org.ow2.proactive.authentication.UserData) Lambda.mapKeys(org.ow2.proactive.utils.Lambda.mapKeys) Attribute(javax.management.Attribute) StatHistory(org.ow2.proactive_grid_cloud_portal.webapp.StatHistory) InstanceNotFoundException(javax.management.InstanceNotFoundException) JsonParser(org.codehaus.jackson.JsonParser) Credentials(org.ow2.proactive.authentication.crypto.Credentials) Lambda.mapValues(org.ow2.proactive.utils.Lambda.mapValues) RMConstants(org.ow2.proactive.resourcemanager.common.RMConstants) PortalConfiguration(org.ow2.proactive_grid_cloud_portal.webapp.PortalConfiguration) IOException(java.io.IOException) Node(org.objectweb.proactive.core.node.Node) org.ow2.proactive_grid_cloud_portal.common(org.ow2.proactive_grid_cloud_portal.common) TimeUnit(java.util.concurrent.TimeUnit) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) MultipartForm(org.jboss.resteasy.annotations.providers.multipart.MultipartForm) StatHistoryCacheEntry(org.ow2.proactive_grid_cloud_portal.common.StatHistoryCaching.StatHistoryCacheEntry) LoginForm(org.ow2.proactive_grid_cloud_portal.common.dto.LoginForm) RestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) RMNodeException(org.ow2.proactive.resourcemanager.exception.RMNodeException) PluginDescriptor(org.ow2.proactive.resourcemanager.nodesource.common.PluginDescriptor) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) JSONObject(org.json.simple.JSONObject) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) TypeReference(org.codehaus.jackson.type.TypeReference) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) LoginException(javax.security.auth.login.LoginException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) IntrospectionException(javax.management.IntrospectionException) KeyException(java.security.KeyException) URISyntaxException(java.net.URISyntaxException) ReflectionException(javax.management.ReflectionException) RMActiveObjectCreationException(org.ow2.proactive.resourcemanager.exception.RMActiveObjectCreationException) RMException(org.ow2.proactive.resourcemanager.exception.RMException) MalformedObjectNameException(javax.management.MalformedObjectNameException) NodeException(org.objectweb.proactive.core.node.NodeException) AttributeNotFoundException(javax.management.AttributeNotFoundException) ScriptException(org.ow2.proactive.scripting.ScriptException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) InstanceNotFoundException(javax.management.InstanceNotFoundException) IOException(java.io.IOException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) RestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) RMNodeException(org.ow2.proactive.resourcemanager.exception.RMNodeException)

Example 4 with RestException

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);
    }
}
Also used : PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) RestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 5 with RestException

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);
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) Session(org.ow2.proactive_grid_cloud_portal.common.Session)

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