use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCore method deployNodeSource.
/**
* {@inheritDoc}
*/
@Override
public BooleanWrapper deployNodeSource(String nodeSourceName) {
if (!this.deployedNodeSources.containsKey(nodeSourceName)) {
NodeSourceDescriptor nodeSourceDescriptor = this.retrieveNodeSourceDescriptorOrFail(nodeSourceName);
logger.info("Deploy node source " + nodeSourceName + REQUESTED_BY_STRING + this.caller.getName());
this.updateNodeSourceDescriptorWithStatusAndPersist(nodeSourceDescriptor, NodeSourceStatus.NODES_DEPLOYED);
NodeSource nodeSourceToDeploy = this.createNodeSourceInstance(nodeSourceDescriptor);
NodeSourcePolicy nodeSourcePolicyStub = this.createNodeSourcePolicyActivity(nodeSourceDescriptor, nodeSourceToDeploy);
NodeSource nodeSourceStub = this.createNodeSourceActivity(nodeSourceName, nodeSourceToDeploy);
this.configureDeployedNodeSource(nodeSourceName, nodeSourceDescriptor, nodeSourceStub, nodeSourcePolicyStub);
this.deployedNodeSources.put(nodeSourceName, nodeSourceStub);
this.monitoring.nodeSourceEvent(new RMNodeSourceEvent(RMEventType.NODESOURCE_CREATED, this.caller.getName(), nodeSourceStub.getName(), nodeSourceStub.getDescription(), nodeSourceStub.getAdministrator().getName(), nodeSourceStub.getStatus().toString()));
logger.info(NODE_SOURCE_STRING + nodeSourceName + " has been successfully deployed");
}
return new BooleanWrapper(true);
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCore method createNodeSourcePolicyActivity.
private NodeSourcePolicy createNodeSourcePolicyActivity(NodeSourceDescriptor nodeSourceDescriptor, NodeSource nodeSourceToDeploy) {
NodeSourcePolicy nodeSourcePolicyStub = NodeSourcePolicyFactory.activate(nodeSourceToDeploy.getPolicy(), nodeSourceDescriptor.getPolicyParameters());
nodeSourceToDeploy.setActivePolicy(nodeSourcePolicyStub);
return nodeSourcePolicyStub;
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class InfrastructureManager method emitEvent.
// **********************************************************************************************//
// *********************** Package private accessors & Helpers
// **********************************//
// **********************************************************************************************//
/**
* To emit an event and register it in the database
*/
private void emitEvent(final RMNodeEvent event) {
NodeSource nsStub = this.nodeSource.getStub();
nsStub.internalEmitDeployingNodeEvent(event);
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource 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
deployingNode = getDeployingOrLostNode(deployingNodeUrl);
}
if (logger.isTraceEnabled()) {
logger.trace("New DeployingNode " + name + " instantiated in IM");
}
RMNodeEvent event = deployingNode.createNodeEvent(RMEventType.NODE_ADDED, null, deployingNode.getProvider().getName());
emitEvent(event);
this.sched(new TimerTask() {
@Override
public void run() {
InfrastructureManager.this.timeout(deployingNodeUrl, timeout);
}
}, timeout);
return deployingNode.getNodeURL();
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class ScriptExecutor method executeScripts.
/**
* Runs selection scripts and process the results
* returns node if it matches, null otherwise
*/
private Node executeScripts() {
boolean selectionScriptSpecified = selectionScriptList != null && selectionScriptList.size() > 0;
boolean nodeMatch = true;
ScriptException exception = null;
if (selectionScriptSpecified) {
// initializing parallel script execution
for (SelectionScript script : selectionScriptList) {
if (manager.isPassed(script, criteria.getBindings(), rmnode)) {
// already executed static script
logger.debug(rmnode.getNodeURL() + " : " + script.hashCode() + " skipping script execution");
continue;
}
logger.info(rmnode.getNodeURL() + " : " + script.hashCode() + " executing");
try {
ScriptResult<Boolean> scriptResult = rmnode.executeScript(script, criteria.getBindings());
// processing the results
if (!MOP.isReifiedObject(scriptResult) && scriptResult.getException() != null) {
// could not create script execution handler
// probably the node id down
logger.warn(rmnode.getNodeURL() + " : " + script.hashCode() + " exception", scriptResult.getException());
logger.warn(rmnode.getNodeURL() + " : pinging the node");
rmnode.getNodeSource().pingNode(rmnode.getNode());
nodeMatch = false;
break;
} else {
try {
PAFuture.waitFor(scriptResult, PAResourceManagerProperties.RM_SELECT_SCRIPT_TIMEOUT.getValueAsLong());
} catch (ProActiveTimeoutException e) {
logger.warn("Timeout on " + rmnode.getNodeURL());
// do not produce an exception here
nodeMatch = false;
break;
}
// display the script result and output in the scheduler logs
if (scriptResult != null && logger.isInfoEnabled()) {
logger.info(rmnode.getNodeURL() + " : " + script.hashCode() + " result " + scriptResult.getResult());
if (scriptResult.getOutput() != null && scriptResult.getOutput().length() > 0) {
logger.info(rmnode.getNodeURL() + " : " + script.hashCode() + " output\n" + scriptResult.getOutput());
}
}
if (scriptResult != null && scriptResult.errorOccured()) {
nodeMatch = false;
exception = new ScriptException(scriptResult.getException());
logger.warn(rmnode.getNodeURL() + " : exception during the script execution", scriptResult.getException());
}
// selection manager at the same time. Returns whether node is selected.
if (!manager.processScriptResult(script, criteria.getBindings(), scriptResult, rmnode)) {
nodeMatch = false;
break;
}
}
} catch (Exception ex) {
// proactive or network exception occurred when script was executed
logger.warn(rmnode.getNodeURL() + " : " + script.hashCode() + " exception", ex);
nodeMatch = false;
exception = new ScriptException(ex);
break;
}
}
}
manager.scriptExecutionFinished(rmnode.getNodeURL());
if (selectionScriptSpecified && logger.isDebugEnabled()) {
if (nodeMatch) {
logger.debug(rmnode.getNodeURL() + " : selected");
} else {
logger.debug(rmnode.getNodeURL() + " : not selected");
}
}
// cleaning the node
try {
rmnode.clean();
} catch (Throwable t) {
logger.warn(rmnode.getNodeURL() + " : exception in cleaning", t);
logger.warn(rmnode.getNodeURL() + " : pinging the node");
try {
// 'pingNode' call can fail with exception if NodeSource was destroyed
rmnode.getNodeSource().pingNode(rmnode.getNode());
} catch (Throwable pingError) {
logger.warn(rmnode.getNodeURL() + " : nodeSource " + rmnode.getNodeSourceName() + " seems to be removed ", pingError);
}
return null;
}
if (exception != null) {
throw exception;
}
if (nodeMatch) {
return rmnode.getNode();
} else {
return null;
}
}
Aggregations