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