Search in sources :

Example 1 with SigarExposer

use of org.ow2.proactive.resourcemanager.node.jmx.SigarExposer in project scheduling by ow2-proactive.

the class RMNodeStarter method registerInRM.

/**
 * Tries to join to the Resource Manager with a specified timeout
 * at the given URL, logs with provided credentials and adds the local node to
 * the Resource Manager. Handles all errors/exceptions.
 */
protected ResourceManager registerInRM(final Credentials credentials, final String rmURL, String nodeName, Collection<Node> nodes) {
    RMAuthentication rmAuth = joinResourceManager(rmURL);
    ResourceManager rm = loginToResourceManager(credentials, rmAuth);
    startMonitoring(rmAuth);
    for (final Node node : nodes) {
        nodeSetJmxUrl(sigarExposer, node);
        addNodeToResourceManager(rmURL, node, rm);
    }
    return rm;
}
Also used : RMAuthentication(org.ow2.proactive.resourcemanager.authentication.RMAuthentication) Node(org.objectweb.proactive.core.node.Node) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager)

Example 2 with SigarExposer

use of org.ow2.proactive.resourcemanager.node.jmx.SigarExposer in project scheduling by ow2-proactive.

the class RMNodeStarter method startMonitoring.

private void startMonitoring(RMAuthentication auth) {
    if (!disabledMonitoring) {
        if (sigarExposer != null) {
            logger.info("Shutting down previous JMX monitoring.");
            sigarExposer.shutdown();
        }
        // initializing JMX server with Sigar beans
        sigarExposer = new SigarExposer(nodeName);
        final RMAuthentication rmAuth = auth;
        logger.info("Starting JMX monitoring.");
        sigarExposer.boot(auth, false, new PermissionChecker() {

            @Override
            public boolean checkPermission(Credentials cred) {
                ResourceManager rm = null;
                try {
                    rm = rmAuth.login(cred);
                    if (NB_OF_ADD_NODE_ATTEMPTS == 0)
                        return true;
                    boolean isAdmin = rm.isNodeAdmin(nodes.values().iterator().next().getNodeInformation().getURL()).getBooleanValue();
                    if (!isAdmin) {
                        throw new SecurityException("Permission denied");
                    }
                    return true;
                } catch (LoginException e) {
                    throw new SecurityException(e);
                } finally {
                    if (rm != null) {
                        rm.disconnect();
                    }
                }
            }
        });
    } else {
        logger.info("JMX monitoring is disabled.");
    }
}
Also used : SigarExposer(org.ow2.proactive.resourcemanager.node.jmx.SigarExposer) RMAuthentication(org.ow2.proactive.resourcemanager.authentication.RMAuthentication) PermissionChecker(org.ow2.proactive.jmx.PermissionChecker) LoginException(javax.security.auth.login.LoginException) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

Aggregations

RMAuthentication (org.ow2.proactive.resourcemanager.authentication.RMAuthentication)2 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)2 LoginException (javax.security.auth.login.LoginException)1 Node (org.objectweb.proactive.core.node.Node)1 Credentials (org.ow2.proactive.authentication.crypto.Credentials)1 PermissionChecker (org.ow2.proactive.jmx.PermissionChecker)1 SigarExposer (org.ow2.proactive.resourcemanager.node.jmx.SigarExposer)1