Search in sources :

Example 11 with NodeState

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()));
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) NodeState(org.ow2.proactive.resourcemanager.common.NodeState) NotConnectedException(org.ow2.proactive.resourcemanager.exception.NotConnectedException)

Example 12 with NodeState

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);
}
Also used : NodeState(org.ow2.proactive.resourcemanager.common.NodeState) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 13 with NodeState

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;
    }
}
Also used : NodeState(org.ow2.proactive.resourcemanager.common.NodeState) RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

Example 14 with NodeState

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());
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) NodeState(org.ow2.proactive.resourcemanager.common.NodeState) HashMap(java.util.HashMap) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Node(org.objectweb.proactive.core.node.Node) RMNodeData(org.ow2.proactive.resourcemanager.db.RMNodeData)

Example 15 with NodeState

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;
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode)

Aggregations

NodeState (org.ow2.proactive.resourcemanager.common.NodeState)9 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)5 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)4 Client (org.ow2.proactive.resourcemanager.authentication.Client)3 RMNodeData (org.ow2.proactive.resourcemanager.db.RMNodeData)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 HashMap (java.util.HashMap)2 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)2 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)2 Matchers.anyString (org.mockito.Matchers.anyString)1 Node (org.objectweb.proactive.core.node.Node)1 RMNodeDescriptor (org.ow2.proactive.resourcemanager.common.event.RMNodeDescriptor)1 RMDBManager (org.ow2.proactive.resourcemanager.db.RMDBManager)1 NotConnectedException (org.ow2.proactive.resourcemanager.exception.NotConnectedException)1 RMMonitoringImpl (org.ow2.proactive.resourcemanager.frontend.RMMonitoringImpl)1 NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)1 RMNodeImpl (org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl)1 SelectionManager (org.ow2.proactive.resourcemanager.selection.SelectionManager)1