Search in sources :

Example 6 with SchedulerException

use of org.ow2.proactive.scheduler.common.exception.SchedulerException in project scheduling by ow2-proactive.

the class SmartProxyImpl method init.

private void init(String url, Credentials credentials, CredData credData) throws SchedulerException, LoginException {
    if (this.connectionInfo == null) {
        this.connectionInfo = new ConnectionInfo(url, null, null, null, false);
    }
    this.connectionInfo.setUrl(url);
    this.credentials = credentials;
    this.credData = credData;
    SchedulerAuthenticationInterface auth = SchedulerConnection.join(url);
    PublicKey pubKey = auth.getPublicKey();
    if (this.credentials != null) {
        this.credentials = credentials;
        this.credData = null;
    } else if (this.credData != null) {
        this.credData = credData;
        try {
            this.credentials = Credentials.createCredentials(credData, pubKey);
        } catch (KeyException e) {
            throw new InternalSchedulerException(e);
        }
    } else {
        throw new IllegalStateException("No valid credential available to connect to the scheduler");
    }
    this.schedulerProxy = auth.login(this.credentials);
    jobTracker.loadJobs();
    setInitialized(true);
    registerAsListener();
    syncAwaitedJobs();
}
Also used : InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) PublicKey(java.security.PublicKey) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) ConnectionInfo(org.ow2.proactive.authentication.ConnectionInfo) KeyException(java.security.KeyException)

Example 7 with SchedulerException

use of org.ow2.proactive.scheduler.common.exception.SchedulerException in project scheduling by ow2-proactive.

the class JobResultSchedulerListener method jobRunningToFinishedEvent.

private void jobRunningToFinishedEvent(NotificationData<JobInfo> jobNotification) {
    JobId jobId = jobNotification.getData().getJobId();
    logger.trace("Trying to get the job result for job " + jobId);
    try {
        logger.info("The result for job with ID " + jobId + " is " + this.daddy.getJobResult(jobId));
    } catch (SchedulerException e) {
        logger.error("Cannot get the job result for job with id " + jobId + " from the scheduler", e);
    }
}
Also used : SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 8 with SchedulerException

use of org.ow2.proactive.scheduler.common.exception.SchedulerException in project scheduling by ow2-proactive.

the class SchedulerAuthenticationGUIHelper method login.

/**
 * This method will log a client to the scheduler by requesting his URL, username and password from a
 * graphical interface.
 *
 * @param schedulerURL The default URL of the scheduler to connect
 * @return The connection to the scheduler as a {@link Scheduler} if logging successful.
 * 			If the username is empty or if the user cancel the authentication, this method will return null.
 * @throws LoginException If a problem occurs while logging the user.
 * @throws SchedulerException If a problem occurs at scheduler level.
 */
public static Scheduler login(String schedulerURL) throws LoginException, SchedulerException {
    AuthResultContainer auth = connect(schedulerURL);
    if (auth == null) {
        return null;
    } else {
        SchedulerAuthenticationInterface schedAuth = auth.getAuth();
        Credentials cred = null;
        try {
            cred = Credentials.createCredentials(new CredData(CredData.parseLogin(auth.getUsername()), CredData.parseDomain(auth.getUsername()), auth.getPassword()), schedAuth.getPublicKey());
        } catch (LoginException e) {
            throw new LoginException("Could not retrieve public key from Scheduler " + schedulerURL + ", contact the administrator" + e);
        } catch (KeyException e) {
            throw new LoginException("Could not encrypt credentials " + e);
        }
        return schedAuth.login(cred);
    }
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) LoginException(javax.security.auth.login.LoginException) Credentials(org.ow2.proactive.authentication.crypto.Credentials) KeyException(java.security.KeyException)

Example 9 with SchedulerException

use of org.ow2.proactive.scheduler.common.exception.SchedulerException in project scheduling by ow2-proactive.

the class SchedulerFactory method createScheduler.

/**
 * Create a new scheduler on the local host plugged on the given resource manager.<br>
 * This constructor also requires the credentials of the client to connect.<br><br>
 * It will return a client scheduler able to managed the scheduler.<br><br>
 * <font color="red">WARNING :</font> this method provides a way to connect to the scheduler after its creation,
 * BUT if the scheduler is restarting after failure, this method will create the scheduler
 * but will throw a SchedulerException due to the failure of client connection.<br>
 * In fact, while the scheduler is restarting after a crash, no one can connect it during the whole restore process.<br><br>
 * In any other case, the method will block until connection is allowed or error occurred.
 *
 * @param rmURL the resource manager URL on which the scheduler will connect
 * @param policyFullClassName the full policy class name for the scheduler.
 * @return a scheduler interface to manage the scheduler.
 * @throws SchedulerException if the scheduler cannot be created.
 * @throws AdminSchedulerException if a client connection exception occurs.
 * @throws LoginException if a user login/password exception occurs.
 */
public static Scheduler createScheduler(Credentials creds, URI rmURL, String policyFullClassName) throws AdminSchedulerException, SchedulerException, LoginException {
    createScheduler(rmURL, policyFullClassName);
    SchedulerAuthenticationInterface auth = SchedulerConnection.waitAndJoin(null);
    return auth.login(creds);
}
Also used : SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)

Example 10 with SchedulerException

use of org.ow2.proactive.scheduler.common.exception.SchedulerException in project scheduling by ow2-proactive.

the class SharedSessionStoreTestUtils method createValidSession.

public static String createValidSession(SchedulerProxyUserInterface scheduler) throws LoginException, ActiveObjectCreationException, SchedulerException, NodeException {
    SchedulerRMProxyFactory schedulerFactory = mock(SchedulerRMProxyFactory.class);
    when(schedulerFactory.connectToScheduler(Matchers.<CredData>any())).thenReturn(scheduler);
    SharedSessionStore.getInstance().setSchedulerRMProxyFactory(schedulerFactory);
    // login
    Session session = SharedSessionStore.getInstance().createUnnamedSession();
    session.connectToScheduler(new CredData());
    return session.getSessionId();
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData)

Aggregations

CredData (org.ow2.proactive.authentication.crypto.CredData)7 SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)5 KeyException (java.security.KeyException)4 LoginException (javax.security.auth.login.LoginException)4 Credentials (org.ow2.proactive.authentication.crypto.Credentials)4 InternalSchedulerException (org.ow2.proactive.scheduler.common.exception.InternalSchedulerException)4 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)4 SchedulerProxyUserInterface (org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface)3 PublicKey (java.security.PublicKey)2 HttpSession (javax.servlet.http.HttpSession)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)2 NodeException (org.objectweb.proactive.core.node.NodeException)2 SchedulerState (org.ow2.proactive.scheduler.common.SchedulerState)2 JobId (org.ow2.proactive.scheduler.common.job.JobId)2 MBeanInfoViewer (org.ow2.proactive.utils.console.MBeanInfoViewer)2 Session (org.ow2.proactive_grid_cloud_portal.common.Session)2