Search in sources :

Example 1 with RMProxiesManager

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

the class TerminationData method terminateRunningTask.

private void terminateRunningTask(SchedulingService service, TaskTerminationData taskToTerminate, RunningTaskData taskData) {
    Map<String, String> genericInformation = new HashMap<>();
    VariablesMap variables = null;
    if (taskToTerminate.internalJob != null) {
        genericInformation = taskData.getTask().getRuntimeGenericInformation();
    }
    try {
        variables = getStringSerializableMap(service, taskToTerminate);
    } catch (Exception e) {
        logger.error("Exception occurred, fail to get variables into the cleaning script: ", e);
    }
    try {
        if (taskToTerminate.terminationStatus == ABORTED) {
            taskData.getLauncher().kill();
        }
    } catch (Throwable t) {
        logger.info("Cannot terminate task launcher for task '" + taskData.getTask().getId() + "'", t);
        try {
            logger.info("Task launcher that cannot be terminated is identified by " + taskData.getLauncher().toString());
        } catch (Throwable ignore) {
            logger.info("Getting information about Task launcher failed (remote object not accessible?)");
        }
    }
    try {
        logger.debug("Releasing nodes for task '" + taskData.getTask().getId() + "'");
        RMProxiesManager proxiesManager = service.getInfrastructure().getRMProxiesManager();
        proxiesManager.getUserRMProxy(taskData.getUser(), taskData.getCredentials()).releaseNodes(taskData.getNodes(), taskToTerminate.terminationStatus != NODEFAILED ? taskData.getTask().getCleaningScript() : null, variables, genericInformation, taskToTerminate.taskData.getTask().getId(), service.addThirdPartyCredentials(taskData.getCredentials()));
    } catch (Throwable t) {
        logger.info("Failed to release nodes for task '" + taskData.getTask().getId() + "'", t);
    }
}
Also used : HashMap(java.util.HashMap) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) IOException(java.io.IOException) RMProxiesManager(org.ow2.proactive.scheduler.core.rmproxies.RMProxiesManager)

Example 2 with RMProxiesManager

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

the class RMProxiesManager method createRMProxiesManager.

/**
 * Create a RMProxiesManager using RM's URI (example : "rmi://localhost:1099/" ).
 *
 * @param rmURI The URI of a started Resource Manager
 * @return an instance of RMProxiesManager joined to the Resource Manager at the given URI
 */
public static RMProxiesManager createRMProxiesManager(final URI rmURI) throws RMException, RMProxyCreationException, URISyntaxException {
    Credentials schedulerProxyCredentials;
    try {
        schedulerProxyCredentials = Credentials.getCredentials(PASchedulerProperties.getAbsolutePath(PASchedulerProperties.RESOURCE_MANAGER_CREDS.getValueAsString()));
    } catch (Exception e) {
        throw new RMProxyCreationException(e);
    }
    boolean singleConnection = PASchedulerProperties.RESOURCE_MANAGER_SINGLE_CONNECTION.getValueAsBoolean();
    if (singleConnection) {
        return new SingleConnectionRMProxiesManager(rmURI, schedulerProxyCredentials);
    } else {
        return new PerUserConnectionRMProxiesManager(rmURI, schedulerProxyCredentials);
    }
}
Also used : Credentials(org.ow2.proactive.authentication.crypto.Credentials) URISyntaxException(java.net.URISyntaxException) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 3 with RMProxiesManager

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

the class TestRMProxy method checkSchedulerProxy.

private void checkSchedulerProxy(RMProxiesManager proxiesManager) {
    log("Check scheduler proxy");
    RMProxy proxy = proxiesManager.getRmProxy();
    assertEquals(proxy.getState().getFreeNodesNumber(), NODES_NUMBER);
    assertTrue(proxy.isActive().getBooleanValue());
}
Also used : RMProxy(org.ow2.proactive.scheduler.core.rmproxies.RMProxy)

Example 4 with RMProxiesManager

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

the class JobRemoveHandlerTest method init.

@Before
public void init() throws Exception {
    jobId = new JobIdImpl(id, jobName);
    MockitoAnnotations.initMocks(this);
    Mockito.when(infrastructure.getDBManager()).thenReturn(dbManager);
    Mockito.when(infrastructure.getRMProxiesManager()).thenReturn(rmProxiesManager);
    Mockito.when(rmProxiesManager.getRmUrl()).thenReturn(null);
    Mockito.when(dbManager.loadJobWithTasksIfNotRemoved(jobId)).thenReturn(Collections.singletonList(job));
    Mockito.when(job.getJobInfo()).thenReturn(jobInfo);
    service = new SchedulingService(infrastructure, listener, null, policyClassName, schedulingMethod);
    jobRemoveHandler = new JobRemoveHandler(service, jobId);
}
Also used : JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Before(org.junit.Before)

Example 5 with RMProxiesManager

use of org.ow2.proactive.scheduler.core.rmproxies.RMProxiesManager 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)

Aggregations

RMProxiesManager (org.ow2.proactive.scheduler.core.rmproxies.RMProxiesManager)3 RMProxy (org.ow2.proactive.scheduler.core.rmproxies.RMProxy)3 Credentials (org.ow2.proactive.authentication.crypto.Credentials)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 KeyException (java.security.KeyException)1 HashMap (java.util.HashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 Before (org.junit.Before)1 PAActiveObject (org.objectweb.proactive.api.PAActiveObject)1 ActiveObject (org.objectweb.proactive.extensions.annotation.ActiveObject)1 NamedThreadFactory (org.objectweb.proactive.utils.NamedThreadFactory)1 CredData (org.ow2.proactive.authentication.crypto.CredData)1 DatabaseManagerException (org.ow2.proactive.db.DatabaseManagerException)1 RMException (org.ow2.proactive.resourcemanager.exception.RMException)1 SchedulerAuthentication (org.ow2.proactive.scheduler.authentication.SchedulerAuthentication)1 AlreadyConnectedException (org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException)1 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)1