Search in sources :

Example 16 with RMProxyUserInterface

use of org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface in project scheduling by ow2-proactive.

the class RMRest method executeNodeSourceScript.

@Override
public List<ScriptResult<Object>> executeNodeSourceScript(String sessionId, String nodeSource, String script, String scriptEngine) throws Throwable {
    RMProxyUserInterface rm = checkAccess(sessionId);
    List<ScriptResult<Object>> results = orThrowRpe(rm.executeScript(script, scriptEngine, TargetType.NODESOURCE_NAME.name(), Collections.singleton(nodeSource)));
    List<ScriptResult<Object>> awaitedResults = results.stream().map(PAFuture::getFutureValue).collect(Collectors.toList());
    checkEmptyScriptResults(awaitedResults);
    return awaitedResults;
}
Also used : ScriptResult(org.ow2.proactive.scripting.ScriptResult) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)

Example 17 with RMProxyUserInterface

use of org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface in project scheduling by ow2-proactive.

the class RMRest method getStatHistory.

@Override
public String getStatHistory(String sessionId, String range1, String function) throws ReflectionException, InterruptedException, IntrospectionException, NotConnectedException, InstanceNotFoundException, MalformedObjectNameException, IOException {
    String newRange = MBeanInfoViewer.possibleModifyRange(range1, dataSources, 'a');
    StatHistoryCacheEntry entry = StatHistoryCaching.getInstance().getEntryOrCompute(newRange, () -> {
        RMProxyUserInterface rm = checkAccess(sessionId);
        AttributeList attrs = rm.getMBeanAttributes(new ObjectName(RMJMXBeans.RUNTIMEDATA_MBEAN_NAME), new String[] { "StatisticHistory" });
        Attribute attr = (Attribute) attrs.get(0);
        // content of the RRD4J database backing file
        byte[] rrd4j = (byte[]) attr.getValue();
        return MBeanInfoViewer.rrdContent(rrd4j, newRange, dataSources, function);
    });
    return entry.getValue();
}
Also used : StatHistoryCacheEntry(org.ow2.proactive_grid_cloud_portal.common.StatHistoryCaching.StatHistoryCacheEntry) Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) ObjectName(javax.management.ObjectName)

Example 18 with RMProxyUserInterface

use of org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface in project scheduling by ow2-proactive.

the class RMRest method checkAccess.

private RMProxyUserInterface checkAccess(String sessionId) throws NotConnectedException {
    Session session = null;
    try {
        session = sessionStore.get(sessionId);
    } catch (NotConnectedRestException e) {
        throw new NotConnectedException(SessionStore.YOU_ARE_NOT_CONNECTED_TO_THE_SERVER_YOU_SHOULD_LOG_ON_FIRST);
    }
    RMProxyUserInterface s = session.getRM();
    if (s == null) {
        throw new NotConnectedException("you are not connected to the resource manager, you should log on first");
    }
    return session.getRM();
}
Also used : NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)

Example 19 with RMProxyUserInterface

use of org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface in project scheduling by ow2-proactive.

the class RMStateCaching method getRMStateDelta.

/**
 * @return cached RM State as returned by {@link RMProxyUserInterface#getRMStateDelta(long)}
 */
public static RMStateDelta getRMStateDelta(long counter) {
    try {
        long startTime = System.currentTimeMillis();
        final RMStateDelta state = PAFuture.getFutureValue(rm.getRMStateDelta(counter));
        long time = System.currentTimeMillis() - startTime;
        logger.debug(String.format("Updated RM initial state in %d ms", time));
        return state;
    } catch (Exception e) {
        logger.error("Exception occurrend while updating RM state cache, connection reset", e);
        throw e;
    }
}
Also used : RMStateDelta(org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta)

Aggregations

RMProxyUserInterface (org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)16 Matchers.anyString (org.mockito.Matchers.anyString)6 Test (org.junit.Test)4 Attribute (javax.management.Attribute)3 AttributeList (javax.management.AttributeList)3 HttpResponse (org.apache.http.HttpResponse)3 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)3 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)3 ScriptResult (org.ow2.proactive.scripting.ScriptResult)3 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)3 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 KeyException (java.security.KeyException)2 AttributeNotFoundException (javax.management.AttributeNotFoundException)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)2 IntrospectionException (javax.management.IntrospectionException)2 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)2 MBeanException (javax.management.MBeanException)2 MalformedObjectNameException (javax.management.MalformedObjectNameException)2 ReflectionException (javax.management.ReflectionException)2