Search in sources :

Example 1 with RMNodeHistory

use of org.ow2.proactive.resourcemanager.common.event.RMNodeHistory 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)

Aggregations

IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 KeyException (java.security.KeyException)1 java.util (java.util)1 TimeUnit (java.util.concurrent.TimeUnit)1 BooleanSupplier (java.util.function.BooleanSupplier)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 Attribute (javax.management.Attribute)1 AttributeList (javax.management.AttributeList)1 AttributeNotFoundException (javax.management.AttributeNotFoundException)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 IntrospectionException (javax.management.IntrospectionException)1 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)1 MBeanException (javax.management.MBeanException)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 ObjectName (javax.management.ObjectName)1