use of org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent in project scheduling by ow2-proactive.
the class RecoverSSHInfrastructureV2Test method startRmAndCheckInitialState.
private void startRmAndCheckInitialState() throws Exception {
// start RM
startRmWithConfig(START_CONFIG);
assertThat(PAResourceManagerProperties.RM_PRESERVE_NODES_ON_SHUTDOWN.getValueAsBoolean()).isTrue();
assertThat(rmHelper.isRMStarted()).isTrue();
// check the initial state of the RM
assertThat(resourceManager.getState().getAllNodes().size()).isEqualTo(0);
resourceManager.createNodeSource(NODE_SOURCE_NAME, SSHInfrastructureV2.class.getName(), TestSSHInfrastructureV2.infraParams, StaticPolicy.class.getName(), TestSSHInfrastructureV2.policyParameters, NODES_RECOVERABLE);
RMTHelper.waitForNodeSourceCreation(NODE_SOURCE_NAME, TestSSHInfrastructureV2.NB_NODES, this.rmHelper.getMonitorsHandler());
RMMonitorEventReceiver resourceManagerMonitor = (RMMonitorEventReceiver) resourceManager;
List<RMNodeSourceEvent> nodeSourceEvent = resourceManagerMonitor.getInitialState().getNodeSourceEvents();
assertThat(nodeSourceEvent.size()).isEqualTo(1);
assertThat(nodeSourceEvent.get(0).getSourceName()).isEqualTo(NODE_SOURCE_NAME);
assertThat(resourceManagerMonitor.getState().getAllNodes().size()).isEqualTo(TestSSHInfrastructureV2.NB_NODES);
}
use of org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent in project scheduling by ow2-proactive.
the class RMFunctionalTest method cleanState.
/**
* Remove all node sources and nodes in the RM
*
* @throws Exception
*/
private void cleanState() throws Exception {
if (rmHelper.isRMStarted()) {
// force reconnection
rmHelper.disconnect();
ResourceManager rm = rmHelper.getResourceManager();
int nodeNumber = rm.getState().getTotalNodesNumber();
RMInitialState state = ((RMMonitorEventReceiver) rmHelper.getResourceManager()).getInitialState();
for (RMNodeSourceEvent sourceEvent : state.getNodeSourceEvents()) {
String nodeSource = sourceEvent.getSourceName();
rm.removeNodeSource(nodeSource, true);
rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, nodeSource);
}
for (int i = 0; i < nodeNumber; i++) {
rmHelper.waitForAnyNodeEvent(RMEventType.NODE_REMOVED);
}
}
}
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(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.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.getAdministrator().getName(), nodeSourceToRemove.getStatus().toString()));
}
}
use of org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent 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);
}
Aggregations