Search in sources :

Example 41 with NotConnectedException

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

the class RMRest method getRMThreadDump.

@Override
public String getRMThreadDump(String sessionId) throws NotConnectedException {
    RMProxyUserInterface rm = checkAccess(sessionId);
    String threadDump;
    try {
        threadDump = orThrowRpe(rm.getRMThreadDump().getStringValue());
    } catch (Exception exception) {
        return exception.getMessage();
    }
    return threadDump;
}
Also used : RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) 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 42 with NotConnectedException

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

the class RMRest method editNodeSource.

@Override
public NSState editNodeSource(String sessionId, String nodeSourceName, String infrastructureType, String[] infrastructureParameters, String[] infrastructureFileParameters, String policyType, String[] policyParameters, String[] policyFileParameters, String nodesRecoverable) throws NotConnectedException {
    ResourceManager rm = checkAccess(sessionId);
    NSState nsState = new NSState();
    Object[] infraParams = this.getAllInfrastructureParameters(infrastructureType, infrastructureParameters, infrastructureFileParameters, rm);
    Object[] policyParams = this.getAllPolicyParameters(policyType, policyParameters, policyFileParameters, rm);
    try {
        nsState.setResult(rm.editNodeSource(nodeSourceName, infrastructureType, infraParams, policyType, policyParams, Boolean.parseBoolean(nodesRecoverable)).getBooleanValue());
    } catch (RuntimeException ex) {
        nsState.setResult(false);
        nsState.setErrorMessage(cleanDisplayedErrorMessage(ex.getMessage()));
        nsState.setStackTrace(StringEscapeUtils.escapeJson(getStackTrace(ex)));
    }
    return nsState;
}
Also used : JSONObject(org.json.simple.JSONObject) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) NSState(org.ow2.proactive.resourcemanager.common.NSState)

Example 43 with NotConnectedException

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

the class RMRest method getNodesHistory.

@Override
public Map<String, Map<String, Map<String, List<RMNodeHistory>>>> getNodesHistory(String sessionId, long windowStart, long windowEnd) throws NotConnectedException {
    ResourceManager rm = checkAccess(sessionId);
    List<RMNodeHistory> rawDataFromRM = rm.getNodesHistory(windowStart, windowEnd);
    // grouped by node source name, host name, and node name
    Map<String, Map<String, Map<String, List<RMNodeHistory>>>> grouped = rawDataFromRM.stream().collect(Collectors.groupingBy(RMNodeHistory::getNodeSource, Collectors.groupingBy(RMNodeHistory::getHost, Collectors.groupingBy(this::getNodeName))));
    grouped.values().forEach(a -> a.values().forEach(b -> {
        b.values().forEach(c -> {
            // sorting by startTime
            c.sort(Comparator.comparing(RMNodeHistory::getStartTime));
            c.forEach(nh -> {
                // if startTime before window
                if (nh.getStartTime() < windowStart) {
                    nh.setStartTime(windowStart);
                }
                // if endTime after window
                if (windowEnd < nh.getEndTime()) {
                    nh.setEndTime(windowEnd);
                }
                if (nh.getEndTime() == 0) {
                    nh.setEndTime(windowEnd);
                }
            });
        });
    }));
    return grouped;
}
Also used : RMNodeHistory(org.ow2.proactive.resourcemanager.common.event.RMNodeHistory) 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) AttributeList(javax.management.AttributeList) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager)

Example 44 with NotConnectedException

use of org.ow2.proactive.scheduler.common.exception.NotConnectedException 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 45 with NotConnectedException

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

the class RMRest method rmDisconnect.

@Override
public void rmDisconnect(String sessionId) throws NotConnectedException {
    RMProxyUserInterface rm = checkAccess(sessionId);
    PAFuture.getFutureValue(rm.disconnect(), RMListenerProxy.MONITORING_INTERFACE_TIMEOUT);
    sessionStore.terminate(sessionId);
}
Also used : RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)

Aggregations

NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)85 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)76 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)54 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)53 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)47 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)44 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)36 Path (javax.ws.rs.Path)33 GET (javax.ws.rs.GET)29 Produces (javax.ws.rs.Produces)28 ImmediateService (org.objectweb.proactive.annotation.ImmediateService)28 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)26 IOException (java.io.IOException)25 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)25 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)24 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)24 JobId (org.ow2.proactive.scheduler.common.job.JobId)23 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)20 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)20 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)20