Search in sources :

Example 1 with NodeException

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

the class SchedulerStateRest method login.

/**
 * Login to the scheduler using a form containing 2 fields (username and
 * password).
 *
 * @param username
 *            username
 * @param password
 *            password
 * @return the session id associated to the login.
 * @throws LoginException
 */
@Override
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("login")
@Produces("application/json")
public String login(@FormParam("username") String username, @FormParam("password") String password) throws LoginException, SchedulerRestException {
    try {
        if ((username == null) || (password == null)) {
            throw new LoginException("Empty login/password");
        }
        Session session = sessionStore.create(username);
        session.connectToScheduler(new CredData(username, password));
        logger.info("Binding user " + username + " to session " + session.getSessionId());
        return session.getSessionId();
    } catch (ActiveObjectCreationException e) {
        throw new SchedulerRestException(e);
    } catch (SchedulerException e) {
        throw new SchedulerRestException(e);
    } catch (NodeException e) {
        throw new SchedulerRestException(e);
    }
}
Also used : InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) CredData(org.ow2.proactive.authentication.crypto.CredData) LoginException(javax.security.auth.login.LoginException) NodeException(org.objectweb.proactive.core.node.NodeException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) HttpSession(javax.servlet.http.HttpSession) Session(org.ow2.proactive_grid_cloud_portal.common.Session) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 2 with NodeException

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

the class SchedulerStateRest method loginWithCredential.

/**
 * Login to the scheduler using a multipart form can be used either by
 * submitting 2 fields ({@code username} and {@code password}) or by sending
 * a credential file with field name {@code credential}.
 *
 * @return the session id associated to this new connection.
 * @throws KeyException
 * @throws LoginException
 * @throws SchedulerRestException
 */
@Override
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("login")
@Produces("application/json")
public String loginWithCredential(@MultipartForm LoginForm multipart) throws LoginException, KeyException, SchedulerRestException {
    try {
        Session session;
        if (multipart.getCredential() != null) {
            Credentials credentials;
            try {
                session = sessionStore.createUnnamedSession();
                credentials = Credentials.getCredentials(multipart.getCredential());
                session.connectToScheduler(credentials);
            } catch (IOException e) {
                throw new LoginException(e.getMessage());
            }
        } else {
            if ((multipart.getUsername() == null) || (multipart.getPassword() == null)) {
                throw new LoginException("empty login/password");
            }
            session = sessionStore.create(multipart.getUsername());
            CredData credData = new CredData(CredData.parseLogin(multipart.getUsername()), CredData.parseDomain(multipart.getUsername()), multipart.getPassword(), multipart.getSshKey());
            session.connectToScheduler(credData);
        }
        return session.getSessionId();
    } catch (PermissionException e) {
        throw new SchedulerRestException(e);
    } catch (ActiveObjectCreationException e) {
        throw new SchedulerRestException(e);
    } catch (SchedulerException e) {
        throw new SchedulerRestException(e);
    } catch (NodeException e) {
        throw new SchedulerRestException(e);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) CredData(org.ow2.proactive.authentication.crypto.CredData) LoginException(javax.security.auth.login.LoginException) NodeException(org.objectweb.proactive.core.node.NodeException) IOException(java.io.IOException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) Credentials(org.ow2.proactive.authentication.crypto.Credentials) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) HttpSession(javax.servlet.http.HttpSession) Session(org.ow2.proactive_grid_cloud_portal.common.Session) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 3 with NodeException

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

the class NodesPinger method ping.

/**
 * Pings remote nodes and returns distances to hosts where these nodes are located.
 *
 * @param nodes to ping
 * @return distances map to hosts where these nodes are located
 */
public HashMap<InetAddress, Long> ping(NodeSet nodes) {
    HashMap<InetAddress, Long> results = new HashMap<>();
    for (Node node : nodes) {
        try {
            InetAddress current = NodeFactory.getDefaultNode().getVMInformation().getInetAddress();
            InetAddress nodeAddress = node.getVMInformation().getInetAddress();
            if (current.equals(nodeAddress)) {
                // nodes on the same host
                results.put(nodeAddress, new Long(0));
            } else {
                results.put(nodeAddress, pingNode(node));
            }
        } catch (NodeException e) {
        }
    }
    return results;
}
Also used : HashMap(java.util.HashMap) Node(org.objectweb.proactive.core.node.Node) NodeException(org.objectweb.proactive.core.node.NodeException) InetAddress(java.net.InetAddress)

Example 4 with NodeException

use of org.objectweb.proactive.core.node.NodeException 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 5 with NodeException

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

the class TopologyManager method pingNode.

/**
 * Launches the pinging process from new host. It will ping all other hosts
 * according to the pinger logic.
 */
private HashMap<InetAddress, Long> pingNode(Node node, NodeSet nodes) {
    try {
        logger.debug("Launching ping process on node " + node.getNodeInformation().getURL());
        long timeStamp = System.currentTimeMillis();
        Pinger pinger = PAActiveObject.newActive(pingerClass, null, node);
        HashMap<InetAddress, Long> result = pinger.ping(nodes);
        PAFuture.waitFor(result);
        logger.debug(result.size() + " hosts were pinged from " + node.getNodeInformation().getURL() + " in " + (System.currentTimeMillis() - timeStamp) + " ms");
        if (logger.isDebugEnabled()) {
            logger.debug("Distances are:");
            for (InetAddress host : result.keySet()) {
                logger.debug(result.get(host) + " to " + host);
            }
        }
        try {
            PAActiveObject.terminateActiveObject(pinger, true);
        } catch (RuntimeException e) {
            logger.error("Cannot kill the pinger active object", e);
        }
        return result;
    } catch (ActiveObjectCreationException e) {
        logger.warn(e.getMessage(), e);
    } catch (NodeException e) {
        logger.warn(e.getMessage(), e);
    }
    return null;
}
Also used : Pinger(org.ow2.proactive.resourcemanager.frontend.topology.pinging.Pinger) NodeException(org.objectweb.proactive.core.node.NodeException) InetAddress(java.net.InetAddress) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException)

Aggregations

NodeException (org.objectweb.proactive.core.node.NodeException)13 IOException (java.io.IOException)5 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)5 Node (org.objectweb.proactive.core.node.Node)5 StartNode (org.objectweb.proactive.core.node.StartNode)4 InetAddress (java.net.InetAddress)3 LoginException (javax.security.auth.login.LoginException)3 HttpSession (javax.servlet.http.HttpSession)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 InternalSchedulerException (org.ow2.proactive.scheduler.common.exception.InternalSchedulerException)3 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)3 MalformedURLException (java.net.MalformedURLException)2 AlreadyBoundException (java.rmi.AlreadyBoundException)2 KeyException (java.security.KeyException)2 HashMap (java.util.HashMap)2 ExecutionException (java.util.concurrent.ExecutionException)2 Consumes (javax.ws.rs.Consumes)2 ProActiveTimeoutException (org.objectweb.proactive.core.ProActiveTimeoutException)2