Search in sources :

Example 11 with RMProxy

use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.

the class TestRMProxy method testRMProxies.

private void testRMProxies(boolean singleUserConnection) throws Exception {
    ResourceManager rm = rmHelper.getResourceManager();
    assertEquals(NODES_NUMBER, rm.getState().getFreeNodesNumber());
    URI rmUri = new URI(RMTHelper.getLocalUrl());
    Credentials schedulerProxyCredentials = Credentials.getCredentials(PASchedulerProperties.getAbsolutePath(PASchedulerProperties.RESOURCE_MANAGER_CREDS.getValueAsString()));
    if (singleUserConnection) {
        proxiesManager = new SingleConnectionRMProxiesManager(rmUri, schedulerProxyCredentials);
    } else {
        proxiesManager = new PerUserConnectionRMProxiesManager(rmUri, schedulerProxyCredentials);
    }
    RMProxy user1RMProxy = proxiesManager.getUserRMProxy("admin", user1Credentials);
    assertSame("Proxy manager should return cached proxy instance", user1RMProxy, proxiesManager.getUserRMProxy("admin", user1Credentials));
    RMProxy user2RMProxy = proxiesManager.getUserRMProxy("demo", user2Credentials);
    assertSame("Proxy manager should return cached proxy instance", user2RMProxy, proxiesManager.getUserRMProxy("demo", user2Credentials));
    requestReleaseOneNode(user1RMProxy, rm);
    testSplitNodeSet(user1RMProxy, rm);
    checkSchedulerProxy(proxiesManager);
    requestWithExtraNodes(user1RMProxy, rm);
    requestTooManyNodes(user1RMProxy, rm);
    requestReleaseAllNodes(user1RMProxy, rm);
    checkSchedulerProxy(proxiesManager);
    requestReleaseOneNode(user2RMProxy, rm);
    requestReleaseAllNodes(user2RMProxy, rm);
    requestWithTwoUsers(user1RMProxy, user2RMProxy, rm);
    checkSchedulerProxy(proxiesManager);
    log("Terminate user proxy1");
    proxiesManager.terminateRMProxy("admin");
    user1RMProxy = proxiesManager.getUserRMProxy("admin", user1Credentials);
    requestReleaseAllNodes(user1RMProxy, rm);
    log("Terminate user proxy2");
    proxiesManager.terminateRMProxy("demo");
    user2RMProxy = proxiesManager.getUserRMProxy("demo", user2Credentials);
    requestReleaseAllNodes(user2RMProxy, rm);
}
Also used : RMProxy(org.ow2.proactive.scheduler.core.rmproxies.RMProxy) PerUserConnectionRMProxiesManager(org.ow2.proactive.scheduler.core.rmproxies.PerUserConnectionRMProxiesManager) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) URI(java.net.URI) SingleConnectionRMProxiesManager(org.ow2.proactive.scheduler.core.rmproxies.SingleConnectionRMProxiesManager) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

Example 12 with RMProxy

use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.

the class TestRMProxy method requestWithTwoUsers.

private void requestWithTwoUsers(RMProxy proxy1, RMProxy proxy2, ResourceManager rm) throws Exception {
    log("Request nodes for two users");
    NodeSet nodeSet1 = proxy1.getNodes(new Criteria(1));
    NodeSet nodeSet2 = proxy2.getNodes(new Criteria(2));
    waitWhenNodeSetAcquired(nodeSet1, 1);
    waitWhenNodeSetAcquired(nodeSet2, 2);
    assertEquals(NODES_NUMBER - 3, rm.getState().getFreeNodesNumber());
    proxy1.releaseNodes(nodeSet1);
    proxy2.releaseNodes(nodeSet2);
    waitWhenNodesAreReleased(3);
    assertEquals(NODES_NUMBER, rm.getState().getFreeNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Criteria(org.ow2.proactive.utils.Criteria)

Example 13 with RMProxy

use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.

the class TestRMProxy method requestReleaseOneNode.

private void requestReleaseOneNode(RMProxy proxy, ResourceManager rm) throws Exception {
    log("Request and release single node");
    NodeSet nodeSet = proxy.getNodes(new Criteria(1));
    waitWhenNodeSetAcquired(nodeSet, 1);
    proxy.releaseNodes(nodeSet);
    waitWhenNodesAreReleased(1);
    assertEquals(NODES_NUMBER, rm.getState().getFreeNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Criteria(org.ow2.proactive.utils.Criteria)

Example 14 with RMProxy

use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.

the class TestRMProxyRebind method testRebind.

private void testRebind(URI rmUri1, URI rmUri2, ResourceManager rm1, ResourceManager rm2, RMMonitorsHandler monitorsHandler1, RMMonitorsHandler monitorsHandler2, boolean singleConnection) throws Exception {
    RMProxiesManager proxiesManager;
    if (singleConnection) {
        proxiesManager = new SingleConnectionRMProxiesManager(rmUri1, schedulerProxyCredentials);
    } else {
        proxiesManager = new PerUserConnectionRMProxiesManager(rmUri1, schedulerProxyCredentials);
    }
    Credentials user1Credentials = Credentials.createCredentials(new CredData("admin", "admin"), helper1.getAuth().getPublicKey());
    RMProxy proxy1 = proxiesManager.getUserRMProxy("admin", user1Credentials);
    log("Get one node with RM1");
    NodeSet rm1NodeSet1 = proxy1.getNodes(new Criteria(1));
    waitWhenNodeSetAcquired(rm1NodeSet1, 1, monitorsHandler1);
    checkFreeNodes(rm1, NODES_NUMBER - 1);
    checkFreeNodes(rm2, NODES_NUMBER);
    assertEquals(NODES_NUMBER - 1, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
    log("Get one node with RM1");
    NodeSet rm1NodeSet2 = proxy1.getNodes(new Criteria(1));
    waitWhenNodeSetAcquired(rm1NodeSet2, 1, monitorsHandler1);
    checkFreeNodes(rm1, NODES_NUMBER - 2);
    checkFreeNodes(rm2, NODES_NUMBER);
    assertEquals(NODES_NUMBER - 2, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
    assertTrue(proxiesManager.getRmProxy().isActive().getBooleanValue());
    log("Rebinding to " + rmUri2);
    proxiesManager.rebindRMProxiesManager(rmUri2);
    assertEquals(NODES_NUMBER, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
    assertTrue(proxiesManager.getRmProxy().isActive().getBooleanValue());
    waitWhenNodeSetReleased(2, monitorsHandler1);
    log("Get one node with RM2");
    NodeSet rm2NodeSet1 = proxy1.getNodes(new Criteria(1));
    waitWhenNodeSetAcquired(rm2NodeSet1, 1, monitorsHandler2);
    checkFreeNodes(rm1, NODES_NUMBER);
    checkFreeNodes(rm2, NODES_NUMBER - 1);
    assertEquals(NODES_NUMBER - 1, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
    log("Get two nodes with RM2");
    NodeSet rm2NodeSet2 = proxy1.getNodes(new Criteria(2));
    waitWhenNodeSetAcquired(rm2NodeSet2, 2, monitorsHandler2);
    checkFreeNodes(rm1, NODES_NUMBER);
    checkFreeNodes(rm2, NODES_NUMBER - 3);
    assertEquals(NODES_NUMBER - 3, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
    log("Release one node with RM2");
    proxy1.releaseNodes(rm2NodeSet1);
    waitWhenNodeSetReleased(1, monitorsHandler2);
    checkFreeNodes(rm1, NODES_NUMBER);
    checkFreeNodes(rm2, NODES_NUMBER - 2);
    assertEquals(NODES_NUMBER - 2, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
    log("Kill RM1");
    PAFuture.waitFor(rm1.shutdown(true));
    helper1.kill();
    rm1 = null;
    assertEquals(NODES_NUMBER - 2, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
    assertTrue(proxiesManager.getRmProxy().isActive().getBooleanValue());
    log("Release two nodes with RM2");
    proxy1.releaseNodes(rm2NodeSet2);
    waitWhenNodeSetReleased(2, monitorsHandler2);
    checkFreeNodes(rm2, NODES_NUMBER);
    assertEquals(NODES_NUMBER, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
    assertTrue(proxiesManager.getRmProxy().isActive().getBooleanValue());
    log("Try to release node with terminated RM1");
    proxy1.releaseNodes(rm1NodeSet2);
    log("Try to release node with terminated RM1 one more time");
    proxy1.releaseNodes(rm1NodeSet2);
    assertEquals(NODES_NUMBER, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
    assertTrue(proxiesManager.getRmProxy().isActive().getBooleanValue());
    log("Terminate all proxies");
    proxiesManager.terminateAllProxies();
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) RMProxy(org.ow2.proactive.scheduler.core.rmproxies.RMProxy) PerUserConnectionRMProxiesManager(org.ow2.proactive.scheduler.core.rmproxies.PerUserConnectionRMProxiesManager) CredData(org.ow2.proactive.authentication.crypto.CredData) Criteria(org.ow2.proactive.utils.Criteria) SingleConnectionRMProxiesManager(org.ow2.proactive.scheduler.core.rmproxies.SingleConnectionRMProxiesManager) PerUserConnectionRMProxiesManager(org.ow2.proactive.scheduler.core.rmproxies.PerUserConnectionRMProxiesManager) SingleConnectionRMProxiesManager(org.ow2.proactive.scheduler.core.rmproxies.SingleConnectionRMProxiesManager) RMProxiesManager(org.ow2.proactive.scheduler.core.rmproxies.RMProxiesManager) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

Example 15 with RMProxy

use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.

the class SchedulerFrontend method initActivity.

/**
 * @see org.objectweb.proactive.InitActive#initActivity(org.objectweb.proactive.Body)
 */
@Override
public void initActivity(Body body) {
    try {
        // setting up the policy
        logger.debug("Setting up scheduler security policy");
        ClientsPolicy.init();
        // creating the scheduler authentication interface.
        // if this fails then it will not continue.
        logger.debug("Creating scheduler authentication interface...");
        authentication = PAActiveObject.newActive(SchedulerAuthentication.class, new Object[] { PAActiveObject.getStubOnThis() });
        // creating scheduler core
        DataSpaceServiceStarter dsServiceStarter = DataSpaceServiceStarter.getDataSpaceServiceStarter();
        dsServiceStarter.startNamingService();
        ExecutorService clientThreadPool = Executors.newFixedThreadPool(PASchedulerProperties.SCHEDULER_CLIENT_POOL_NBTHREAD.getValueAsInt(), new NamedThreadFactory("ClientRequestsThreadPool"));
        ExecutorService internalThreadPool = Executors.newFixedThreadPool(PASchedulerProperties.SCHEDULER_INTERNAL_POOL_NBTHREAD.getValueAsInt(), new NamedThreadFactory("InternalOperationsThreadPool"));
        ExecutorService taskPingerThreadPool = Executors.newFixedThreadPool(PASchedulerProperties.SCHEDULER_TASK_PINGER_POOL_NBTHREAD.getValueAsInt(), new NamedThreadFactory("TaskPingerThreadPool"));
        ScheduledExecutorService scheduledThreadPool = new ScheduledThreadPoolExecutor(PASchedulerProperties.SCHEDULER_SCHEDULED_POOL_NBTHREAD.getValueAsInt(), new NamedThreadFactory("SchedulingServiceTimerThread"));
        // at this point we must wait the resource manager
        RMConnection.waitAndJoin(rmURL.toString());
        RMProxiesManager rmProxiesManager = RMProxiesManager.createRMProxiesManager(rmURL);
        RMProxy rmProxy = rmProxiesManager.getRmProxy();
        long loadJobPeriod = -1;
        if (PASchedulerProperties.SCHEDULER_DB_LOAD_JOB_PERIOD.isSet()) {
            String periodStr = PASchedulerProperties.SCHEDULER_DB_LOAD_JOB_PERIOD.getValueAsString();
            if (periodStr != null && !periodStr.isEmpty()) {
                try {
                    loadJobPeriod = Tools.parsePeriod(periodStr);
                } catch (IllegalArgumentException e) {
                    logger.warn("Invalid load job period string: " + periodStr + ", this setting is ignored", e);
                }
            }
        }
        logger.debug("Booting jmx...");
        this.jmxHelper.boot(authentication);
        RecoveredSchedulerState recoveredState = new SchedulerStateRecoverHelper(dbManager).recover(loadJobPeriod, rmProxy);
        this.frontendState = new SchedulerFrontendState(recoveredState.getSchedulerState(), jmxHelper);
        SchedulingInfrastructure infrastructure = new SchedulingInfrastructureImpl(dbManager, rmProxiesManager, dsServiceStarter, clientThreadPool, internalThreadPool, taskPingerThreadPool, scheduledThreadPool);
        this.spacesSupport = infrastructure.getSpacesSupport();
        this.corePublicKey = Credentials.getPublicKey(PASchedulerProperties.getAbsolutePath(PASchedulerProperties.SCHEDULER_AUTH_PUBKEY_PATH.getValueAsString()));
        this.schedulingService = new SchedulingService(infrastructure, frontendState, recoveredState, policyFullName, null);
        recoveredState.enableLiveLogsForRunningTasks(schedulingService);
        releaseBusyNodesWithNoRunningTask(rmProxy, recoveredState);
        logger.debug("Registering scheduler...");
        PAActiveObject.registerByName(authentication, SchedulerConstants.SCHEDULER_DEFAULT_NAME);
        authentication.setActivated(true);
        Tools.logAvailableScriptEngines(logger);
        if (PASchedulerProperties.SCHEDULER_MEM_MONITORING_FREQ.isSet()) {
            logger.debug("Starting the memory monitoring process...");
            metricsMonitorScheduler = new it.sauronsoftware.cron4j.Scheduler();
            String cronExpr = PASchedulerProperties.SCHEDULER_MEM_MONITORING_FREQ.getValueAsString();
            metricsMonitorScheduler.schedule(cronExpr, new TableSizeMonitorRunner(dbManager.getTransactionHelper()));
            metricsMonitorScheduler.schedule(cronExpr, new JobsMemoryMonitorRunner(dbManager.getSessionFactory().getStatistics(), recoveredState.getSchedulerState()));
            metricsMonitorScheduler.start();
        }
    } catch (Exception e) {
        logger.error("Failed to start Scheduler", e);
        e.printStackTrace();
        System.exit(1);
    }
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) NamedThreadFactory(org.objectweb.proactive.utils.NamedThreadFactory) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) SchedulerAuthentication(org.ow2.proactive.scheduler.authentication.SchedulerAuthentication) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) TaskCouldNotRestartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotRestartException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) AlreadyConnectedException(org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskCouldNotStartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotStartException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) DatabaseManagerException(org.ow2.proactive.db.DatabaseManagerException) TaskSkippedException(org.ow2.proactive.scheduler.common.exception.TaskSkippedException) RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) RMProxy(org.ow2.proactive.scheduler.core.rmproxies.RMProxy) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) TableSizeMonitorRunner(org.ow2.proactive.scheduler.core.helpers.TableSizeMonitorRunner) ActiveObject(org.objectweb.proactive.extensions.annotation.ActiveObject) PAActiveObject(org.objectweb.proactive.api.PAActiveObject) JobsMemoryMonitorRunner(org.ow2.proactive.scheduler.core.helpers.JobsMemoryMonitorRunner) RMProxiesManager(org.ow2.proactive.scheduler.core.rmproxies.RMProxiesManager)

Aggregations

NodeSet (org.ow2.proactive.utils.NodeSet)9 Criteria (org.ow2.proactive.utils.Criteria)7 RMProxy (org.ow2.proactive.scheduler.core.rmproxies.RMProxy)4 Credentials (org.ow2.proactive.authentication.crypto.Credentials)3 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)3 ExecutorService (java.util.concurrent.ExecutorService)2 CredData (org.ow2.proactive.authentication.crypto.CredData)2 PerUserConnectionRMProxiesManager (org.ow2.proactive.scheduler.core.rmproxies.PerUserConnectionRMProxiesManager)2 RMProxiesManager (org.ow2.proactive.scheduler.core.rmproxies.RMProxiesManager)2 SingleConnectionRMProxiesManager (org.ow2.proactive.scheduler.core.rmproxies.SingleConnectionRMProxiesManager)2 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)2 RMMonitorEventReceiver (functionaltests.monitor.RMMonitorEventReceiver)1 RMMonitorsHandler (functionaltests.monitor.RMMonitorsHandler)1 URI (java.net.URI)1 KeyException (java.security.KeyException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Vector (java.util.Vector)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1