use of org.ow2.proactive.resourcemanager.nodesource.RMNodeConfigurator in project scheduling by ow2-proactive.
the class RMCore method initActivity.
/**
* Initialization part of the RMCore active object.
* Create RM's active objects and the default static Node Source named
* {@link RMConstants#DEFAULT_STATIC_SOURCE_NAME}. Finally, it throws the RM
* started event.
*
* @param body the active object's body.
*/
public void initActivity(Body body) {
if (logger.isDebugEnabled()) {
logger.debug("RMCore start : initActivity");
}
try {
// setting up the policy
logger.debug("Setting up the resource manager security policy");
ClientsPolicy.init();
StubObject rmCoreStub = PAActiveObject.getStubOnThis();
PAActiveObject.registerByName(rmCoreStub, RMConstants.NAME_ACTIVE_OBJECT_RMCORE);
dbManager = RMDBManager.getInstance();
if (logger.isDebugEnabled()) {
logger.debug("Creating RMAuthentication active object");
}
authentication = (RMAuthenticationImpl) PAActiveObject.newActive(RMAuthenticationImpl.class.getName(), new Object[] { rmCoreStub }, nodeRM);
if (logger.isDebugEnabled()) {
logger.debug("Creating RMMonitoring active object");
}
// Boot the JMX infrastructure
this.jmxHelper.boot(authentication);
monitoring = (RMMonitoringImpl) PAActiveObject.newActive(RMMonitoringImpl.class.getName(), new Object[] { rmCoreStub }, nodeRM);
if (logger.isDebugEnabled()) {
logger.debug("Creating SelectionManager active object");
}
selectionManager = (SelectionManager) PAActiveObject.newActive(ProbablisticSelectionManager.class.getName(), new Object[] { rmCoreStub }, nodeRM);
if (logger.isDebugEnabled()) {
logger.debug("Creating ClientPinger active object");
}
clientPinger = (ClientPinger) PAActiveObject.newActive(ClientPinger.class.getName(), new Object[] { rmCoreStub }, nodeRM);
if (logger.isDebugEnabled()) {
logger.debug("Creating NodeCleaner active object");
}
nodesCleaner = (NodesCleaner) PAActiveObject.newActive(NodesCleaner.class.getName(), new Object[] { rmCoreStub }, nodeRM);
topologyManager = new TopologyManager();
nodeConfigurator = (RMNodeConfigurator) PAActiveObject.newActive(RMNodeConfigurator.class.getName(), new Object[] { rmCoreStub }, nodeRM);
// adding shutdown hook
final RMCore rmcoreStub = (RMCore) rmCoreStub;
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
if (!toShutDown) {
rmcoreStub.shutdown(true);
}
synchronized (nodeRM) {
if (!shutedDown) {
try {
// wait for rmcore shutdown (5 min at most)
nodeRM.wait(5 * 60 * 60 * 1000);
} catch (InterruptedException e) {
logger.warn("shutdown hook interrupted", e);
}
}
}
}
});
// Creating RM started event
this.monitoring.rmEvent(new RMEvent(RMEventType.STARTED));
authentication.setActivated(true);
clientPinger.ping();
initiateRecoveryIfRequired();
} catch (ActiveObjectCreationException e) {
logger.error("", e);
} catch (NodeException e) {
logger.error("", e);
} catch (ProActiveException e) {
logger.error("", e);
} catch (ClassNotFoundException e) {
logger.error("", e);
} finally {
signalRMCoreIsInitialized();
}
if (logger.isDebugEnabled()) {
logger.debug("RMCore end: initActivity");
}
}
use of org.ow2.proactive.resourcemanager.nodesource.RMNodeConfigurator in project scheduling by ow2-proactive.
the class RMCore method internalAddNodeToCore.
/**
* Internal operation of registering a new node in the Core
* This step is done after node configuration ran by {@link RMNodeConfigurator} active object.
*
* @param configuredNode the node that is going to be added.
*/
public void internalAddNodeToCore(RMNode configuredNode) {
String nodeURL = configuredNode.getNodeURL();
if (!this.allNodes.containsKey(nodeURL)) {
// does nothing, the node has been removed preemptively
// during its configuration
logger.debug("internalAddNodeToCore returned immediately because the node " + nodeURL + " was not known");
return;
}
// was added during internalRegisterConfiguringNode
RMNode rmnode = this.allNodes.get(nodeURL);
registerAvailableNode(configuredNode);
if (toShutDown) {
logger.warn("Node " + rmnode.getNodeURL() + " will not be added to the core as the resource manager is shutting down");
removeNodeFromCoreAndSource(rmnode, rmnode.getProvider());
return;
}
// noinspection ConstantConditions
if (isNumberOfNodesLimited() && isMaximumNumberOfNodesReachedIncludingAskingNode()) {
logger.warn("Node " + rmnode.getNodeURL() + " is removed because the Resource Manager is limited to " + maximumNumberOfNodes + " nodes." + CONTACT_UPGRADE_MESSAGE);
removeNodeFromCoreAndSource(rmnode, rmnode.getProvider());
throw new AddingNodesException("Maximum number of nodes reached: " + maximumNumberOfNodes + ". " + CONTACT_UPGRADE_MESSAGE);
}
// during the configuration process, the rmnode can be removed. Its state would be toRemove
if (rmnode.isToRemove()) {
removeNodeFromCoreAndSource(rmnode, rmnode.getProvider());
return;
}
// discarding the registration
if (rmnode.isDown()) {
logger.debug("internalAddNodeToCore returned immediately because the node " + nodeURL + " is already down");
return;
}
internalSetFree(configuredNode);
}
Aggregations