use of org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent 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);
NodeSourceStatus status = nodeSourceToRemove.getStatus();
this.nodeSourceUnregister(nodeSourceName, status, new RMNodeSourceEvent(RMEventType.NODESOURCE_SHUTDOWN, this.caller.getName(), nodeSourceName, nodeSourceToRemove.getDescription(), nodeSourceToRemove.getAdditionalInformation(), nodeSourceToRemove.getAdministrator().getName(), status.toString()));
// asynchronously delegate the removal process to the node source
nodeSourceToRemove.shutdown(this.caller);
}
}
use of org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent 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(ns -> {
if (deployedNodeSources.containsKey(ns.getName())) {
return PAFuture.getFutureValue(deployedNodeSources.get(ns.getName()).createNodeSourceEvent());
} else {
return ns.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.common.event.RMNodeSourceEvent 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.getAdditionalInformation(), nodeSourceToRemove.getAdministrator().getName(), nodeSourceToRemove.getStatus().toString()));
}
}
use of org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent in project scheduling by ow2-proactive.
the class RMCore method emitNodeSourceEvent.
private void emitNodeSourceEvent(NodeSource nodeSource, RMEventType eventType) {
NodeSourceDescriptor descriptor = nodeSource.getDescriptor();
this.monitoring.nodeSourceEvent(new RMNodeSourceEvent(eventType, this.caller.getName(), descriptor.getName(), nodeSource.getDescription(), nodeSource.getAdditionalInformation(), descriptor.getProvider().getName(), nodeSource.getStatus().toString()));
}
use of org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent in project scheduling by ow2-proactive.
the class RMCore method undeployNodeSource.
/**
* {@inheritDoc}
*/
public BooleanWrapper undeployNodeSource(String nodeSourceName, boolean preempt) {
logger.info("Undeploy node source " + nodeSourceName + " with preempt=" + preempt + REQUESTED_BY_STRING + this.caller.getName());
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 undeploy " + nodeSourceName, new RMCoreAllPermission(), new NSAdminPermission());
nodeSourceToRemove.setStatus(NodeSourceStatus.NODES_UNDEPLOYED);
this.removeAllNodes(nodeSourceName, preempt);
this.updateNodeSourceDescriptorWithStatusAndPersist(this.definedNodeSources.get(nodeSourceName).getDescriptor(), NodeSourceStatus.NODES_UNDEPLOYED);
this.nodeSourceUnregister(nodeSourceName, NodeSourceStatus.NODES_UNDEPLOYED, new RMNodeSourceEvent(RMEventType.NODESOURCE_SHUTDOWN, this.caller.getName(), nodeSourceName, nodeSourceToRemove.getDescription(), nodeSourceToRemove.getAdditionalInformation(), nodeSourceToRemove.getAdministrator().getName(), NodeSourceStatus.NODES_UNDEPLOYED.toString()));
// asynchronously delegate the removal process to the node source
nodeSourceToRemove.shutdown(this.caller);
}
return new BooleanWrapper(true);
}
Aggregations