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;
}
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();
}
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");
}
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()));
}
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);
}
Aggregations