use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCore method getRMInitialState.
/**
* Builds and returns a snapshot of RMCore's current state. Initial state
* must be understood as a new Monitor point of view. A new monitor start to
* receive RMCore events, so must be informed of the current state of the
* Core at the beginning of monitoring. The monitor is built in three parts
* first with all the nodes knows by the RMCore, then with all deploying
* nodes known by the deployed node sources and then with all the defined
* node sources.
*
* @return RMInitialState containing nodes and nodeSources of the RMCore.
*/
public RMInitialState getRMInitialState() {
final Map<String, RMNodeEvent> nodeEvents = this.allNodes.values().stream().map(RMNode::createNodeEvent).collect(Collectors.toMap(RMNodeEvent::getNodeUrl, event -> event));
for (NodeSource source : this.deployedNodeSources.values()) {
for (RMDeployingNode node : source.getDeployingAndLostNodes()) {
final RMNodeEvent nodeEvent = node.createNodeEvent();
nodeEvents.put(nodeEvent.getNodeUrl(), nodeEvent);
}
}
final List<RMNodeSourceEvent> nodeSourceEvents = new ArrayList<>(this.definedNodeSources.values().stream().map(NodeSource::createNodeSourceEvent).collect(Collectors.toList()));
long eventCounter = 0;
for (RMNodeSourceEvent nodeSourceEvent : nodeSourceEvents) {
nodeSourceEvent.setCounter(eventCounter++);
}
for (RMNodeEvent nodeEvent : nodeEvents.values()) {
nodeEvent.setCounter(eventCounter++);
}
final RMInitialState rmInitialState = new RMInitialState();
rmInitialState.addAll(nodeEvents.values());
rmInitialState.addAll(nodeSourceEvents);
return rmInitialState;
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCore method removeDefinedNodeSource.
private void removeDefinedNodeSource(String nodeSourceName, NodeSource nodeSourceToRemove) {
this.definedNodeSources.remove(nodeSourceName);
this.dbManager.removeNodeSource(nodeSourceName);
if (nodeSourceToRemove.getStatus().equals(NodeSourceStatus.NODES_UNDEPLOYED)) {
logger.info(NODE_SOURCE_STRING + nodeSourceName + " has been successfully removed");
// if the node source to remove is not deployed, we need to issue
// the node source removed event right now, because we will not
// receive it from the node source shutdown call back
this.monitoring.nodeSourceEvent(new RMNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, this.caller.getName(), nodeSourceToRemove.getName(), nodeSourceToRemove.getDescription(), nodeSourceToRemove.getAdministrator().getName(), nodeSourceToRemove.getStatus().toString()));
}
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCore method undeployNodeSource.
/**
* {@inheritDoc}
*/
public BooleanWrapper undeployNodeSource(String nodeSourceName, boolean preempt) {
if (!this.definedNodeSources.containsKey(nodeSourceName)) {
throw new IllegalArgumentException("Unknown node source " + nodeSourceName);
}
if (this.deployedNodeSources.containsKey(nodeSourceName)) {
NodeSource nodeSourceToRemove = this.deployedNodeSources.get(nodeSourceName);
this.caller.checkPermission(nodeSourceToRemove.getAdminPermission(), this.caller + " is not authorized to remove " + nodeSourceName);
logger.info("Undeploy node source " + nodeSourceName + " with preempt=" + preempt + REQUESTED_BY_STRING + this.caller.getName());
nodeSourceToRemove.setStatus(NodeSourceStatus.NODES_UNDEPLOYED);
this.removeAllNodes(nodeSourceName, preempt);
// delegate the removal process to the node source that will
// eventually call back the RMCore to unregister the deployed node
// source
nodeSourceToRemove.shutdown(this.caller);
this.updateNodeSourceDescriptorWithStatusAndPersist(this.definedNodeSources.get(nodeSourceName).getDescriptor(), NodeSourceStatus.NODES_UNDEPLOYED);
logger.info(NODE_SOURCE_STRING + nodeSourceName + " has been successfully undeployed");
}
return new BooleanWrapper(true);
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCore method shutdown.
/**
* Shutdown the resource manager
*/
public BooleanWrapper shutdown(boolean preempt) {
// this method could be called twice from shutdown hook and user action
if (toShutDown)
return new BooleanWrapper(false);
logger.info("RMCore shutdown request");
this.monitoring.rmEvent(new RMEvent(RMEventType.SHUTTING_DOWN));
this.toShutDown = true;
if (PAResourceManagerProperties.RM_PRESERVE_NODES_ON_SHUTDOWN.getValueAsBoolean() || this.deployedNodeSources.size() == 0) {
finalizeShutdown();
} else {
for (Entry<String, NodeSource> entry : this.deployedNodeSources.entrySet()) {
removeAllNodes(entry.getKey(), preempt, true);
entry.getValue().shutdown(caller);
}
}
return new BooleanWrapper(true);
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCore method createNodeSourceInstance.
private NodeSource createNodeSourceInstance(NodeSourceDescriptor nodeSourceDescriptor) {
InfrastructureManager infrastructureManager = InfrastructureManagerFactory.create(nodeSourceDescriptor);
NodeSourcePolicy notActivePolicy = NodeSourcePolicyFactory.create(nodeSourceDescriptor.getPolicyType());
return new NodeSource(this.getUrl(), nodeSourceDescriptor.getName(), infrastructureManager, notActivePolicy, (RMCore) PAActiveObject.getStubOnThis(), this.monitoring, nodeSourceDescriptor);
}
Aggregations