Search in sources :

Example 1 with RMEvent

use of org.ow2.proactive.resourcemanager.common.event.RMEvent in project scheduling by ow2-proactive.

the class RMGroupEventListener method notify.

public void notify(Collection<RMEvent> events) {
    for (RMEvent event : events) {
        if (event instanceof RMNodeEvent) {
            RMNodeEvent nodeEvent = (RMNodeEvent) event;
            nodeEvent(nodeEvent);
        } else if (event instanceof RMNodeSourceEvent) {
            RMNodeSourceEvent sourceEvent = (RMNodeSourceEvent) event;
            nodeSourceEvent(sourceEvent);
        } else {
            rmEvent(event);
        }
    }
}
Also used : RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) RMEvent(org.ow2.proactive.resourcemanager.common.event.RMEvent) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

Example 2 with RMEvent

use of org.ow2.proactive.resourcemanager.common.event.RMEvent 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");
    }
}
Also used : ProbablisticSelectionManager(org.ow2.proactive.resourcemanager.selection.statistics.ProbablisticSelectionManager) ClientPinger(org.ow2.proactive.resourcemanager.utils.ClientPinger) RMMonitoringImpl(org.ow2.proactive.resourcemanager.frontend.RMMonitoringImpl) NodeException(org.objectweb.proactive.core.node.NodeException) ProActiveException(org.objectweb.proactive.core.ProActiveException) RMAuthenticationImpl(org.ow2.proactive.resourcemanager.authentication.RMAuthenticationImpl) StubObject(org.objectweb.proactive.core.mop.StubObject) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) NodesCleaner(org.ow2.proactive.resourcemanager.cleaning.NodesCleaner) TopologyManager(org.ow2.proactive.resourcemanager.selection.topology.TopologyManager) RMEvent(org.ow2.proactive.resourcemanager.common.event.RMEvent) RMNodeConfigurator(org.ow2.proactive.resourcemanager.nodesource.RMNodeConfigurator)

Example 3 with RMEvent

use of org.ow2.proactive.resourcemanager.common.event.RMEvent in project scheduling by ow2-proactive.

the class RMInitialState method cloneAndFilter.

/**
 * Clones current state events, but keep only those events which has counter bigger than provided 'filter'
 * Event counter can take values [0, +).
 * So if filter is '-1' then all events will returned.
 * @param filter
 * @return rmInitialState where all the events bigger than 'filter'
 */
public RMStateDelta cloneAndFilter(long filter) {
    long actualFilter = computeActualFilter(filter);
    final List<RMEvent> responseEvents = events.getSortedItems().tailSet(// because tailSet returns event which is equal or greater
    new RMEvent(actualFilter + 1)).stream().limit(PAResourceManagerProperties.RM_REST_MONITORING_MAXIMUM_CHUNK_SIZE.getValueAsInt()).collect(Collectors.toList());
    RMStateDelta response = new RMStateDelta();
    response.setNodeSource(getNodeSourceEvents(responseEvents));
    response.setNodesEvents(getNodeEvents(responseEvents));
    response.setLatestCounter(Math.max(actualFilter, findLargestCounter(responseEvents)));
    return response;
}
Also used : RMStateDelta(org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta)

Example 4 with RMEvent

use of org.ow2.proactive.resourcemanager.common.event.RMEvent 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);
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) RMEvent(org.ow2.proactive.resourcemanager.common.event.RMEvent)

Aggregations

RMEvent (org.ow2.proactive.resourcemanager.common.event.RMEvent)3 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)1 ProActiveException (org.objectweb.proactive.core.ProActiveException)1 StubObject (org.objectweb.proactive.core.mop.StubObject)1 NodeException (org.objectweb.proactive.core.node.NodeException)1 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)1 RMAuthenticationImpl (org.ow2.proactive.resourcemanager.authentication.RMAuthenticationImpl)1 NodesCleaner (org.ow2.proactive.resourcemanager.cleaning.NodesCleaner)1 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)1 RMNodeSourceEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)1 RMStateDelta (org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta)1 RMMonitoringImpl (org.ow2.proactive.resourcemanager.frontend.RMMonitoringImpl)1 NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)1 RMNodeConfigurator (org.ow2.proactive.resourcemanager.nodesource.RMNodeConfigurator)1 ProbablisticSelectionManager (org.ow2.proactive.resourcemanager.selection.statistics.ProbablisticSelectionManager)1 TopologyManager (org.ow2.proactive.resourcemanager.selection.topology.TopologyManager)1 ClientPinger (org.ow2.proactive.resourcemanager.utils.ClientPinger)1