use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode in project scheduling by ow2-proactive.
the class RMDeployingNodeTest method createDeployingNode.
private RMDeployingNode createDeployingNode(String name) {
Client client = Mockito.mock(Client.class);
NodeSource nodeSource = Mockito.mock(NodeSource.class);
return new RMDeployingNode(name, nodeSource, "command", client);
}
use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode in project scheduling by ow2-proactive.
the class InfrastructureManager method removeLostNodeWithLockAndPersist.
private RMDeployingNode removeLostNodeWithLockAndPersist(final String nodeUrl) {
return setPersistedInfraVariable(() -> {
RMDeployingNode removedLostNode = this.lostNodesMap.remove(nodeUrl);
getPersistedLostNodesUrl().remove(nodeUrl);
return removedLostNode;
});
}
use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode in project scheduling by ow2-proactive.
the class InfrastructureManager method update.
/**
* Updates a deploying node.
* <p>
* The update is performed on deploying nodes first.
* If no node if found, lost nodes are considered.
*
* @param rmNode the new deploying node instance to use.
* @return the previous value or {@code null}.
*/
public RMDeployingNode update(RMDeployingNode rmNode) {
String nodeUrl = rmNode.getNodeURL();
RMDeployingNode previousDeployingNode;
if (rmNode.isLost() && containsLostNodeWithLock(nodeUrl)) {
previousDeployingNode = addLostNodeWithLockAndPersist(nodeUrl, rmNode);
} else if (containsDeployingNodeWithLock(nodeUrl)) {
previousDeployingNode = addDeployingNodeWithLockAndPersist(nodeUrl, rmNode);
} else {
previousDeployingNode = null;
}
return previousDeployingNode;
}
use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode in project scheduling by ow2-proactive.
the class InfrastructureManager method addDeployingNode.
/**
* Creates a new RMDeployingNode's, stores it in a local ArrayList and
* notify the owning NodeSource of the RMDeployingNode creation
*
* @param name
* The RMDeployingNode's name.
* @param description
* The RMDeployingNode's description
* @param timeout
* after which one the deploying node will be declared lost. (
* node acquisition after this timeout is discarded )
* @return The newly created RMDeployingNode's URL.
* @throws UnsupportedOperationException
* if the infrastructure manager is shuting down
*/
protected final String addDeployingNode(String name, String command, String description, final long timeout) {
checkName(name);
checkTimeout(timeout);
if (shutDown.get()) {
throw new UnsupportedOperationException("The infrastructure manager is shuting down.");
}
// if the user calls this method, we use the require nodes/timeout
// mecanism
setUsingDeployingNodesWithLockAndPersist();
NodeSource nsStub = this.nodeSource.getStub();
RMDeployingNode deployingNode = RMDeployingNodeAccessor.getDefault().newRMDeployingNode(name, nsStub, command, nsStub.getAdministrator(), description);
final String deployingNodeUrl = deployingNode.getNodeURL();
addDeployingNodeWithLockAndPersist(deployingNodeUrl, deployingNode);
if (RM_NODES_LOCK_RESTORATION.getValueAsBoolean()) {
logger.debug("Checking lock status for node " + deployingNodeUrl);
nodeSource.setDeploying(deployingNode);
// The value for 'deployingNode' is retrieved before calling 'nodeSource.setDeploying'
// However, 'nodeSource.setDeploying' may lock the node that is currently handled
// (e.g. node lock restoration on RM startup) and thus update 'deployingNodes'.
// In such a case, the 'deployingNodes' collection is updated with a new deploying node instance which has the
// same URL as 'deployingNode' but different state information (e.g. lock status).
// This is due to deep copies made by ProActive Programming with method invocation on Active Objects.
// As a consequence, the 'deployingNode' variable must be updated with the last value available
// in the 'deployingNodes' collection
RMDeployingNode statefulDeployingNode = getDeployingOrLostNode(deployingNodeUrl);
if (statefulDeployingNode != null) {
deployingNode = statefulDeployingNode;
}
}
if (logger.isTraceEnabled()) {
logger.trace("New DeployingNode " + name + " instantiated in IM");
}
RMNodeEvent event = deployingNode.createNodeEvent(RMEventType.NODE_ADDED, null, deployingNode.getProvider().getName());
emitNodeEvent(event);
this.sched(new TimerTask() {
@Override
public void run() {
InfrastructureManager.this.timeout(deployingNodeUrl, timeout);
}
}, timeout);
return deployingNode.getNodeURL();
}
use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode 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());
emitNodeEvent(event);
logger.trace("Deploying node " + toUpdateURL + " updated in IM");
return true;
} else {
logger.trace("Deploying node " + toUpdateURL + " no more managed by the IM, cannot update it");
return false;
}
}
Aggregations