Search in sources :

Example 1 with RMProxyUserInterface

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);
}
Also used : JSONObject(org.json.simple.JSONObject) Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) JSONParser(org.json.simple.parser.JSONParser) Matchers.anyString(org.mockito.Matchers.anyString)

Example 2 with RMProxyUserInterface

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();
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData)

Example 3 with RMProxyUserInterface

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);
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) HttpResponse(org.apache.http.HttpResponse) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 4 with RMProxyUserInterface

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;
}
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 5 with RMProxyUserInterface

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);
}
Also used : ScriptResult(org.ow2.proactive.scripting.ScriptResult) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)

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