Search in sources :

Example 1 with TaskUsage

use of org.ow2.proactive.scheduler.common.usage.TaskUsage in project scheduling by ow2-proactive.

the class DataUtility method jobUsage.

public static JobUsage jobUsage(JobUsageData d) {
    JobUsage impl = new JobUsage(d.getOwner(), d.getProject(), d.getJobId(), d.getJobName(), d.getJobDuration());
    List<TaskUsageData> taskUsageDataList = d.getTaskUsages();
    for (TaskUsageData taskUsageData : taskUsageDataList) {
        impl.add(taskUsage(taskUsageData));
    }
    return impl;
}
Also used : JobUsage(org.ow2.proactive.scheduler.common.usage.JobUsage)

Example 2 with TaskUsage

use of org.ow2.proactive.scheduler.common.usage.TaskUsage in project scheduling by ow2-proactive.

the class JobData method toJobUsage.

JobUsage toJobUsage() {
    JobIdImpl jobId = new JobIdImpl(getId(), getJobName());
    JobUsage jobUsage = new JobUsage(getOwner(), getProjectName(), jobId.value(), getJobName(), getFinishedTime() - getStartTime());
    for (TaskData taskData : getTasks()) {
        TaskUsage taskUsage = taskData.toTaskUsage(jobId);
        jobUsage.add(taskUsage);
    }
    return jobUsage;
}
Also used : TaskUsage(org.ow2.proactive.scheduler.common.usage.TaskUsage) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobUsage(org.ow2.proactive.scheduler.common.usage.JobUsage)

Example 3 with TaskUsage

use of org.ow2.proactive.scheduler.common.usage.TaskUsage in project scheduling by ow2-proactive.

the class TestUsageData method testNonEmptyDatabase.

@Test
public void testNonEmptyDatabase() throws Exception {
    Date beforeJobExecution = new Date();
    InternalJob job = defaultSubmitJob(createJob("job", "task1", "task2", "task3"), USER_WITH_JOBS);
    // not started and killed job, should not appear in usage data
    InternalJob jobToBeKilled = defaultSubmitJob(createJob("job2", "task1"), USER_WITH_JOBS);
    killJob(jobToBeKilled);
    job.start();
    for (InternalTask task : job.getITasks()) {
        startTask(job, task);
        finishTask(job, task);
    }
    Date afterJobExecution = new Date();
    List<JobUsage> usagesBeforeJobRan = dbManager.getUsage(USER_WITH_JOBS, beforeJobExecution, beforeJobExecution);
    assertTrue(usagesBeforeJobRan.isEmpty());
    List<JobUsage> usagesAfterJobRan = dbManager.getUsage(USER_WITH_JOBS, afterJobExecution, afterJobExecution);
    assertTrue(usagesAfterJobRan.isEmpty());
    List<JobUsage> usagesForDifferentUser = dbManager.getUsage(USER_WITHOUT_JOBS, beforeJobExecution, afterJobExecution);
    assertTrue(usagesForDifferentUser.isEmpty());
    List<JobUsage> usagesWithinJobRun = dbManager.getUsage(USER_WITH_JOBS, beforeJobExecution, afterJobExecution);
    assertEquals(1, usagesWithinJobRun.size());
    assertEquals(3, usagesWithinJobRun.get(0).getTaskUsages().size());
    JobUsage onlyOneUsage = usagesWithinJobRun.get(0);
    assertEquals("job", onlyOneUsage.getJobName());
    assertTrue(onlyOneUsage.getJobDuration() > 0);
    TaskUsage onlyOneTaskUsage = onlyOneUsage.getTaskUsages().get(0);
    assertTrue(onlyOneTaskUsage.getTaskName().contains("task"));
    assertEquals(1, onlyOneTaskUsage.getTaskNodeNumber());
    assertTrue(onlyOneTaskUsage.getTaskExecutionDuration() > 0);
}
Also used : TaskUsage(org.ow2.proactive.scheduler.common.usage.TaskUsage) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) JobUsage(org.ow2.proactive.scheduler.common.usage.JobUsage) Date(java.util.Date) Test(org.junit.Test)

Aggregations

JobUsage (org.ow2.proactive.scheduler.common.usage.JobUsage)3 TaskUsage (org.ow2.proactive.scheduler.common.usage.TaskUsage)2 Date (java.util.Date)1 Test (org.junit.Test)1 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)1 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)1 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)1