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;
}
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();
}
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();
}
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;
}
}
Aggregations