use of org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl in project scheduling by ow2-proactive.
the class NodeSource method buildRMNodeAfterRecovery.
/**
* Rebuild a RMNode from a node that could be looked up again after a
* recovery of the RM. This builder configures nothing for the node
* because it is configured already as it suppoesed to be recovered from
* the database.
* @return the expected RMNode
*/
private RMNode buildRMNodeAfterRecovery(Node node, RMNodeData rmNodeData) {
RMNodeImpl rmNode = new RMNodeImpl(node, stub, rmNodeData.getName(), rmNodeData.getNodeUrl(), rmNodeData.getProvider(), rmNodeData.getHostname(), rmNodeData.getJmxUrls(), rmNodeData.getJvmName(), rmNodeData.getUserPermission(), rmNodeData.getState());
if (rmNodeData.getState().equals(NodeState.BUSY)) {
logger.info("Node " + rmNodeData.getName() + " was found busy after scheduler recovery with owner " + rmNodeData.getOwner());
rmNode.setBusy(rmNodeData.getOwner());
}
return rmNode;
}
use of org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl in project scheduling by ow2-proactive.
the class NodeSource method buildRMNode.
/**
* Builds a RMNode from a raw Node
* @param node the node object
* @param provider the client of the request
* @return the expected RMNode
*/
private RMNode buildRMNode(Node node, Client provider) {
// creating a node access permission
// it could be either PROVIDER/PROVIDER_GROUPS and in this case
// the provider principals will be taken or
// ME/MY_GROUPS (ns creator/ns creator groups) and in this case
// creator's principals will be used
Client permissionOwner = administrator;
if (nodeUserAccessType.equals(AccessType.PROVIDER) || nodeUserAccessType.equals(AccessType.PROVIDER_GROUPS)) {
permissionOwner = provider;
}
// now selecting the type (user or group) and construct the permission
Set<IdentityPrincipal> principals = (Set<IdentityPrincipal>) nodeUserAccessType.getIdentityPrincipals(permissionOwner);
boolean tokenInNode = false;
boolean tokenInNodeSource = nodeUserAccessType.getTokens() != null && nodeUserAccessType.getTokens().length > 0;
try {
String nodeAccessToken = node.getProperty(RMNodeStarter.NODE_ACCESS_TOKEN);
tokenInNode = nodeAccessToken != null && nodeAccessToken.length() > 0;
if (tokenInNode) {
logger.debug("Node " + node.getNodeInformation().getURL() + " is protected by access token " + nodeAccessToken);
// it overrides all other principals
principals.clear();
principals.add(new TokenPrincipal(nodeAccessToken));
}
} catch (Exception e) {
throw new AddingNodesException(e);
}
PrincipalPermission nodeAccessPermission = new PrincipalPermission(node.getNodeInformation().getURL(), principals);
RMNodeImpl rmnode = new RMNodeImpl(node, stub, provider, nodeAccessPermission);
rmnode.setProtectedByToken(tokenInNode || tokenInNodeSource);
return rmnode;
}
use of org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl in project scheduling by ow2-proactive.
the class NodesLockRestorationManagerTest method testHandleNotInitialized.
@Test
public void testHandleNotInitialized() {
// creates a node that matches an entry in the table specifying the nodes to lock
RMNodeImpl rmNode = RMNodeHelper.basicWithMockedInternals("ns1", "n1", "h1", "nurl1", "parurl1").getLeft();
assertThat(rmNode.isLocked()).isFalse();
Map<String, MutableInteger> table = Maps.newHashMap();
MutableInteger putResult = table.put("ns", new MutableInteger(1));
assertThat(putResult).isNull();
doReturn(table).when(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
assertThat(table).hasSize(1);
verify(rmCore, never()).lockNodes(anySetOf(String.class));
nodesLockRestorationManager.handle(rmNode, caller);
assertThat(table).hasSize(1);
verify(rmCore, never()).lockNodes(anySetOf(String.class));
}
use of org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl in project scheduling by ow2-proactive.
the class NodesLockRestorationManagerTest method testHandleNodeAlreadyLocked.
@Test
public void testHandleNodeAlreadyLocked() {
RMNodeImpl rmNode = RMNodeHelper.basicWithMockedInternals("ns1", "n1", "h1", "nurl1", "parurl1").getLeft();
rmNode.lock(null);
assertThat(rmNode.isLocked()).isTrue();
Map<String, MutableInteger> table = Maps.newHashMap();
MutableInteger putResult = table.put("ns", new MutableInteger(1));
assertThat(putResult).isNull();
doReturn(table).when(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
nodesLockRestorationManager.initialize();
assertThat(nodesLockRestorationManager.isInitialized()).isTrue();
verify(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
assertThat(table).hasSize(1);
verify(rmCore, never()).lockNodes(anySetOf(String.class));
nodesLockRestorationManager.handle(rmNode, caller);
assertThat(table).hasSize(1);
verify(rmCore, never()).lockNodes(anySetOf(String.class));
}
use of org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl in project scheduling by ow2-proactive.
the class NodeSourceTest method testSetNodeAvailableKnownNode.
@Test
public void testSetNodeAvailableKnownNode() throws RMException {
Node node = createNode(PROACTIVE_PROGRAMMING_NODE_URL);
RMNode rmNode = new RMNodeImpl(node, nodeSource, client, mock(Permission.class));
nodeSource.internalAddNode(node);
nodeSource.detectedPingedDownNode(node.getNodeInformation().getName(), node.getNodeInformation().getURL());
assertThat(nodeSource.getDownNodes()).hasSize(1);
boolean result = nodeSource.setNodeAvailable(rmNode);
assertThat(result).isTrue();
assertThat(nodeSource.getDownNodes()).hasSize(0);
}
Aggregations