Search in sources :

Example 1 with ActiveObjectCreationException

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

the class SchedulerStateRest method login.

@Override
public String login(String username, 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 | SchedulerException | NodeException e) {
        throw new SchedulerRestException(e);
    }
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) LoginException(javax.security.auth.login.LoginException) NodeException(org.objectweb.proactive.core.node.NodeException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) HttpSession(javax.servlet.http.HttpSession) Session(org.ow2.proactive_grid_cloud_portal.common.Session)

Example 2 with ActiveObjectCreationException

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

the class SchedulerStateRest method loginWithCredential.

@Override
public String loginWithCredential(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 (ActiveObjectCreationException | NodeException | SchedulerException e) {
        throw new SchedulerRestException(e);
    }
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) LoginException(javax.security.auth.login.LoginException) NodeException(org.objectweb.proactive.core.node.NodeException) 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)

Example 3 with ActiveObjectCreationException

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

the class RMRest method loginWithCredential.

/*
     * (non-Javadoc)
     *
     * @see org.ow2.proactive_grid_cloud_portal.SchedulerRestInterface#loginWithCredential(org.ow2.
     * proactive_grid_cloud_portal.LoginForm)
     */
@Override
public String loginWithCredential(@MultipartForm LoginForm multipart) throws RMActiveObjectCreationException, RMNodeException, KeyException, IOException, LoginException, RMException {
    Session session;
    try {
        if (multipart.getCredential() != null) {
            session = sessionStore.createUnnamedSession();
            Credentials credentials = Credentials.getCredentials(multipart.getCredential());
            session.connectToRM(credentials);
        } else {
            session = sessionStore.create(multipart.getUsername());
            CredData credData = new CredData(CredData.parseLogin(multipart.getUsername()), CredData.parseDomain(multipart.getUsername()), multipart.getPassword(), multipart.getSshKey());
            session.connectToRM(credData);
        }
    } catch (ActiveObjectCreationException e) {
        throw new RMActiveObjectCreationException(e);
    } catch (NodeException e) {
        throw new RMNodeException(e);
    }
    return session.getSessionId();
}
Also used : RMNodeException(org.ow2.proactive.resourcemanager.exception.RMNodeException) RMActiveObjectCreationException(org.ow2.proactive.resourcemanager.exception.RMActiveObjectCreationException) CredData(org.ow2.proactive.authentication.crypto.CredData) NodeException(org.objectweb.proactive.core.node.NodeException) RMNodeException(org.ow2.proactive.resourcemanager.exception.RMNodeException) Credentials(org.ow2.proactive.authentication.crypto.Credentials) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) RMActiveObjectCreationException(org.ow2.proactive.resourcemanager.exception.RMActiveObjectCreationException)

Example 4 with ActiveObjectCreationException

use of org.objectweb.proactive.ActiveObjectCreationException 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) {
                    PAFuture.waitFor(rmcoreStub.shutdown(true), PAResourceManagerProperties.RM_SHUTDOWN_TIMEOUT.getValueAsInt() * 1000L);
                }
            }
        });
        // Creating RM started event
        this.monitoring.rmEvent(new RMEvent(RMEventType.STARTED));
        authentication.setActivated(true);
        clientPinger.ping();
        nodeSourceParameterHelper = new NodeSourceParameterHelper();
        nodesHouseKeepingService = new NodesHouseKeepingService(rmcoreStub);
        nodesHouseKeepingService.start();
        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) NodesHouseKeepingService(org.ow2.proactive.resourcemanager.housekeeping.NodesHouseKeepingService) RMEvent(org.ow2.proactive.resourcemanager.common.event.RMEvent) RMNodeConfigurator(org.ow2.proactive.resourcemanager.nodesource.RMNodeConfigurator)

Example 5 with ActiveObjectCreationException

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

the class SchedulingMethodImpl method selectAndStartTasks.

private int selectAndStartTasks(Policy currentPolicy, Map<JobId, JobDescriptor> jobMap, Set<String> freeResources, LinkedList<EligibleTaskDescriptor> tasksRetrievedFromPolicy) {
    int numberOfTaskStarted = 0;
    schedulingMainLoopTimingLogger.start("updateVariablesForTasksToSchedule");
    int neededNodes = computeNeededNodes(tasksRetrievedFromPolicy);
    if (logger.isDebugEnabled()) {
        loggingEligibleTasksDetails(tasksRetrievedFromPolicy);
    }
    updateVariablesForTasksToSchedule(tasksRetrievedFromPolicy);
    schedulingMainLoopTimingLogger.end("updateVariablesForTasksToSchedule");
    schedulingMainLoopTimingLogger.start("loadAndInit");
    for (Iterator<EligibleTaskDescriptor> iterator = tasksRetrievedFromPolicy.iterator(); iterator.hasNext(); ) {
        EligibleTaskDescriptorImpl taskDescriptor = (EligibleTaskDescriptorImpl) iterator.next();
        // load and Initialize the executable container
        InternalTask internalTask = taskDescriptor.getInternal();
        try {
            loadAndInit(internalTask);
        } catch (Exception e) {
            handleLoadExecutableContainerError(internalTask, iterator, e);
        }
    }
    schedulingMainLoopTimingLogger.end("loadAndInit");
    while (!tasksRetrievedFromPolicy.isEmpty() && (!PASchedulerProperties.SCHEDULER_POLCY_STRICT_FIFO.getValueAsBoolean() || !freeResources.isEmpty())) {
        // get the next compatible tasks from the whole returned policy tasks
        LinkedList<EligibleTaskDescriptor> tasksToSchedule = new LinkedList<>();
        int neededResourcesNumber = 0;
        schedulingMainLoopTimingLogger.start("getNextcompatibleTasks");
        while (!tasksRetrievedFromPolicy.isEmpty() && neededResourcesNumber == 0) {
            // the loop will search for next compatible task until it find something
            neededResourcesNumber = getNextcompatibleTasks(jobMap, tasksRetrievedFromPolicy, tasksToSchedule);
        }
        schedulingMainLoopTimingLogger.end("getNextcompatibleTasks");
        if (logger.isDebugEnabled()) {
            logger.debug("tasksToSchedule : " + tasksToSchedule);
        }
        logger.debug("required number of nodes : " + neededResourcesNumber);
        if (neededResourcesNumber == 0 || tasksToSchedule.isEmpty()) {
            break;
        }
        schedulingMainLoopTimingLogger.start("getRMNodes");
        NodeSet nodeSet = getRMNodes(jobMap, neededResourcesNumber, tasksToSchedule, freeResources);
        schedulingMainLoopTimingLogger.end("getRMNodes");
        if (PASchedulerProperties.SCHEDULER_POLCY_STRICT_FIFO.getValueAsBoolean() && nodeSet != null) {
            freeResources.removeAll(nodeSet.getAllNodesUrls());
        }
        // start selected tasks
        Node node = null;
        InternalJob currentJob = null;
        try {
            while (nodeSet != null && !nodeSet.isEmpty()) {
                EligibleTaskDescriptor taskDescriptor = tasksToSchedule.removeFirst();
                currentJob = ((JobDescriptorImpl) jobMap.get(taskDescriptor.getJobId())).getInternal();
                InternalTask internalTask = ((EligibleTaskDescriptorImpl) taskDescriptor).getInternal();
                if (currentPolicy.isTaskExecutable(nodeSet, taskDescriptor)) {
                    // create launcher and try to start the task
                    node = nodeSet.get(0);
                    schedulingMainLoopTimingLogger.start("createExecution");
                    if (createExecution(nodeSet, node, currentJob, internalTask, taskDescriptor)) {
                        neededNodes -= taskDescriptor.getNumberOfNodesNeeded();
                        numberOfTaskStarted++;
                    }
                    schedulingMainLoopTimingLogger.end("createExecution");
                }
                // if every task that should be launched have been removed
                if (tasksToSchedule.isEmpty()) {
                    // get back unused nodes to the RManager
                    if (!nodeSet.isEmpty()) {
                        schedulingMainLoopTimingLogger.start("releaseNodes");
                        releaseNodes(currentJob, nodeSet);
                        if (PASchedulerProperties.SCHEDULER_POLCY_STRICT_FIFO.getValueAsBoolean()) {
                            freeResources.addAll(nodeSet.getAllNodesUrls());
                        }
                        schedulingMainLoopTimingLogger.end("releaseNodes");
                    }
                    // and leave the loop
                    break;
                }
            }
        } catch (ActiveObjectCreationException e1) {
            // Something goes wrong with the active object creation (createLauncher)
            logger.warn("An exception occured while creating the task launcher.", e1);
            // so try to get back every remaining nodes to the resource manager
            try {
                releaseNodes(currentJob, nodeSet);
                if (PASchedulerProperties.SCHEDULER_POLCY_STRICT_FIFO.getValueAsBoolean()) {
                    freeResources.addAll(nodeSet.getAllNodesUrls());
                }
            } catch (Exception e2) {
                logger.info("Unable to get back the nodeSet to the RM", e2);
            }
            if (--activeObjectCreationRetryTimeNumber == 0) {
                break;
            }
        } catch (Exception e1) {
            // if we are here, it is that something append while launching the current task.
            logger.warn("An exception occured while starting task.", e1);
            // so try to get back every remaining nodes to the resource manager
            try {
                releaseNodes(currentJob, nodeSet);
                if (PASchedulerProperties.SCHEDULER_POLCY_STRICT_FIFO.getValueAsBoolean()) {
                    freeResources.addAll(nodeSet.getAllNodesUrls());
                }
            } catch (Exception e2) {
                logger.info("Unable to get back the nodeSet to the RM", e2);
            }
        }
    }
    // number of nodes needed to start all pending tasks
    updateNeededNodes(neededNodes);
    return numberOfTaskStarted;
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) Node(org.objectweb.proactive.core.node.Node) EligibleTaskDescriptorImpl(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) TopologyDisabledException(org.ow2.proactive.resourcemanager.frontend.topology.TopologyDisabledException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) RMProxyCreationException(org.ow2.proactive.scheduler.core.rmproxies.RMProxyCreationException) IOException(java.io.IOException) LinkedList(java.util.LinkedList) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException)

Aggregations

ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)9 NodeException (org.objectweb.proactive.core.node.NodeException)6 IOException (java.io.IOException)3 LoginException (javax.security.auth.login.LoginException)3 HttpSession (javax.servlet.http.HttpSession)3 CredData (org.ow2.proactive.authentication.crypto.CredData)3 Credentials (org.ow2.proactive.authentication.crypto.Credentials)2 Session (org.ow2.proactive_grid_cloud_portal.common.Session)2 URISyntaxException (java.net.URISyntaxException)1 KeyException (java.security.KeyException)1 LinkedList (java.util.LinkedList)1 Subject (javax.security.auth.Subject)1 AtmosphereResource (org.atmosphere.cpr.AtmosphereResource)1 WebSocketEventListenerAdapter (org.atmosphere.websocket.WebSocketEventListenerAdapter)1 ProActiveException (org.objectweb.proactive.core.ProActiveException)1 StubObject (org.objectweb.proactive.core.mop.StubObject)1 Node (org.objectweb.proactive.core.node.Node)1 UserNamePrincipal (org.ow2.proactive.authentication.principals.UserNamePrincipal)1 RMAuthenticationImpl (org.ow2.proactive.resourcemanager.authentication.RMAuthenticationImpl)1 NodesCleaner (org.ow2.proactive.resourcemanager.cleaning.NodesCleaner)1