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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations