Search in sources :

Example 1 with ProActiveException

use of org.objectweb.proactive.core.ProActiveException 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 2 with ProActiveException

use of org.objectweb.proactive.core.ProActiveException in project scheduling by ow2-proactive.

the class ROConnectorServer method start.

/**
 * Activates the connector server, that is starts listening for client connections.
 * Calling this method when the connector server is already active has no effect.
 * Calling this method when the connector server has been stopped will generate an IOException.
 * The behavior of this method when called for the first time depends on the parameters that were supplied at construction, as described below.
 * First, an object of a subclass of ROServerImpl is required, to export the connector server through Remote Objects:
 * If an ROServerImpl was supplied to the constructor, it is used.
 */
public synchronized void start() throws IOException {
    if (this.state == STARTED) {
        return;
    } else if (this.state == STOPPED) {
        throw new IOException("This connector server has been stopped");
    }
    // Check if the connector server is attached to an MBean server
    final MBeanServer mbs = getMBeanServer();
    if (mbs == null) {
        throw new IllegalStateException("This connector server is not attached with a mbean server");
    }
    // Create an instance the server
    if (this.roServerLocalRef == null) {
        this.roServerLocalRef = new ROServerImpl(mbs, this.env);
    }
    // Extract the URI from the current address
    final URI uri = JMXProviderUtils.extractURI(this.address);
    try {
        // Use the exposer of the created server to expose it as a remote object
        final RemoteObjectExposer<ROServerImpl> roe = this.roServerLocalRef.getRemoteObjectExposer();
        // Bind under the correct uri
        PARemoteObject.bind(roe, uri);
    } catch (ProActiveException e) {
        throw JMXProviderUtils.newIOException("Failed to create the Remote Object JMX Server " + this.address.getURLPath(), e);
    }
    this.state = STARTED;
}
Also used : IOException(java.io.IOException) ProActiveException(org.objectweb.proactive.core.ProActiveException) URI(java.net.URI) MBeanServer(javax.management.MBeanServer)

Example 3 with ProActiveException

use of org.objectweb.proactive.core.ProActiveException in project scheduling by ow2-proactive.

the class ROServerImpl method internalCloseRemoteObject.

private void internalCloseRemoteObject(final RemoteObjectExposer<?> roe) throws ProActiveException {
    // First try to unregisterAll
    ProActiveException unregisterAllException = null;
    try {
        roe.unregisterAll();
    } catch (ProActiveException e) {
        // In case of exception keep it
        unregisterAllException = e;
    }
    // Since the unexportAll method throws an exception it cannot be placed in a finally block
    // so try it even if there was a exception on unregisterAll
    ProActiveException unexportAllException = null;
    try {
        roe.unexportAll();
    } catch (ProActiveException e) {
        // In case of exception keep it
        unexportAllException = e;
    }
    // If there was an exception on unregisterAll report it
    if (unregisterAllException != null) {
        throw unregisterAllException;
    }
    // If there was an exception on unexportAll report it
    if (unexportAllException != null) {
        throw unexportAllException;
    }
}
Also used : ProActiveException(org.objectweb.proactive.core.ProActiveException)

Example 4 with ProActiveException

use of org.objectweb.proactive.core.ProActiveException in project scheduling by ow2-proactive.

the class SchedulerStarter method connectToOrStartResourceManager.

private static String connectToOrStartResourceManager(CommandLine commandLine, String rmUrl) throws ProActiveException, URISyntaxException, ParseException {
    if (rmUrl != null) {
        try {
            LOGGER.info("Connecting to the resource manager on " + rmUrl);
            int rmConnectionTimeout = PASchedulerProperties.RESOURCE_MANAGER_CONNECTION_TIMEOUT.getValueAsInt();
            SchedulerFactory.waitAndJoinRM(new URI(rmUrl), rmConnectionTimeout);
        } catch (Exception e) {
            LOGGER.error("ERROR while connecting to the RM on " + rmUrl + ", no RM found !");
            System.exit(2);
        }
    } else {
        rmUrl = getLocalAdress();
        URI uri = new URI(rmUrl);
        // trying to connect to a started local RM
        try {
            SchedulerFactory.tryJoinRM(uri);
            LOGGER.info("Connected to the existing resource manager at " + uri);
        } catch (Exception e) {
            int defaultNodesNumber = PAResourceManagerProperties.RM_NB_LOCAL_NODES.getValueAsInt();
            // -1 means that the number of local nodes depends of the number of cores in the local machine
            if (defaultNodesNumber == -1) {
                defaultNodesNumber = RMStarter.DEFAULT_NODES_NUMBER;
            }
            int numberLocalNodes = readIntOption(commandLine, OPTION_LOCALNODES, defaultNodesNumber);
            int nodeTimeoutValue = readIntOption(commandLine, OPTION_TIMEOUT, DEFAULT_NODES_TIMEOUT);
            startResourceManager(numberLocalNodes, nodeTimeoutValue);
        }
    }
    return rmUrl;
}
Also used : URI(java.net.URI) LoginException(javax.security.auth.login.LoginException) KeyException(java.security.KeyException) URISyntaxException(java.net.URISyntaxException) InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) ParseException(org.apache.commons.cli.ParseException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) SocketException(java.net.SocketException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ProActiveException(org.objectweb.proactive.core.ProActiveException) AlreadyBoundException(java.rmi.AlreadyBoundException)

Example 5 with ProActiveException

use of org.objectweb.proactive.core.ProActiveException in project scheduling by ow2-proactive.

the class RMNodeStarter method configureLogging.

/*
     * Sets system properties "proactive.home" and "node.name" (used to parameterize the default
     * node.properties configuration file). Re-configures log4j for the new values of the properties
     * to
     * take effect.
     */
private static void configureLogging(String nodeName) {
    String proActiveHome = System.getProperty(CentralPAPropertyRepository.PA_HOME.getName());
    if (proActiveHome == null) {
        try {
            proActiveHome = ProActiveRuntimeImpl.getProActiveRuntime().getProActiveHome();
        } catch (ProActiveException e) {
            logger.debug("Cannot find proactive home using ProActiveRuntime, will use RM home as ProActive home.");
            proActiveHome = PAResourceManagerProperties.RM_HOME.getValueAsString();
        }
        System.setProperty(CentralPAPropertyRepository.PA_HOME.getName(), proActiveHome);
    }
    System.setProperty("node.name", nodeName);
    LogManager.resetConfiguration();
    String log4jConfigPropertyValue = System.getProperty(CentralPAPropertyRepository.LOG4J.getName());
    // (re-)configure log4j so that system properties set above take effect
    if (log4jConfigPropertyValue != null) {
        // log4j.configuration property is set (to a URL), use its value
        URL url;
        try {
            url = new URL(log4jConfigPropertyValue);
        } catch (MalformedURLException e) {
            throw new RuntimeException("Malformed log4j.configuration value: " + log4jConfigPropertyValue, e);
        }
        PropertyConfigurator.configure(url);
        logger.info("Reconfigured log4j using " + log4jConfigPropertyValue);
    } else {
        // log4j.configuration property is not set, use default log4j configuration for node
        String log4jConfig = proActiveHome + File.separator + "config" + File.separator + "log" + File.separator + "node.properties";
        // set log4j.configuration to stop ProActiveLogger#load from reconfiguring log4j once again
        if (new File(log4jConfig).exists()) {
            System.setProperty(CentralPAPropertyRepository.LOG4J.getName(), "file:" + log4jConfig);
            PropertyConfigurator.configure(log4jConfig);
            logger.info("Configured log4j using " + log4jConfig);
        } else {
            // use log4j config from JAR
            URL log4jConfigFromJar = RMNodeStarter.class.getResource("/config/log/node.properties");
            System.setProperty(CentralPAPropertyRepository.LOG4J.getName(), log4jConfigFromJar.toString());
            PropertyConfigurator.configure(log4jConfigFromJar);
            logger.info("Configured log4j using " + log4jConfigFromJar.toString());
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ProActiveRuntimeException(org.objectweb.proactive.core.ProActiveRuntimeException) Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString) ProActiveException(org.objectweb.proactive.core.ProActiveException) File(java.io.File) URL(java.net.URL)

Aggregations

ProActiveException (org.objectweb.proactive.core.ProActiveException)6 IOException (java.io.IOException)3 URI (java.net.URI)2 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)1 File (java.io.File)1 WeakReference (java.lang.ref.WeakReference)1 MalformedURLException (java.net.MalformedURLException)1 SocketException (java.net.SocketException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 AlreadyBoundException (java.rmi.AlreadyBoundException)1 KeyException (java.security.KeyException)1 MBeanServer (javax.management.MBeanServer)1 LoginException (javax.security.auth.login.LoginException)1 ParseException (org.apache.commons.cli.ParseException)1 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)1 ProActiveRuntimeException (org.objectweb.proactive.core.ProActiveRuntimeException)1 StubObject (org.objectweb.proactive.core.mop.StubObject)1 NodeException (org.objectweb.proactive.core.node.NodeException)1