use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class CLIInfrastructure method killNodeImpl.
/**
* {@inheritDoc}
*/
@Override
protected void killNodeImpl(Node node, InetAddress h) {
final Node n = node;
final InetAddress host = h;
incrementNbRemovalThread();
this.nodeSource.executeInParallel(new Runnable() {
public void run() {
try {
final String commandLine = interpreter + " " + removalScript.getAbsolutePath() + " " + host.getHostName() + " " + n.getNodeInformation().getURL();
Process p;
try {
logger.debug("Launching the command: " + commandLine);
p = Runtime.getRuntime().exec(commandLine);
// TODO add timeout behavior
int exitCode = p.waitFor();
String pOutPut = Utils.extractProcessOutput(p);
String pErrPut = Utils.extractProcessErrput(p);
String lf = System.lineSeparator();
final String description = "Removal script ouput" + lf + " >Error code: " + exitCode + lf + " >Errput: " + pErrPut + " >Output: " + pOutPut;
if (exitCode != 0) {
logger.error("Child process at " + host.getHostName() + " exited abnormally (" + exitCode + ").");
logger.error(description);
} else {
logger.info("Removal node process has exited normally for " + n.getNodeInformation().getURL());
logger.debug(description);
}
} catch (IOException e1) {
logger.error(e1);
}
} catch (Exception e) {
logger.trace("An exception occurred during node removal", e);
}
decrementNbRemovalThread();
}
});
}
use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class DefaultInfrastructureManager method removeNode.
/**
* {@inheritDoc}
*/
@Override
public void removeNode(Node node) throws RMException {
try {
logger.info("Terminating the node " + node.getNodeInformation().getName());
if (!isThereNodesInSameJVM(node)) {
final Node n = node;
nodeSource.executeInParallel(new Runnable() {
public void run() {
try {
logger.info("Terminating the runtime " + n.getProActiveRuntime().getURL());
n.getProActiveRuntime().killRT(false);
} catch (Exception e) {
// do nothing, no exception treatment for node just
// killed before
}
}
});
}
decrementNodesCount();
} catch (Exception e) {
throw new RMException(e);
}
}
use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class RMRest method releaseNode.
/**
* Release a node
*
* @param sessionId a valid session id
* @param url node's URL
* @return true of the node has been released
* @throws NodeException
* @throws NotConnectedException
*/
@Override
@POST
@Path("node/release")
@Produces("application/json")
public boolean releaseNode(@HeaderParam("sessionid") String sessionId, @FormParam("url") String url) throws NodeException, NotConnectedException {
ResourceManager rm = checkAccess(sessionId);
Node n;
n = NodeFactory.getNode(url);
return rm.releaseNode(n).getBooleanValue();
}
use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class HAC method initClusterDistances.
private HashMap<Cluster<Node>, HashMap<Cluster<Node>, Long>> initClusterDistances(List<Node> from) {
if (pivot.size() > 0) {
from = new LinkedList<>(from);
for (Node piv : pivot) {
if (!from.contains(piv))
from.add(piv);
}
}
HashMap<Cluster<Node>, HashMap<Cluster<Node>, Long>> clusterDistances = new HashMap<>();
for (Node node : from) {
Cluster<Node> newCluster = new Cluster<>(getNodeId(node), node);
HashMap<Cluster<Node>, Long> dist = new HashMap<>();
for (Cluster<Node> cluster : clusterDistances.keySet()) {
dist.put(cluster, getDistance(node, cluster.getElements().get(0)));
}
clusterDistances.put(newCluster, dist);
}
return clusterDistances;
}
use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class HostsPinger method ping.
/**
* Pings remote nodes and returns distances to hosts where these nodes are located.
*
* @param nodes to ping
* @return distances map to hosts where these nodes are located
*/
public HashMap<InetAddress, Long> ping(NodeSet nodes) {
HashMap<InetAddress, Long> results = new HashMap<>();
for (Node node : nodes) {
try {
InetAddress current = NodeFactory.getDefaultNode().getVMInformation().getInetAddress();
InetAddress nodeAddress = node.getVMInformation().getInetAddress();
if (current.equals(nodeAddress)) {
// nodes on the same host
results.put(nodeAddress, new Long(0));
} else {
results.put(nodeAddress, pingHost(nodeAddress));
}
} catch (NodeException e) {
}
}
return results;
}
Aggregations