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;
}
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;
}
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);
}
Aggregations