use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class RMTHelper method killRuntime.
/**
* Kills the runtime associated with specified node url
*
* @param url of the node
* @throws NodeException if node cannot be looked up
*/
public static void killRuntime(String url) throws NodeException {
try {
Node node = NodeFactory.getNode(url);
node.getProActiveRuntime().killRT(false);
} catch (Exception ignored) {
}
}
use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class RMTHelper method killNode.
/**
* Kills the node with specified url
* @param url of the node
* @throws NodeException if node cannot be looked up
*/
public static void killNode(String url) throws NodeException {
Node node = NodeFactory.getNode(url);
try {
ProActiveRuntime rt = node.getProActiveRuntime();
rt.killNode(node.getNodeInformation().getName());
} catch (Exception ignored) {
}
}
use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class RMCoreTest method configureRMNode.
private void configureRMNode(MockedRMNodeParameters param) {
RMNode rmNode = param.getRmNode();
Node mockedNode = Mockito.mock(Node.class);
NodeInformation mockedNodeInformation = Mockito.mock(NodeInformation.class);
when(mockedNode.getNodeInformation()).thenReturn(mockedNodeInformation);
when(rmNode.getNode()).thenReturn(mockedNode);
when(rmNode.getNodeName()).thenReturn(param.getUrl());
when(rmNode.getNodeURL()).thenReturn(param.getUrl());
when(rmNode.isDown()).thenReturn(param.isDown());
when(rmNode.isFree()).thenReturn(param.isFree());
when(rmNode.isLocked()).thenReturn(param.isLocked());
when(mockedNodeInformation.getURL()).thenReturn(param.getUrl());
when(mockedNodeInformation.getName()).thenReturn(param.getUrl());
when(rmNode.getNodeSource()).thenReturn(param.getNodeSource());
when(rmNode.getNodeSourceName()).thenReturn(param.getNodeSourceName());
when(rmNode.getAdminPermission()).thenReturn(null);
when(rmNode.getProvider()).thenReturn(new Client());
Client client = Mockito.mock(Client.class);
when(rmNode.getOwner()).thenReturn(client);
when(client.getName()).thenReturn("test");
when(rmNode.getNodeURL()).thenReturn(param.getUrl());
}
use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class TaskLauncherRebinder method getReboundTaskTerminateNotificationHandler.
/**
* Attempt to reaquire a correct reference to the TaskTerminateNotification
* active object from a previously saved URL for this object.
*
* @return a reference to a TaskTerminateNotification that is bounded to the
* terminateNotificationNodeURL, or null if it cannot be retrieved or if
* task is not recoverable
*/
TaskTerminateNotification getReboundTaskTerminateNotificationHandler(Throwable error) {
if (taskRecoverable) {
try {
logger.debug("List AOs on " + terminateNotificationNodeURL + " (expect only one): " + Arrays.toString(NodeFactory.getNode(terminateNotificationNodeURL).getActiveObjects(TaskTerminateNotification.class.getName())));
Node node = NodeFactory.getNode(terminateNotificationNodeURL);
Object[] aos = node.getActiveObjects(TaskTerminateNotification.class.getName());
logger.info("On node " + node.getNodeInformation().getName() + " number of active objects found is " + aos.length + " and the first one " + aos[0] + " will be used to send back the task result");
return (TaskTerminateNotification) aos[0];
} catch (Throwable t) {
// error when retrieving the termination handler after reconnection
logger.error("Failed to rebind TaskTerminatedNotification handler of task " + taskId.getReadableName() + " from URL " + terminateNotificationNodeURL + " after exception " + error.getMessage(), t);
return null;
}
} else {
return null;
}
}
use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class RMCore method releaseNodes.
/**
* {@inheritDoc}
*/
public BooleanWrapper releaseNodes(NodeSet nodes) {
if (nodes.getExtraNodes() != null) {
// do not forget to release extra nodes
nodes.addAll(nodes.getExtraNodes());
}
// exception to throw in case of problems
RuntimeException exception = null;
NodeSet nodesReleased = new NodeSet();
NodeSet nodesFailedToRelease = new NodeSet();
for (Node node : nodes) {
String nodeURL = null;
try {
nodeURL = node.getNodeInformation().getURL();
logger.debug("Releasing node " + nodeURL);
} catch (RuntimeException e) {
logger.debug("A Runtime exception occurred while obtaining information on the node," + "the node must be down (it will be detected later)", e);
// node is down, will be detected by pinger
exception = new IllegalStateException(e.getMessage(), e);
nodesFailedToRelease.add(node);
}
// verify whether the node has not been removed from the RM
if (this.allNodes.containsKey(nodeURL)) {
RMNode rmnode = this.getNodebyUrl(nodeURL);
// free
if (rmnode.isFree()) {
logger.warn("Client " + caller + " tries to release the already free node " + nodeURL);
nodesFailedToRelease.add(node);
} else if (rmnode.isDown()) {
logger.warn("Node was down, it cannot be released");
nodesFailedToRelease.add(node);
} else {
Set<? extends IdentityPrincipal> userPrincipal = rmnode.getOwner().getSubject().getPrincipals(UserNamePrincipal.class);
Permission ownerPermission = new PrincipalPermission(rmnode.getOwner().getName(), userPrincipal);
try {
caller.checkPermission(ownerPermission, caller + " is not authorized to free node " + node.getNodeInformation().getURL());
if (rmnode.isToRemove()) {
removeNodeFromCoreAndSource(rmnode, caller);
nodesReleased.add(node);
} else {
internalSetFree(rmnode);
nodesReleased.add(node);
}
} catch (SecurityException ex) {
logger.error(ex.getMessage(), ex);
nodesFailedToRelease.add(node);
exception = ex;
}
}
} else {
logger.warn("Cannot release unknown node " + nodeURL);
nodesFailedToRelease.add(node);
exception = new IllegalArgumentException("Cannot release unknown node " + nodeURL);
}
}
logger.info("Nodes released : " + nodesReleased);
if (!nodesFailedToRelease.isEmpty()) {
logger.warn("Nodes failed to release : " + nodesFailedToRelease);
}
if (exception != null) {
// throwing the latest exception we had
throw exception;
}
return new BooleanWrapper(true);
}
Aggregations