Search in sources :

Example 1 with NodeState

use of org.ow2.proactive.resourcemanager.common.NodeState in project scheduling by ow2-proactive.

the class RMCore method setDownNode.

/**
 * Sets a node state to down and updates all internal structures of rm core
 * accordingly. Sends an event indicating that the node is down.
 */
public void setDownNode(String nodeUrl) {
    RMNode rmNode = getNodebyUrl(nodeUrl);
    if (rmNode != null) {
        // If the node is already down no need to go further
        if (rmNode.isDown()) {
            return;
        }
        logger.info("The node " + rmNode.getNodeURL() + " provided by " + rmNode.getProvider() + " is down");
        // Get the previous state of the node needed for the event
        final NodeState previousNodeState = rmNode.getState();
        if (rmNode.isFree()) {
            eligibleNodes.remove(rmNode);
        }
        rmNode.setDown();
        persistUpdatedRMNodeIfRecoveryEnabled(rmNode);
        // create the event
        this.registerAndEmitNodeEvent(rmNode.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousNodeState, rmNode.getProvider().getName()));
    } else {
        // the nodes has been removed from core asynchronously
        // when pinger of selection manager tried to access it
        // do nothing in this case
        logger.debug("setDownNode returned immediately because the node " + nodeUrl + " was not known");
    }
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) NodeState(org.ow2.proactive.resourcemanager.common.NodeState)

Example 2 with NodeState

use of org.ow2.proactive.resourcemanager.common.NodeState in project scheduling by ow2-proactive.

the class InfrastructureManager method updateDeployingNodeDescription.

/**
 * To update the description of a deploying node. If a timeout has occurred
 * for this node, the update is discarded.
 *
 * @param toUpdateURL
 *            The RMDeployingNode's URL whose description will be updated.
 * @param newDescription
 *            The new description
 * @return true in case of success, false if the deploying node is not
 *         managed by the IM anymore.
 */
protected final boolean updateDeployingNodeDescription(String toUpdateURL, String newDescription) {
    RMDeployingNode pn = getDeployingNodeWithLock(toUpdateURL);
    if (pn != null) {
        NodeState previousState = pn.getState();
        RMDeployingNodeAccessor.getDefault().setDescription(pn, newDescription);
        RMNodeEvent event = pn.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousState, pn.getProvider().getName());
        emitEvent(event);
        logger.trace("DeployingNode " + toUpdateURL + " updated in IM");
        return true;
    } else {
        logger.trace("DeployingNode " + toUpdateURL + " no more managed by the IM, cannot update it");
        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 3 with NodeState

use of org.ow2.proactive.resourcemanager.common.NodeState in project scheduling by ow2-proactive.

the class RMStatistics method nodeEvent.

/**
 * Handle incoming node events of the Resource Manager
 * @param event incoming event
 */
public void nodeEvent(final RMNodeEvent event) {
    // Update cumulative times based on activity and inactivity during the last time interval
    final long currentTimeStamp = System.nanoTime();
    final long timeInterval = currentTimeStamp - this.previousTimeStamp;
    this.cumulativeActivityTime += this.busyNodesCount * timeInterval;
    this.cumulativeInactivityTime += this.freeNodesCount * timeInterval;
    // Update the previous time stamp to the current
    this.previousTimeStamp = currentTimeStamp;
    // Depending on the event type update nodes count
    switch(event.getEventType()) {
        case NODE_ADDED:
            // Increment the available nodes count
            this.availableNodesCount++;
            // We define the state of the added node
            final NodeState addNodeState = event.getNodeState();
            switch(addNodeState) {
                case FREE:
                    this.incrementFreeNodesCount();
                    break;
                case CONFIGURING:
                    this.incrementConfiguringNodesCount();
                    break;
                case DEPLOYING:
                    this.incrementDeployingNodesCount();
                    break;
                case LOST:
                    this.incrementLostNodesCount();
                    break;
                case BUSY:
                    this.incrementBusyNodesCount();
                    break;
                case DOWN:
                    this.incrementDownNodesCount();
                    break;
                case TO_BE_REMOVED:
                    this.incrementToBeRemovedNodesCount();
                    break;
                default:
            }
            break;
        case NODE_REMOVED:
            // Get the state of the node before it was removed
            final NodeState nodeState = event.getNodeState();
            switch(nodeState) {
                case FREE:
                    this.decrementFreeNodesCount();
                    break;
                case BUSY:
                    this.decrementBusyNodesCount();
                    break;
                case TO_BE_REMOVED:
                    this.decrementToBeRemovedNodesCount();
                    break;
                case DOWN:
                    this.decrementDownNodesCount();
                    break;
                case CONFIGURING:
                    this.decrementConfiguringNodesCount();
                    break;
                case LOST:
                    this.decrementLostNodesCount();
                    break;
                case DEPLOYING:
                    this.decrementDeployingNodesCount();
                    break;
                default:
            }
            this.decrementAvailableNodesCount();
            break;
        case NODE_STATE_CHANGED:
            // Depending on the previous state decrement counters
            final NodeState previousNodeState = event.getPreviousNodeState();
            if (previousNodeState != null) {
                switch(previousNodeState) {
                    case FREE:
                        this.decrementFreeNodesCount();
                        break;
                    case BUSY:
                        this.decrementBusyNodesCount();
                        break;
                    case TO_BE_REMOVED:
                        this.decrementToBeRemovedNodesCount();
                        break;
                    case DOWN:
                        this.decrementDownNodesCount();
                        break;
                    case CONFIGURING:
                        this.decrementConfiguringNodesCount();
                        break;
                    case LOST:
                        this.decrementLostNodesCount();
                        break;
                    case DEPLOYING:
                        this.decrementDeployingNodesCount();
                        break;
                    default:
                }
            }
            // can't be null
            final NodeState currentNodeState = event.getNodeState();
            // Depending on the current state increment counters
            switch(currentNodeState) {
                case FREE:
                    this.incrementFreeNodesCount();
                    break;
                case BUSY:
                    this.incrementBusyNodesCount();
                    break;
                case TO_BE_REMOVED:
                    this.incrementToBeRemovedNodesCount();
                    break;
                case DOWN:
                    this.incrementDownNodesCount();
                    break;
                case CONFIGURING:
                    this.incrementConfiguringNodesCount();
                    break;
                case LOST:
                    this.incrementLostNodesCount();
                    break;
                case DEPLOYING:
                    this.incrementDeployingNodesCount();
                    break;
                default:
            }
        default:
    }
}
Also used : NodeState(org.ow2.proactive.resourcemanager.common.NodeState)

Example 4 with NodeState

use of org.ow2.proactive.resourcemanager.common.NodeState in project scheduling by ow2-proactive.

the class RMDBManagerBufferTest method addRMNodeData.

private RMNodeData addRMNodeData(String nodeName, NodeState state) {
    RMNodeData rmNodeData = new RMNodeData(nodeName, NODE_URL, owner, provider, permission, state, STATE_CHANGE_TIME_BASE, HOSTNAME, JMX_URLS, JVM_NAME);
    rmNodeData.setNodeSource(nodeSourceData);
    dbManager.addNode(rmNodeData, NODE_SOURCE_NAME_BASE);
    return rmNodeData;
}
Also used : RMNodeData(org.ow2.proactive.resourcemanager.db.RMNodeData)

Example 5 with NodeState

use of org.ow2.proactive.resourcemanager.common.NodeState in project scheduling by ow2-proactive.

the class RMCoreTest method configureNodeForStateChange.

private void configureNodeForStateChange(RMNode mockedRmNode, NodeState previousNodeState) {
    RMNodeEvent rmNodeEvent = createRmNodeEvent(previousNodeState);
    when(mockedRmNode.getLastEvent()).thenReturn(rmNodeEvent);
    when(mockedRmNode.getOwner()).thenReturn(new Client(null, false));
    RMCore.clients.put(mockedRmNode.getOwner().getId(), mockedRmNode.getOwner());
}
Also used : Client(org.ow2.proactive.resourcemanager.authentication.Client) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

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