Search in sources :

Example 21 with Policy

use of org.ow2.proactive.scheduler.policy.Policy in project scheduling by ow2-proactive.

the class TestLocalInfrastructureRestartDownNodesPolicy method testRestartDownNodesPolicy.

@Test
public void testRestartDownNodesPolicy() throws Exception {
    nodeSourceName = "Node_source_1";
    RMTHelper.log("Test 1 - restart down nodes policy");
    createNodeSourceWithNodes(nodeSourceName, new Object[] { "ALL", "ALL", "10000" });
    RMState stateTest1 = resourceManager.getState();
    assertEquals(defaultDescriptorNodesNb, stateTest1.getTotalNodesNumber());
    assertEquals(defaultDescriptorNodesNb, stateTest1.getFreeNodesNumber());
    NodeSet ns = resourceManager.getNodes(new Criteria(defaultDescriptorNodesNb));
    for (Node n : ns) {
        rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL());
    }
    String nodeUrl = ns.get(0).getNodeInformation().getURL();
    // Nodes will be redeployed only if we kill the whole runtime
    rmHelper.killRuntime(nodeUrl);
    RMNodeEvent ev = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodeUrl);
    assertEquals(NodeState.DOWN, ev.getNodeState());
    // one node is down - the policy should detect it and redeploy
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    assertEquals(defaultDescriptorNodesNb, stateTest1.getTotalNodesNumber());
    assertEquals(defaultDescriptorNodesNb, stateTest1.getTotalAliveNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Node(org.objectweb.proactive.core.node.Node) Criteria(org.ow2.proactive.utils.Criteria) RMState(org.ow2.proactive.resourcemanager.common.RMState) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 22 with Policy

use of org.ow2.proactive.scheduler.policy.Policy 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 23 with Policy

use of org.ow2.proactive.scheduler.policy.Policy 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 24 with Policy

use of org.ow2.proactive.scheduler.policy.Policy 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 25 with Policy

use of org.ow2.proactive.scheduler.policy.Policy 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)

Aggregations

Node (org.objectweb.proactive.core.node.Node)7 Test (org.junit.Test)6 NodeSet (org.ow2.proactive.utils.NodeSet)5 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)4 KeyException (java.security.KeyException)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)4 RMState (org.ow2.proactive.resourcemanager.common.RMState)4 RMException (org.ow2.proactive.resourcemanager.exception.RMException)4 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)4 HttpResponseWrapper (org.ow2.proactive_grid_cloud_portal.cli.utils.HttpResponseWrapper)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)3 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)2 File (java.io.File)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 LoginException (javax.security.auth.login.LoginException)2 UniqueID (org.objectweb.proactive.core.UniqueID)2