Search in sources :

Example 31 with Criteria

use of org.ow2.proactive.utils.Criteria 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 32 with Criteria

use of org.ow2.proactive.utils.Criteria 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 33 with Criteria

use of org.ow2.proactive.utils.Criteria 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 34 with Criteria

use of org.ow2.proactive.utils.Criteria in project scheduling by ow2-proactive.

the class SchedulerDBManagerTest method assertTaskInfoPage.

private void assertTaskInfoPage(Page<TaskInfo> page, TaskFilterCriteria criterias) {
    List<TaskInfo> taskInfos = page.getList();
    for (TaskInfo taskInfo : taskInfos) {
        String taskStr = taskInfo.getName() + "," + taskInfo.getTaskId().getTag() + "," + String.valueOf(taskInfo.getFinishedTime()) + "," + taskInfo.getStatus();
        System.out.println(taskStr);
        String tag = criterias.getTag();
        // tag
        if (tag != null && "".compareTo(tag) != 0)
            assertEquals("Tag is incorrect for task " + taskStr, tag, taskInfo.getTaskId().getTag());
        // from
        long from = criterias.getFrom();
        if (from != 0)
            assertEquals("startTime is incorrect", from, taskInfo.getStartTime());
        // to
        long to = criterias.getTo();
        if (to != 0)
            assertEquals("finishedTime is incorrect", to, taskInfo.getFinishedTime());
        // pagination
        int pageSize = criterias.getLimit() - criterias.getOffset();
        if (pageSize > 0) {
            assertTrue("Page size is incorrect", pageSize >= taskInfos.size());
        }
        // user
        String user = criterias.getUser();
        if (user != null && "".compareTo(user) != 0) {
            assertEquals("user is incorrect", user, taskInfo.getJobInfo().getJobOwner());
        }
        // the corresponding criteria should be true
        switch(taskInfo.getStatus()) {
            case SUBMITTED:
            case PENDING:
            case NOT_STARTED:
                assertTrue("Task status is incorrect", criterias.isPending());
                break;
            case PAUSED:
            case RUNNING:
            case WAITING_ON_ERROR:
            case WAITING_ON_FAILURE:
                assertTrue("Task status is incorrect", criterias.isRunning());
                break;
            case FAILED:
            case NOT_RESTARTED:
            case ABORTED:
            case FAULTY:
            case FINISHED:
            case SKIPPED:
                assertTrue("Task status is incorrect", criterias.isFinished());
                break;
            default:
                fail("Incoherent task status");
        }
    }
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo)

Example 35 with Criteria

use of org.ow2.proactive.utils.Criteria in project scheduling by ow2-proactive.

the class SchedulerDBManagerTest method testDatesTaskCentric.

@Test
public void testDatesTaskCentric() throws Throwable {
    int nbJobs = 5;
    int nbTasksPerJob = 10;
    int totalNbTasks = nbJobs * nbTasksPerJob;
    // These only should come up
    actualInternalJobs = createTestJobs("Job-hier", "TAG-HIER", nbJobs, nbTasksPerJob);
    for (InternalJob j : actualInternalJobs) {
        service.submitJob(j);
    }
    // These should NOT come up
    List<InternalJob> todayJobs = createTestJobs("Job-today", "TAG-TODAY", nbJobs, nbTasksPerJob);
    for (InternalJob j : todayJobs) {
        service.submitJob(j);
    }
    for (InternalJob j : actualInternalJobs) {
        j.start();
        j.setStartTime(100L);
        for (InternalTask t : j.getITasks()) {
            t.setStartTime(100L);
            dbManager.jobTaskStarted(j, t, true);
        }
    }
    for (int i = 0; i < todayJobs.size(); i++) {
        terminateJob(i, 500L);
    }
    crit = TaskFilterCriteria.TFCBuilder.newInstance().from(100L).criterias();
    actualPageState = getTaskStates(crit);
    for (TaskState ts : actualPageState.getList()) {
        String taskStr = "Results from criteria:" + ts.getName() + "," + ts.getTag() + "," + String.valueOf(ts.getStartTime()) + "," + String.valueOf(ts.getFinishedTime()) + "," + ts.getStatus();
        System.out.println(taskStr);
    }
    assertEquals("Incorrect tasks list size due to coupled dates from/to", totalNbTasks, actualPageState.getList().size());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Aggregations

Criteria (org.ow2.proactive.utils.Criteria)25 NodeSet (org.ow2.proactive.utils.NodeSet)23 Test (org.junit.Test)16 Node (org.objectweb.proactive.core.node.Node)9 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)7 ArrayList (java.util.ArrayList)7 RMCore (org.ow2.proactive.resourcemanager.core.RMCore)6 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)6 CredData (org.ow2.proactive.authentication.crypto.CredData)5 Credentials (org.ow2.proactive.authentication.crypto.Credentials)5 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)5 Client (org.ow2.proactive.resourcemanager.authentication.Client)4 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)4 LinkedList (java.util.LinkedList)3 RMAuthentication (org.ow2.proactive.resourcemanager.authentication.RMAuthentication)3 RMState (org.ow2.proactive.resourcemanager.common.RMState)3 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)3 PublicKey (java.security.PublicKey)2 HashMap (java.util.HashMap)2 List (java.util.List)2