Search in sources :

Example 6 with NodeSource

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

the class RMDeployingNodeTest method createDeployingNode.

private RMDeployingNode createDeployingNode(String name) {
    Client client = Mockito.mock(Client.class);
    NodeSource nodeSource = Mockito.mock(NodeSource.class);
    return new RMDeployingNode(name, nodeSource, "command", client);
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) Client(org.ow2.proactive.resourcemanager.authentication.Client)

Example 7 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 8 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 9 with NodeSource

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

the class RMCore method getNodeByUrlIncludingDeployingNodes.

protected RMNode getNodeByUrlIncludingDeployingNodes(String url) {
    RMNode nodeByUrl = getNodebyUrl(url);
    if (nodeByUrl != null) {
        return nodeByUrl;
    } else {
        String[] chunks = url.split("/");
        if (chunks.length >= 3) {
            String nodeSourceName = chunks[2];
            NodeSource nodeSource = this.deployedNodeSources.get(nodeSourceName);
            if (nodeSource != null) {
                return nodeSource.getNodeInDeployingOrLostNodes(url);
            }
        }
    }
    return null;
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode)

Example 10 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)

Aggregations

NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)21 Test (org.junit.Test)17 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)13 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)11 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)11 Client (org.ow2.proactive.resourcemanager.authentication.Client)9 Node (org.objectweb.proactive.core.node.Node)8 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)7 ArrayList (java.util.ArrayList)6 RMNodeSourceEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)6 Permission (java.security.Permission)5 NodeSourceData (org.ow2.proactive.resourcemanager.db.NodeSourceData)5 RMException (org.ow2.proactive.resourcemanager.exception.RMException)5 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)4 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Matchers.anyString (org.mockito.Matchers.anyString)4