use of org.objectweb.proactive.core.node.Node 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.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class NodeSource method acquireNode.
/**
* Acquires the existing node with specific url. The node have to be up and running.
*
* @param nodeUrl the url of the node
* @param provider
*/
public BooleanWrapper acquireNode(String nodeUrl, Client provider) {
if (toShutdown) {
throw new AddingNodesException("[" + name + "] node " + nodeUrl + " adding request discarded because node source is shutting down");
}
// checking that client has a right to change this node source
// if the provider is the administrator of the node source it always has this permission
provider.checkPermission(providerPermission, provider + " is not authorized to add node " + nodeUrl + " to " + name);
// lookup for a new Node
int lookUpTimeout = PAResourceManagerProperties.RM_NODELOOKUP_TIMEOUT.getValueAsInt();
Node nodeToAdd = null;
try {
logger.info("Looking up the node " + nodeUrl + " with " + lookUpTimeout + " ms timeout");
nodeToAdd = lookupNode(nodeUrl, lookUpTimeout);
logger.info("The node " + nodeUrl + " has been successfully looked up");
} catch (Exception e) {
logger.warn("Cannot look up the node " + nodeUrl + " within " + lookUpTimeout + " ms due to " + e.getMessage(), e);
throw new AddingNodesException(e);
}
// node should be not null at this point...
if (nodeToAdd == null) {
throw new AddingNodesException("Cannot lookup node for unknown reason : " + nodeUrl);
}
// now checking if this node has been registered before in the node source
if (downNodes.containsKey(nodeUrl)) {
// it was registered but detected as down node,
// so basically the node was restarted.
// adding a new node and removing old one from the down list
logger.debug("Removing existing node from down nodes list");
BooleanWrapper result = rmcore.removeNodeFromCore(nodeUrl);
if (result.getBooleanValue()) {
if (logger.isDebugEnabled())
logger.debug("[" + name + "] successfully removed node " + nodeUrl + " from the core");
// just removing it from down nodes list
removeNode(nodeUrl, provider);
}
} else if (nodes.containsKey(nodeUrl)) {
// adding a node which exists in node source
Node existingNode = nodes.get(nodeUrl);
if (nodeToAdd.equals(existingNode)) {
// don't do anything
if (logger.isDebugEnabled())
logger.debug("An attempt to add the same node twice " + nodeUrl + " - ignoring");
return new BooleanWrapper(false);
} else {
// adding another node with the same url
// replacing the old node by the new one
logger.debug("Removing existing node from the RM without request propagation to the infrastructure manager");
BooleanWrapper result = rmcore.removeNodeFromCore(nodeUrl);
if (result.getBooleanValue()) {
if (logger.isDebugEnabled())
logger.debug("[" + name + "] successfully removed node " + nodeUrl + " from the core");
// removing it from the nodes list but don't propagate
// the request the the infrastructure because the restarted node will be killed
nodes.remove(nodeUrl);
}
}
}
// if any exception occurs in internalAddNode(node) do not add the node to the core
RMDeployingNode deployingNode;
try {
deployingNode = internalAddNode(nodeToAdd);
} catch (RMException e) {
throw new AddingNodesException(e);
}
// we build the rmnode
RMNode rmNode = buildRMNode(nodeToAdd, provider);
if (deployingNode != null) {
// inherit locking status from associated deploying node created before
((AbstractRMNode) rmNode).copyLockStatusFrom(deployingNode);
}
boolean isNodeAdded = rmcore.registerAvailableNode(rmNode).getBooleanValue();
if (isNodeAdded) {
// if the node is successfully added we can let it configure
// asynchronously. It will then be seen as "configuring"
rmcore.internalRegisterConfiguringNode(rmNode);
return new BooleanWrapper(true);
} else {
return new BooleanWrapper(false);
}
}
use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class NodeSource method runActivity.
public void runActivity(Body body) {
Service service = new Service(body);
long timeStamp = System.currentTimeMillis();
long delta = 0;
// recalculating nodes number only once per policy period
while (body.isActive()) {
try {
service.blockingServeOldest(pingFrequency);
delta += System.currentTimeMillis() - timeStamp;
timeStamp = System.currentTimeMillis();
if (delta > pingFrequency) {
logger.info("[" + name + "] Pinging alive nodes : " + getAliveNodes().size());
for (Node node : getAliveNodes()) {
pingNode(node);
}
delta = 0;
}
} catch (InterruptedException e) {
logger.warn("runActivity interrupted", e);
}
}
}
use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class DefaultInfrastructureManager method isThereNodesInSameJVM.
/**
* Check if there are any other nodes handled by the NodeSource in the same
* JVM of the node passed in parameter.
*
* @param node
* Node to check if there any other node of the NodeSource in the
* same JVM
* @return true there is another node in the node's JVM handled by the
* nodeSource, false otherwise.
*/
public boolean isThereNodesInSameJVM(Node node) {
VMID nodeID = node.getVMInformation().getVMID();
String nodeToTestUrl = node.getNodeInformation().getURL();
Collection<Node> nodesList = nodeSource.getAliveNodes();
for (Node n : nodesList) {
if (!n.getNodeInformation().getURL().equals(nodeToTestUrl) && n.getVMInformation().getVMID().equals(nodeID)) {
return true;
}
}
return false;
}
use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.
the class SSHInfrastructure method killNodeImpl.
@Override
protected void killNodeImpl(Node node, InetAddress host) {
final Node n = node;
this.nodeSource.executeInParallel(new Runnable() {
public void run() {
try {
n.getProActiveRuntime().killRT(false);
} catch (Exception e) {
logger.trace("An exception occurred during node removal", e);
}
}
});
}
Aggregations