use of org.ow2.proactive.resourcemanager.frontend.RMMonitoring 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.frontend.RMMonitoring in project scheduling by ow2-proactive.
the class RMMonitoringImpl method removeRMEventListener.
/**
* Removes a listener from RMMonitoring. Only listener itself must call this method
*/
public void removeRMEventListener() throws RMException {
UniqueID id = PAActiveObject.getContext().getCurrentRequest().getSourceBodyID();
String shortId = id.shortString();
if (removeRMEventListener(id)) {
logger.debug("Removing the RM listener for " + shortId);
} else {
throw new RMException("Unknown listener found: " + shortId);
}
}
use of org.ow2.proactive.resourcemanager.frontend.RMMonitoring in project scheduling by ow2-proactive.
the class RestartDownNodesPolicy method activate.
/**
* Activates static policy. Register a listener in RMMonitoring
*/
@Override
public BooleanWrapper activate() {
acquireAllNodes();
timer.schedule(new TimerTask() {
@Override
public void run() {
int numberOfNodesToDeploy = 0;
for (Node downNode : nodeSource.getDownNodes()) {
String nodeUrl = downNode.getNodeInformation().getURL();
logger.info("Removing down node " + nodeUrl);
BooleanWrapper removed = nodeSource.getRMCore().removeNode(nodeUrl, true);
if (removed.getBooleanValue()) {
logger.info("Down node removed " + nodeUrl);
numberOfNodesToDeploy++;
}
}
for (RMDeployingNode lostNode : nodeSource.getDeployingAndLostNodes()) {
if (!lostNode.isLost()) {
continue;
}
String nodeUrl = lostNode.getNodeURL();
logger.info("Removing lost node " + nodeUrl);
BooleanWrapper removed = nodeSource.getRMCore().removeNode(nodeUrl, true);
if (removed.getBooleanValue()) {
logger.info("Lost node removed " + nodeUrl);
numberOfNodesToDeploy++;
}
}
if (numberOfNodesToDeploy > 0) {
logger.info("Acquiring " + numberOfNodesToDeploy + " nodes");
acquireNodes(numberOfNodesToDeploy);
}
}
}, checkNodeStateEach, checkNodeStateEach);
return new BooleanWrapper(true);
}
use of org.ow2.proactive.resourcemanager.frontend.RMMonitoring in project scheduling by ow2-proactive.
the class RMCore method internalSetFree.
/**
* Change the state of the node to free, after a Task has been completed by the specified node.
* The node passed as parameter is moved to the list of nodes which are eligible for scheduling if it is not locked.
* In all cases, an event informing the node state's change is propagated to RMMonitoring.
*
* @param rmNode node to set free.
* @return true if the node successfully set as free, false if it was down before.
*/
@VisibleForTesting
BooleanWrapper internalSetFree(final RMNode rmNode) {
if (logger.isDebugEnabled()) {
logger.debug("Current node state " + rmNode.getState() + " " + rmNode.getNodeURL());
logger.debug("Setting node state to free " + rmNode.getNodeURL());
}
// If the node is already free no need to go further
if (rmNode.isFree()) {
return new BooleanWrapper(true);
}
// Get the previous state of the node needed for the event
final NodeState previousNodeState = rmNode.getState();
Client client = rmNode.getOwner();
if (client == null) {
// node has been just configured, so the user initiated this action is the node provider
client = rmNode.getProvider();
}
// resetting owner here
rmNode.setFree();
// an eligible node is a node that is free and not locked
if (!rmNode.isLocked()) {
this.eligibleNodes.add(rmNode);
}
persistUpdatedRMNodeIfRecoveryEnabled(rmNode);
this.registerAndEmitNodeEvent(rmNode.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousNodeState, client.getName()));
return new BooleanWrapper(true);
}
use of org.ow2.proactive.resourcemanager.frontend.RMMonitoring in project scheduling by ow2-proactive.
the class RMCore method setBusyNode.
/**
* Set a node state to busy. Set the node to busy, and move the node to the
* internal busy nodes list. An event informing the node state's change is
* thrown to RMMonitoring.
*
* @param owner
* @param nodeUrl node to set
*/
public void setBusyNode(final String nodeUrl, Client owner) throws NotConnectedException {
final RMNode rmNode = this.allNodes.get(nodeUrl);
if (rmNode == null) {
logger.error("Unknown node " + nodeUrl);
return;
}
if (!clients.containsKey(owner.getId())) {
logger.warn(nodeUrl + " cannot set busy as the client disconnected " + owner);
throw new NotConnectedException("Client " + owner + " is not connected to the resource manager");
}
// If the node is already busy no need to go further
if (rmNode.isBusy()) {
return;
}
// Get the previous state of the node needed for the event
final NodeState previousNodeState = rmNode.getState();
rmNode.setBusy(owner);
this.eligibleNodes.remove(rmNode);
persistUpdatedRMNodeIfRecoveryEnabled(rmNode);
// create the event
this.registerAndEmitNodeEvent(rmNode.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousNodeState, owner.getName()));
}
Aggregations