use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCore method defineNodeSource.
/**
* {@inheritDoc}
*/
@Override
public BooleanWrapper defineNodeSource(String nodeSourceName, String infrastructureType, Object[] infraParams, String policyType, Object[] policyParams, boolean nodesRecoverable) {
this.validateNodeSourceNameOrFail(nodeSourceName);
nodeSourceName = nodeSourceName.trim();
logger.info("Define node source " + nodeSourceName + REQUESTED_BY_STRING + this.caller.getName());
NodeSourceDescriptor nodeSourceDescriptor = this.persistNodeSourceAndGetDescriptor(nodeSourceName, infrastructureType, infraParams, policyType, policyParams, nodesRecoverable);
NodeSource nodeSource = this.createNodeSourceInstance(nodeSourceDescriptor);
this.definedNodeSources.put(nodeSourceName, nodeSource);
this.monitoring.nodeSourceEvent(new RMNodeSourceEvent(RMEventType.NODESOURCE_DEFINED, this.caller.getName(), nodeSourceName, nodeSource.getDescription(), nodeSourceDescriptor.getProvider().getName(), nodeSource.getStatus().toString()));
logger.info(NODE_SOURCE_STRING + nodeSourceName + " has been successfully defined");
return new BooleanWrapper(true);
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCore method shutDownNodeSourceIfDeployed.
private void shutDownNodeSourceIfDeployed(String nodeSourceName, boolean preempt) {
if (this.deployedNodeSources.containsKey(nodeSourceName)) {
NodeSource nodeSourceToRemove = this.deployedNodeSources.get(nodeSourceName);
this.removeAllNodes(nodeSourceName, preempt);
// delegate the removal process to the node source that will
// eventually do a call back to remove the node source from the
// deployed node sources map
nodeSourceToRemove.shutdown(this.caller);
}
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCore method executeScript.
/**
* {@inheritDoc}
*/
public <T> List<ScriptResult<T>> executeScript(Script<T> script, String targetType, Set<String> targets) {
// Depending on the target type, select nodes for script execution
final TargetType tType = TargetType.valueOf(targetType);
final HashSet<RMNode> selectedRMNodes = new HashSet<>();
switch(tType) {
case NODESOURCE_NAME:
// If target is a nodesource name select all its nodes
for (String target : targets) {
NodeSource nodeSource = this.deployedNodeSources.get(target);
if (nodeSource != null) {
for (RMNode candidateNode : this.allNodes.values()) {
if (candidateNode.getNodeSource().equals(nodeSource)) {
this.selectCandidateNode(selectedRMNodes, candidateNode);
}
}
}
}
break;
case NODE_URL:
// If target is node url select the node
for (String target : targets) {
RMNode candidateNode = this.allNodes.get(target);
if (candidateNode != null) {
this.selectCandidateNode(selectedRMNodes, candidateNode);
}
}
break;
case HOSTNAME:
// If target is hostname select first node from that host
for (String target : targets) {
for (RMNode node : this.allNodes.values()) {
if (node.getHostName().equals(target)) {
this.selectCandidateNode(selectedRMNodes, node);
break;
}
}
}
break;
default:
throw new IllegalArgumentException("Unable to execute script, unknown target type: " + targetType);
}
// Return a ProActive future on the list of results
return this.selectionManager.executeScript(script, selectedRMNodes, null);
// To avoid blocking rmcore ao the call is delegated to the selection
// manager ao and each node is unlocked as soon as the script has
// finished it's execution.
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class NodeSource method detectedPingedDownNode.
/**
* Marks node as down. Remove it from node source node set. It remains in rmcore nodes list until
* user decides to remove them or node source is shutdown.
* @see NodeSource#detectedPingedDownNode(String, String)
*/
public void detectedPingedDownNode(String nodeName, String nodeUrl) {
if (toShutdown) {
logger.warn("[" + name + "] detectedPingedDownNode request discarded because node source is shutting down");
return;
}
logger.warn("[" + name + "] Detected down node: " + nodeUrl);
Node downNode = nodes.remove(nodeUrl);
if (downNode != null) {
downNodes.put(nodeUrl, downNode);
try {
RMCore.topologyManager.removeNode(downNode);
infrastructureManager.internalNotifyDownNode(nodeName, nodeUrl, downNode);
} catch (RMException e) {
logger.error("Error while removing down node: " + nodeUrl, e);
}
} else {
// almost no information about the node apart from its name and url
try {
infrastructureManager.internalNotifyDownNode(nodeName, nodeUrl, null);
} catch (RMException e) {
logger.error("New empty node " + nodeUrl + " could not be created to handle down node", e);
}
}
rmcore.setDownNode(nodeUrl);
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class NodeSource method initActivity.
/**
* Initialization of node source. Creates and activates a pinger to monitor nodes.
*
* @param body active object body
*/
public void initActivity(Body body) {
this.stub = (NodeSource) PAActiveObject.getStubOnThis();
this.infrastructureManager.setNodeSource(this);
// Infrastructure has been configured and linked to the node source, so we can now persist the runtime
// variables of the infrastructure for the first time (they have been initialized during the creation of the
// infrastructure, in its configuration.
this.infrastructureManager.persistInfrastructureVariables();
this.activePolicy.setNodeSource((NodeSource) PAActiveObject.getStubOnThis());
// Set permissions again according to the activated node source policy
// node source admin permission
// it's the PrincipalPermission of the user who created the node source
this.adminPermission = new PrincipalPermission(this.administrator.getName(), this.administrator.getSubject().getPrincipals(UserNamePrincipal.class));
// creating node source provider permission
// could be one of the following: PrincipalPermission (NS creator) or PrincipalPermission (NS creator groups)
// or PrincipalPermission (anyone)
this.providerPermission = new PrincipalPermission(this.administrator.getName(), this.activePolicy.getProviderAccessType().getIdentityPrincipals(this.administrator));
this.nodeUserAccessType = this.activePolicy.getUserAccessType();
Thread.currentThread().setName("Node Source \"" + this.name + "\"");
}
Aggregations