Search in sources :

Example 6 with NodeState

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

the class RMDBManagerTest 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 7 with NodeState

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

the class RMCoreTest method testLockNodeState.

private void testLockNodeState(NodeState nodeState) {
    RMNodeImpl rmNode = spy(RMNodeHelper.basicWithMockedInternals().getLeft());
    rmNode.setState(nodeState);
    HashMap<String, RMNode> allNodes = new HashMap<>();
    allNodes.put(rmNode.getNodeURL(), rmNode);
    ArrayList<RMNode> freeNodes = Lists.newArrayList((RMNode) rmNode);
    RMCore rmCore = new RMCore(new HashMap<String, NodeSource>(), allNodes, Mockito.mock(Client.class), Mockito.mock(RMMonitoringImpl.class), Mockito.mock(SelectionManager.class), freeNodes, Mockito.mock(RMDBManager.class));
    rmCore.signalRMCoreIsInitialized();
    BooleanWrapper lockResult = rmCore.lockNodes(ImmutableSet.of(rmNode.getNodeURL()));
    assertThat(lockResult.getBooleanValue()).isTrue();
    assertThat(rmNode.getState()).isEqualTo(nodeState);
    assertThat(rmNode.isLocked()).isTrue();
    assertThat(freeNodes).isEmpty();
}
Also used : RMDBManager(org.ow2.proactive.resourcemanager.db.RMDBManager) SelectionManager(org.ow2.proactive.resourcemanager.selection.SelectionManager) HashMap(java.util.HashMap) RMMonitoringImpl(org.ow2.proactive.resourcemanager.frontend.RMMonitoringImpl) Matchers.anyString(org.mockito.Matchers.anyString) NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Client(org.ow2.proactive.resourcemanager.authentication.Client)

Example 8 with NodeState

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

the class RMCoreTest method createRmNodeEvent.

private RMNodeEvent createRmNodeEvent(NodeState previousNodeState) {
    RMNodeDescriptor rmNodeDescriptor = new RMNodeDescriptor();
    rmNodeDescriptor.setState(NodeState.DOWN);
    return new RMNodeEvent(rmNodeDescriptor, RMEventType.NODE_STATE_CHANGED, previousNodeState, "initiator");
}
Also used : RMNodeDescriptor(org.ow2.proactive.resourcemanager.common.event.RMNodeDescriptor) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

Example 9 with NodeState

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

the class RMCore method internalSetToRemove.

/**
 * Mark node to be removed after releasing.
 *
 * @param rmNode node to be removed after node is released.
 */
void internalSetToRemove(final RMNode rmNode, Client initiator) {
    // If the node is already marked to be removed, so no need to go further
    if (rmNode.isToRemove()) {
        return;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Prepare to removing the node " + rmNode.getNodeURL());
    }
    // Get the previous state of the node needed for the event
    final NodeState previousNodeState = rmNode.getState();
    rmNode.setToRemove();
    persistUpdatedRMNodeIfRecoveryEnabled(rmNode);
    // create the event
    this.registerAndEmitNodeEvent(rmNode.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousNodeState, initiator.getName()));
}
Also used : NodeState(org.ow2.proactive.resourcemanager.common.NodeState)

Example 10 with NodeState

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

the class RMCore method internalSetFree.

/**
 * Change the state of the node to free, after a Task has been completed by the specified node.
 * The node passed as parameter is moved to the list of nodes which are eligible for scheduling if it is not locked.
 * In all cases, an event informing the node state's change is propagated to RMMonitoring.
 *
 * @param rmNode node to set free.
 * @return true if the node successfully set as free, false if it was down before.
 */
@VisibleForTesting
BooleanWrapper internalSetFree(final RMNode rmNode) {
    if (logger.isDebugEnabled()) {
        logger.debug("Current node state " + rmNode.getState() + " " + rmNode.getNodeURL());
        logger.debug("Setting node state to free " + rmNode.getNodeURL());
    }
    // If the node is already free no need to go further
    if (rmNode.isFree()) {
        return new BooleanWrapper(true);
    }
    // Get the previous state of the node needed for the event
    final NodeState previousNodeState = rmNode.getState();
    Client client = rmNode.getOwner();
    if (client == null) {
        // node has been just configured, so the user initiated this action is the node provider
        client = rmNode.getProvider();
    }
    // resetting owner here
    rmNode.setFree();
    // an eligible node is a node that is free and not locked
    if (!rmNode.isLocked()) {
        this.eligibleNodes.add(rmNode);
    }
    persistUpdatedRMNodeIfRecoveryEnabled(rmNode);
    this.registerAndEmitNodeEvent(rmNode.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousNodeState, client.getName()));
    return new BooleanWrapper(true);
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) NodeState(org.ow2.proactive.resourcemanager.common.NodeState) Client(org.ow2.proactive.resourcemanager.authentication.Client) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

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