use of org.ow2.proactive.resourcemanager.common.NodeState in project scheduling by ow2-proactive.
the class RMCore method setBusyNode.
/**
* Set a node state to busy. Set the node to busy, and move the node to the
* internal busy nodes list. An event informing the node state's change is
* thrown to RMMonitoring.
*
* @param owner
* @param nodeUrl node to set
*/
public void setBusyNode(final String nodeUrl, Client owner) throws NotConnectedException {
final RMNode rmNode = this.allNodes.get(nodeUrl);
if (rmNode == null) {
logger.error("Unknown node " + nodeUrl);
return;
}
if (!clients.containsKey(owner.getId())) {
logger.warn(nodeUrl + " cannot set busy as the client disconnected " + owner);
throw new NotConnectedException("Client " + owner + " is not connected to the resource manager");
}
// If the node is already busy no need to go further
if (rmNode.isBusy()) {
return;
}
// Get the previous state of the node needed for the event
final NodeState previousNodeState = rmNode.getState();
rmNode.setBusy(owner);
this.eligibleNodes.remove(rmNode);
persistUpdatedRMNodeIfRecoveryEnabled(rmNode);
// create the event
this.registerAndEmitNodeEvent(rmNode.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousNodeState, owner.getName()));
}
use of org.ow2.proactive.resourcemanager.common.NodeState in project scheduling by ow2-proactive.
the class RMCore method restoreNodeState.
@VisibleForTesting
void restoreNodeState(String nodeUrl, RMNode node) {
NodeState previousNodeState = node.getLastEvent().getPreviousNodeState();
if (previousNodeState == NodeState.BUSY) {
logger.info("Restoring DOWN node to BUSY: " + nodeUrl);
setBusyNode(nodeUrl, node.getOwner());
} else {
logger.info("Restoring DOWN node to FREE: " + nodeUrl);
internalSetFree(node);
}
node.getNodeSource().setNodeAvailable(node);
}
use of org.ow2.proactive.resourcemanager.common.NodeState in project scheduling by ow2-proactive.
the class InfrastructureManager method declareDeployingNodeLost.
/**
* Declares a deploying node lost. Future attempts to modify the deploying
* node will be ignored.
*
* @param toUpdateURL
* The RMDeployingNode's URL which is to be declared as lost
* @param description
* the new rmdeployingnode's description, can be null.
* @return true if the method ran successfully, false otherwise.
*/
protected final boolean declareDeployingNodeLost(String toUpdateURL, String description) {
RMDeployingNode deployingNode;
// we need to atomically move the node from the deploying collection to
// the lost one.
writeLock.lock();
try {
deployingNode = removeDeployingNodeWithLockAndPersist(toUpdateURL);
if (deployingNode != null) {
addLostNodeWithLockAndPersist(toUpdateURL, deployingNode);
}
} catch (RuntimeException e) {
logger.error("Exception while moving a node from deploying to lost: " + e.getMessage());
throw e;
} finally {
writeLock.unlock();
}
if (deployingNode != null) {
logger.warn("Declaring node as lost: " + toUpdateURL + ", " + description);
NodeState previousState = deployingNode.getState();
RMDeployingNodeAccessor.getDefault().setLost(deployingNode);
if (description != null) {
RMDeployingNodeAccessor.getDefault().setDescription(deployingNode, description);
}
RMNodeEvent event = deployingNode.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousState, deployingNode.getProvider().getName());
emitEvent(event);
if (logger.isTraceEnabled()) {
logger.trace(RMDeployingNode.class.getSimpleName() + " " + toUpdateURL + " declared lost in IM");
}
return true;
} else {
if (logger.isTraceEnabled()) {
logger.trace(RMDeployingNode.class.getSimpleName() + " " + toUpdateURL + " no more managed by IM, cannot declare it as lost");
}
return false;
}
}
use of org.ow2.proactive.resourcemanager.common.NodeState in project scheduling by ow2-proactive.
the class NodesRecoveryManager method recoverNodes.
protected void recoverNodes(NodeSource nodeSource) {
// this log line is important for performance tests
logger.info(START_TO_RECOVER_NODES);
int lookUpTimeout = PAResourceManagerProperties.RM_NODELOOKUP_TIMEOUT.getValueAsInt();
String nodeSourceName = nodeSource.getName();
this.logWarnIfNodeSourceHasNoNode(nodeSource, nodeSourceName);
Collection<RMNodeData> nodesData = this.rmCore.getDbManager().getNodesByNodeSource(nodeSourceName);
logger.info("Number of nodes found in database for node source " + nodeSourceName + ": " + nodesData.size());
List<RMNode> recoveredEligibleNodes = Collections.synchronizedList(new ArrayList<RMNode>());
Map<NodeState, Integer> recoveredNodeStatesCounter = new HashMap<>();
// as down node
for (RMNodeData rmNodeData : nodesData) {
String nodeUrl = rmNodeData.getNodeUrl();
Node node = this.tryToLookupNode(nodeSource, lookUpTimeout, nodeUrl);
RMNode rmnode = this.recoverRMNode(nodeSource, recoveredNodeStatesCounter, rmNodeData, nodeUrl, node);
if (this.isEligible(rmnode)) {
recoveredEligibleNodes.add(rmnode);
}
}
this.rmCore.setEligibleNodesToRecover(recoveredEligibleNodes);
this.logNodeRecoverySummary(nodeSourceName, recoveredNodeStatesCounter, recoveredEligibleNodes.size());
}
use of org.ow2.proactive.resourcemanager.common.NodeState in project scheduling by ow2-proactive.
the class NodesRecoveryManager method recoverRMNode.
private RMNode recoverRMNode(NodeSource nodeSource, Map<NodeState, Integer> nodeStates, RMNodeData rmNodeData, String nodeUrl, Node node) {
RMNode rmnode = null;
if (node != null) {
rmnode = this.recoverNodeInternally(nodeSource, rmNodeData, nodeUrl, node);
this.nodesLockRestorationManager.handle(rmnode, rmNodeData.getProvider());
this.updateRecoveredNodeStateCounter(nodeStates, rmnode.getState());
} else {
// the node is not recoverable and does not appear in any data
// structures: we can remove it safely from database
this.rmCore.getDbManager().removeNode(rmNodeData, rmNodeData.getNodeSource().getName());
this.markNodesNotInDeployingStateAsDown(nodeSource, rmNodeData, nodeUrl);
this.updateRecoveredNodeStateCounter(nodeStates, NodeState.DOWN);
}
return rmnode;
}
Aggregations