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