use of org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface in project scheduling by ow2-proactive.
the class RMRestTest method callGetStatHistory.
private JSONObject callGetStatHistory() throws Exception {
RMProxyUserInterface rmMock = mock(RMProxyUserInterface.class);
String sessionId = SharedSessionStoreTestUtils.createValidSession(rmMock);
AttributeList value = new AttributeList(Collections.singletonList(new Attribute("test", createRrdDb().getBytes())));
when(rmMock.getMBeanAttributes(Matchers.<ObjectName>any(), Matchers.<String[]>any())).thenReturn(value);
RMRestInterface client = ProxyFactory.create(RMRestInterface.class, "http://localhost:" + port + "/");
String statHistory = client.getStatHistory(sessionId, "hhhhh");
return (JSONObject) new JSONParser().parse(statHistory);
}
use of org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface in project scheduling by ow2-proactive.
the class SharedSessionStoreTestUtils method createValidSession.
public static String createValidSession(RMProxyUserInterface rm) throws ActiveObjectCreationException, NodeException, RMException, KeyException, LoginException {
SchedulerRMProxyFactory schedulerFactory = mock(SchedulerRMProxyFactory.class);
when(schedulerFactory.connectToRM(Matchers.<CredData>any())).thenReturn(rm);
SharedSessionStore.getInstance().setSchedulerRMProxyFactory(schedulerFactory);
// login
Session session = SharedSessionStore.getInstance().createUnnamedSession();
session.connectToRM(new CredData());
return session.getSessionId();
}
use of org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface in project scheduling by ow2-proactive.
the class RMRestTest method testShutdown_PreemptParameter.
@Test
public void testShutdown_PreemptParameter() throws Exception {
RMProxyUserInterface rm = mock(RMProxyUserInterface.class);
when(rm.shutdown(true)).thenReturn(new BooleanWrapper(true));
String sessionId = SharedSessionStoreTestUtils.createValidSession(rm);
HttpResponse response = callHttpGetMethod("shutdown?preempt=true", sessionId);
assertEquals(HttpURLConnection.HTTP_OK, response.getStatusLine().getStatusCode());
verify(rm).shutdown(true);
}
use of org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface 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;
}
use of org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface in project scheduling by ow2-proactive.
the class RMRest method executeNodeScript.
@Override
public ScriptResult<Object> executeNodeScript(String sessionId, String nodeUrl, String script, String scriptEngine) throws Throwable {
RMProxyUserInterface rm = checkAccess(sessionId);
List<ScriptResult<Object>> results = orThrowRpe(rm.executeScript(script, scriptEngine, TargetType.NODE_URL.name(), Collections.singleton(nodeUrl)));
checkEmptyScriptResults(results);
return results.get(0);
}
Aggregations