Search in sources :

Example 16 with Connection

use of org.ow2.proactive.authentication.Connection in project scheduling by ow2-proactive.

the class SchedulerFactory method startLocal.

/**
 * Creates and starts a Scheduler on the local host.
 * This call considered that the JVM is correctly configured for starting Scheduler.
 * The "pa.scheduler.home" and required JVM properties MUST be set.
 *
 * @param rmURL the URL of a started Resource Manager
 * @param policy the full class name of the Scheduling policy to use.
 *
 * @return a Scheduler authentication that allow you to administer the Scheduler or get its connection URL.
 *
 * @throws ActiveObjectCreationException If Scheduler cannot be created
 */
public static SchedulerAuthenticationInterface startLocal(URI rmURL, String policy) throws Exception {
    SchedulerInitializer init = new SchedulerInitializer();
    init.setPolicyFullClassName(policy);
    allowNullInit = true;
    SchedulerAuthenticationInterface sai = startLocal(rmURL, init);
    allowNullInit = false;
    return sai;
}
Also used : SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)

Example 17 with Connection

use of org.ow2.proactive.authentication.Connection 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 will provide a connection interface to allow the access to a restricted number of user.<br>
 * Use {@link SchedulerConnection} class to join the Scheduler.
 *
 * @param rmURL the resource manager URL on which the scheduler will connect
 * @param policyFullClassName the full policy class name for the scheduler.
 * @throws AdminSchedulerException If an error occurred during creation process
 */
public static void createScheduler(URI rmURL, String policyFullClassName) throws AdminSchedulerException {
    logger.debug("Starting new Scheduler");
    // check arguments...
    if (rmURL == null) {
        String msg = "The Resource Manager URL must not be null";
        logger.error(msg);
        throw new AdminSchedulerException(msg);
    }
    try {
        // creating the scheduler
        // if this fails then it will not continue.
        logger.debug("Creating scheduler frontend...");
        PAActiveObject.newActive(SchedulerFrontend.class.getName(), new Object[] { rmURL, policyFullClassName });
        // ready
        logger.debug("Scheduler is now ready to be started!");
        ServerJobAndTaskLogs.configure();
    } catch (Exception e) {
        logger.error(e);
        e.printStackTrace();
        throw new AdminSchedulerException(e.getMessage());
    }
}
Also used : AdminSchedulerException(org.ow2.proactive.scheduler.exception.AdminSchedulerException) SchedulerFrontend(org.ow2.proactive.scheduler.core.SchedulerFrontend) LoginException(javax.security.auth.login.LoginException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) AdminSchedulerException(org.ow2.proactive.scheduler.exception.AdminSchedulerException) InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 18 with Connection

use of org.ow2.proactive.authentication.Connection 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 19 with Connection

use of org.ow2.proactive.authentication.Connection in project scheduling by ow2-proactive.

the class SchedulerFactory method startLocal.

/**
 * Creates and starts a Scheduler on the local host using the given initializer to configure it.
 * Only one Scheduler can be started by JVM.
 *
 * @param rmURL the URL of a started Resource Manager
 * @param initializer Use to configure the Scheduler before starting it.
 * 		This parameter cannot be null.
 *
 * @return a Scheduler authentication that allow you to administer it or get its connection URL.
 *
 * @throws InternalSchedulerException If Scheduler cannot be created
 */
public static synchronized SchedulerAuthenticationInterface startLocal(URI rmURL, SchedulerInitializer initializer) throws InternalSchedulerException {
    if (!schedulerStarted) {
        if (!allowNullInit) {
            if (initializer != null) {
                // configure application
                configure(initializer);
            } else {
                throw new IllegalArgumentException("Initializer cannot be null!");
            }
        }
        if (rmURL == null) {
            throw new IllegalArgumentException("RM url is null!");
        }
        try {
            String policy = initializer.getPolicyFullClassName();
            // start scheduler
            createScheduler(rmURL, policy);
            SchedulerAuthenticationInterface sai = SchedulerConnection.waitAndJoin(null);
            schedulerStarted = true;
            return sai;
        } catch (Exception e) {
            throw new InternalSchedulerException(e);
        }
    } else {
        throw new InternalSchedulerException("Scheduler already localy running");
    }
}
Also used : InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) LoginException(javax.security.auth.login.LoginException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) AdminSchedulerException(org.ow2.proactive.scheduler.exception.AdminSchedulerException) InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 20 with Connection

use of org.ow2.proactive.authentication.Connection in project scheduling by ow2-proactive.

the class SchedulerStateRest method getSchedulerPropertiesFromSessionId.

@GET
@Override
@Path("properties")
@Produces("application/json")
public Map<String, Object> getSchedulerPropertiesFromSessionId(@HeaderParam("sessionid") final String sessionId) throws NotConnectedRestException, PermissionRestException {
    SchedulerProxyUserInterface scheduler = checkAccess(sessionId, "properties");
    Map<String, Object> schedulerProperties = new HashMap<String, Object>();
    try {
        schedulerProperties = scheduler.getSchedulerProperties();
    } catch (NotConnectedException e) {
        logger.warn("Attempt to retrieve scheduler properties but failed because connection exception", e);
        throw new PermissionRestException(e);
    } catch (PermissionException e) {
        logger.warn("Attempt to retrieve scheduler properties but failed because permission exception", e);
        throw new NotConnectedRestException(e);
    }
    return schedulerProperties;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) HashMap(java.util.HashMap) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) FileObject(org.apache.commons.vfs2.FileObject) PAActiveObject(org.objectweb.proactive.api.PAActiveObject) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)9 KeyException (java.security.KeyException)6 LoginException (javax.security.auth.login.LoginException)6 Test (org.junit.Test)6 CredData (org.ow2.proactive.authentication.crypto.CredData)5 Credentials (org.ow2.proactive.authentication.crypto.Credentials)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)4 InternalSchedulerException (org.ow2.proactive.scheduler.common.exception.InternalSchedulerException)4 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)4 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)3 PublicKey (java.security.PublicKey)3 JMXConnector (javax.management.remote.JMXConnector)3 JMXServiceURL (javax.management.remote.JMXServiceURL)3 RMException (org.ow2.proactive.resourcemanager.exception.RMException)3 JobId (org.ow2.proactive.scheduler.common.job.JobId)3 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)2 File (java.io.File)2 MBeanServerConnection (javax.management.MBeanServerConnection)2