Search in sources :

Example 6 with RMProxyUserInterface

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

the class RMRestTest method testAddNodeOverloading.

// PORTAL-326
@Test
public void testAddNodeOverloading() throws Exception {
    RMProxyUserInterface rm = mock(RMProxyUserInterface.class);
    String sessionId = SharedSessionStoreTestUtils.createValidSession(rm);
    when(rm.addNode(anyString())).thenReturn(new BooleanWrapper(true));
    List<NameValuePair> firstCall = Collections.<NameValuePair>singletonList(new BasicNameValuePair("nodeurl", "url"));
    callHttpPostMethod("node", sessionId, firstCall);
    verify(rm).addNode("url");
    reset(rm);
    when(rm.addNode(anyString(), anyString())).thenReturn(new BooleanWrapper(true));
    List<NameValuePair> secondCall = new ArrayList<>();
    secondCall.add(new BasicNameValuePair("nodeurl", "urlwithnsname"));
    secondCall.add(new BasicNameValuePair("nodesource", "ns"));
    callHttpPostMethod("node", sessionId, secondCall);
    verify(rm).addNode("urlwithnsname", "ns");
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 7 with RMProxyUserInterface

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

the class RMRestTest method testShutdown_NoPreemptParameter.

@Test
public void testShutdown_NoPreemptParameter() throws Exception {
    RMProxyUserInterface rm = mock(RMProxyUserInterface.class);
    when(rm.shutdown(false)).thenReturn(new BooleanWrapper(true));
    String sessionId = SharedSessionStoreTestUtils.createValidSession(rm);
    HttpResponse response = callHttpGetMethod("shutdown", sessionId);
    assertEquals(HttpURLConnection.HTTP_OK, response.getStatusLine().getStatusCode());
    verify(rm).shutdown(false);
}
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 8 with RMProxyUserInterface

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

the class SchedulerRMProxyFactory method connectToRM.

public RMProxyUserInterface connectToRM(Credentials credentials) throws ActiveObjectCreationException, NodeException, RMException, KeyException, LoginException {
    RMProxyUserInterface rm = PAActiveObject.newActive(RMProxyUserInterface.class, new Object[] {});
    rm.init(PortalConfiguration.RM_URL.getValueAsString(), credentials);
    return rm;
}
Also used : RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)

Example 9 with RMProxyUserInterface

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

the class SchedulerRMProxyFactory method connectToRM.

public RMProxyUserInterface connectToRM(CredData credData) throws ActiveObjectCreationException, NodeException, RMException, KeyException, LoginException {
    RMProxyUserInterface rm = PAActiveObject.newActive(RMProxyUserInterface.class, new Object[] {});
    rm.init(PortalConfiguration.RM_URL.getValueAsString(), credData);
    return rm;
}
Also used : RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)

Example 10 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 = sessionStore.get(sessionId);
    if (session == null) {
        throw new NotConnectedException("you are not connected to the scheduler, you should log on first");
    }
    RMProxyUserInterface s = session.getRM();
    if (s == null) {
        throw new NotConnectedException("you are not connected to the scheduler, 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) Session(org.ow2.proactive_grid_cloud_portal.common.Session)

Aggregations

RMProxyUserInterface (org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)10 Matchers.anyString (org.mockito.Matchers.anyString)4 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 Test (org.junit.Test)3 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)3 Attribute (javax.management.Attribute)2 AttributeList (javax.management.AttributeList)2 POST (javax.ws.rs.POST)2 HttpResponse (org.apache.http.HttpResponse)2 GZIP (org.jboss.resteasy.annotations.GZIP)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 DecimalFormat (java.text.DecimalFormat)1 DecimalFormatSymbols (java.text.DecimalFormatSymbols)1 ArrayList (java.util.ArrayList)1 ObjectName (javax.management.ObjectName)1 GET (javax.ws.rs.GET)1 NameValuePair (org.apache.http.NameValuePair)1