Search in sources :

Example 1 with NodeSource

use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.

the class SelectionManagerTest method createMockeNode.

public static RMNode createMockeNode(String nodeUser, String nodeName, String nodeUrl) {
    RMNode rmNode = mock(RMNode.class);
    NodeInformation mockedNodeInformation = mock(NodeInformation.class);
    Node node = mock(Node.class);
    when(mockedNodeInformation.getURL()).thenReturn(nodeUrl);
    when(mockedNodeInformation.getName()).thenReturn(nodeName);
    when(node.getNodeInformation()).thenReturn(mockedNodeInformation);
    when(rmNode.getNodeName()).thenReturn(nodeName);
    when(rmNode.getNodeSource()).thenReturn(new NodeSource());
    when(rmNode.getNode()).thenReturn(node);
    when(rmNode.getNodeURL()).thenReturn(nodeUrl);
    when(rmNode.getUserPermission()).thenReturn(new PrincipalPermission("permissions", singleton(new UserNamePrincipal(nodeUser))));
    return rmNode;
}
Also used : UserNamePrincipal(org.ow2.proactive.authentication.principals.UserNamePrincipal) NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) NodeInformation(org.objectweb.proactive.core.node.NodeInformation) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Node(org.objectweb.proactive.core.node.Node) PrincipalPermission(org.ow2.proactive.permissions.PrincipalPermission)

Example 2 with NodeSource

use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.

the class NodesRecoveryManager method tryToLookupNode.

private Node tryToLookupNode(NodeSource nodeSource, int lookUpTimeout, String nodeUrl) {
    Node node = null;
    try {
        logger.info("Trying to lookup node to recover: " + nodeUrl);
        node = nodeSource.lookupNode(nodeUrl, lookUpTimeout);
    } catch (Exception e) {
        // do not log exception message here: not being able to look up a
        // node to recover is not an exceptional behavior
        logger.warn("Node to recover could not be looked up");
    }
    return node;
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Node(org.objectweb.proactive.core.node.Node)

Example 3 with NodeSource

use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.

the class RMCore method checkNodeAdminPermission.

/**
 * Checks if the client is the node admin.
 *
 * @param rmnode is a node to be checked
 * @param client is a client to be checked
 * @return true if the client is an admin, SecurityException otherwise
 */
private boolean checkNodeAdminPermission(RMNode rmnode, Client client) {
    NodeSource nodeSource = rmnode.getNodeSource();
    String errorMessage = client.getName() + " is not authorized to manage node " + rmnode.getNodeURL() + " from " + rmnode.getNodeSourceName();
    // a node provider
    try {
        // checking if the caller is an administrator
        client.checkPermission(nodeSource.getAdminPermission(), errorMessage);
    } catch (SecurityException ex) {
        // the caller is not an administrator, so checking if it is a node provider
        client.checkPermission(rmnode.getAdminPermission(), errorMessage);
    }
    return true;
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource)

Example 4 with NodeSource

use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.

the class InfrastructureManager method emitEvent.

// **********************************************************************************************//
// *********************** Package private accessors & Helpers
// **********************************//
// **********************************************************************************************//
/**
 * To emit an event and register it in the database
 */
private void emitEvent(final RMNodeEvent event) {
    NodeSource nsStub = this.nodeSource.getStub();
    nsStub.internalEmitDeployingNodeEvent(event);
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource)

Example 5 with NodeSource

use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.

the class TestExecRemote method scriptOnNodeSource.

private void scriptOnNodeSource(String nsName, HashSet<String> nodesUrls) throws Exception {
    RMTHelper.log("Test 6 - Execute script on a specified nodesource name");
    SimpleScript script = new SimpleScript(TestExecRemote.simpleScriptContent, "javascript");
    HashSet<String> targets = new HashSet<>(1);
    targets.add(nsName);
    List<ScriptResult<Object>> results = rmHelper.getResourceManager().executeScript(script, TargetType.NODESOURCE_NAME.toString(), targets);
    assertEquals("The size of result list must equal to size of nodesource", nodesUrls.size(), results.size());
    for (ScriptResult<Object> res : results) {
        Throwable exception = res.getException();
        if (exception != null) {
            RMTHelper.log("An exception occured while executing the script remotely:");
            exception.printStackTrace(System.out);
        }
        assertNull("No exception must occur", exception);
    }
}
Also used : ScriptResult(org.ow2.proactive.scripting.ScriptResult) SimpleScript(org.ow2.proactive.scripting.SimpleScript) HashSet(java.util.HashSet)

Aggregations

NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)32 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)19 Test (org.junit.Test)17 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)17 Node (org.objectweb.proactive.core.node.Node)12 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)12 RMException (org.ow2.proactive.resourcemanager.exception.RMException)11 Client (org.ow2.proactive.resourcemanager.authentication.Client)10 RMNodeSourceEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)9 AddingNodesException (org.ow2.proactive.resourcemanager.exception.AddingNodesException)9 URISyntaxException (java.net.URISyntaxException)7 ArrayList (java.util.ArrayList)7 NSAdminPermission (org.ow2.proactive.permissions.NSAdminPermission)7 RMCoreAllPermission (org.ow2.proactive.permissions.RMCoreAllPermission)7 NodeSourceData (org.ow2.proactive.resourcemanager.db.NodeSourceData)7 ScriptException (org.ow2.proactive.scripting.ScriptException)7 HashSet (java.util.HashSet)6 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)6 NodeException (org.objectweb.proactive.core.node.NodeException)6 IOException (java.io.IOException)5