Commit 4acab84c authored by Fabien Viale's avatar Fabien Viale
Browse files

Optimize JobData and TaskData queries

 - discontinue support of pa.scheduler.job.removeFromDataBase=false, which implied executing joined tables queries constantly (decreases performance and disallow some indexing)
 - add 3 indexes in JobData (submit_time, scheduled_time_for_removal, and job_id_status : composite index used to optimize scheduler portal default list jobs query)
 - getTaskCounts : avoid joined table query by considering only task statuses.
 - getFinishedTaskCount : fix incomplete list of finished task statuses
 - getPendingTaskCount : add in-error status (similar to pause)
 - adapt db tests
 - add owner column in TaskData to avoid join
 - initialize TaskData.owner using JobData.owner when recovering an existing database
 - TaskData : replace task.jobData.id by task.id.jobId to avoid implicit cross join
 - TaskDBUtils : supress removeTime usage and replace jobData.owner by taskData.owner
 - BaseServiceTest : add SQL debug info
 - MockSchedulingInfrastructure : print unexpected exceptions
parent 20eccc8d
......@@ -122,6 +122,7 @@ pa.scheduler.core.automaticremovejobdelay=0
# This housekeeping feature can be replaced by a stored procedure
# that runs at the desired period of time (e.g. non-business hours)
# Such an example is available in samples/scripts/database/postgres/
# Changing this setting is strongly not recommended as the support for pa.scheduler.job.removeFromDataBase=false has been discontinued
pa.scheduler.job.removeFromDataBase=true
# This cron expression determines the housekeeping call frequency.
......
......@@ -195,6 +195,7 @@ public enum PASchedulerProperties implements PACommonProperties {
SCHEDULER_AUTOMATIC_REMOVED_JOB_CRON_EXPR("pa.scheduler.core.automaticremovejobcronexpression", PropertyType.STRING, "*/10 * * * *"),
/** Remove job in dataBase when removing it from scheduler. */
/** Changing this setting is strongly not recommended as the support for pa.scheduler.job.removeFromDataBase=false has been discontinued */
JOB_REMOVE_FROM_DB("pa.scheduler.job.removeFromDataBase", PropertyType.BOOLEAN, "true"),
/** File encoding used by the scheduler */
......
......@@ -84,17 +84,17 @@ import com.google.common.collect.Lists;
@NamedQuery(name = "countJobDataFinished", query = "select count (*) from JobData where status = 3"),
@NamedQuery(name = "countJobData", query = "select count (*) from JobData"),
@NamedQuery(name = "findUsersWithJobs", query = "select owner, count(owner), max(submittedTime) from JobData group by owner"),
@NamedQuery(name = "getJobsNumberWithStatus", query = "select count(*) from JobData where status in (:status) and removedTime = -1"),
@NamedQuery(name = "getJobsNumberWithStatusUsername", query = "select count(*) from JobData where owner = :username and status in (:status) and removedTime = -1"),
@NamedQuery(name = "getJobsNumberWithStatus", query = "select count(*) from JobData where status in (:status)"),
@NamedQuery(name = "getJobsNumberWithStatusUsername", query = "select count(*) from JobData where owner = :username and status in (:status)"),
@NamedQuery(name = "getJobSubmittedTime", query = "select submittedTime from JobData where id = :id"),
@NamedQuery(name = "getMeanJobExecutionTime", query = "select avg(finishedTime - startTime) from JobData where startTime > 0 and finishedTime > 0"),
@NamedQuery(name = "getMeanJobPendingTime", query = "select avg(startTime - submittedTime) from JobData where startTime > 0 and submittedTime > 0"),
@NamedQuery(name = "getMeanJobSubmittingPeriod", query = "select count(*), min(submittedTime), max(submittedTime) from JobData"),
@NamedQuery(name = "getTotalJobsCount", query = "select count(*) from JobData where removedTime = -1"),
@NamedQuery(name = "getTotalJobsCount", query = "select count(*) from JobData"),
@NamedQuery(name = "loadInternalJobs", query = "from JobData as job where job.id in (:ids)"),
@NamedQuery(name = "loadJobs", query = "select id from JobData where status in (:status) and removedTime = -1"),
@NamedQuery(name = "loadJobsWithPeriod", query = "select id from JobData where status in (:status) and removedTime = -1 and submittedTime >= :minSubmittedTime"),
@NamedQuery(name = "loadJobDataIfNotRemoved", query = "from JobData as job where job.id in (:ids) and job.removedTime = -1"),
@NamedQuery(name = "loadJobs", query = "select id from JobData where status in (:status)"),
@NamedQuery(name = "loadJobsWithPeriod", query = "select id from JobData where status in (:status) and submittedTime >= :minSubmittedTime"),
@NamedQuery(name = "loadJobDataIfNotRemoved", query = "from JobData as job where job.id in (:ids)"),
@NamedQuery(name = "readAccountJobs", query = "select count(*), sum(finishedTime) - sum(startTime) from JobData" +
" where owner = :username and finishedTime > 0"),
@NamedQuery(name = "updateJobAndTasksState", query = "update JobData set status = :status, " +
......@@ -130,8 +130,11 @@ import com.google.common.collect.Lists;
@Index(name = "JOB_DATA_OWNER", columnList = "OWNER"),
@Index(name = "JOB_DATA_REMOVE_TIME", columnList = "REMOVE_TIME"),
@Index(name = "JOB_DATA_START_TIME", columnList = "START_TIME"),
@Index(name = "JOB_DATA_SUBMIT_TIME", columnList = "SUBMIT_TIME"),
@Index(name = "JOB_DATA_REMOVAL_TIME", columnList = "SCHEDULED_TIME_FOR_REMOVAL"),
@Index(name = "JOB_DATA_STATUS", columnList = "STATUS"),
@Index(name = "JOB_PARENT_JOB_ID", columnList = "PARENT_JOB_ID") })
@Index(name = "JOB_PARENT_JOB_ID", columnList = "PARENT_JOB_ID"),
@Index(name = "JOB_ID_STATUS", columnList = "ID,STATUS") })
public class JobData implements Serializable {
private static final Logger logger = Logger.getLogger(JobData.class);
......
......@@ -235,8 +235,6 @@ public class SchedulerDBManager {
criteria.add(Restrictions.in("status", jobStatuses));
}
criteria.add(Restrictions.eq("removedTime", -1L));
if (sortParameters != null) {
Order sortOrder;
for (SortParameter<JobSortParameter> param : sortParameters) {
......@@ -322,16 +320,16 @@ public class SchedulerDBManager {
boolean hasUser = params.getUser() != null && "".compareTo(params.getUser()) != 0;
StringBuilder queryString = new StringBuilder("select count(*) from JobData where removedTime = -1 ");
StringBuilder queryString = new StringBuilder("select count(*) from JobData where ");
queryString.append("status in (:jobStatus) ");
if (hasUser) {
queryString.append("and owner = :user ");
}
queryString.append("and status in (:taskStatus) ");
Query query = session.createQuery(queryString.toString());
query.setParameterList("taskStatus", statuses);
query.setParameterList("jobStatus", statuses);
if (hasUser) {
query.setParameter("user", params.getUser());
}
......@@ -468,8 +466,15 @@ public class SchedulerDBManager {
public long getFinishedTasksCount() {
return executeReadOnlyTransaction(session -> {
Query query = session.getNamedQuery("getFinishedTasksCount")
.setParameterList("taskStatus", Arrays.asList(TaskStatus.FINISHED, TaskStatus.FAULTY));
Query query = session.getNamedQuery("getTasksCountByStatus")
.setParameterList("taskStatus",
Arrays.asList(TaskStatus.FINISHED,
TaskStatus.FAULTY,
TaskStatus.FAILED,
TaskStatus.NOT_RESTARTED,
TaskStatus.NOT_STARTED,
TaskStatus.ABORTED,
TaskStatus.SKIPPED));
return (Long) query.uniqueResult();
});
......@@ -479,12 +484,11 @@ public class SchedulerDBManager {
return executeReadOnlyTransaction(session -> {
Collection<TaskStatus> taskStatus = Arrays.asList(TaskStatus.SUBMITTED,
TaskStatus.PAUSED,
TaskStatus.IN_ERROR,
TaskStatus.PENDING,
TaskStatus.WAITING_ON_ERROR,
TaskStatus.WAITING_ON_FAILURE);
Query query = session.getNamedQuery("getPendingTasksCount")
.setParameterList("jobStatus", NOT_FINISHED_JOB_STATUSES)
.setParameterList("taskStatus", taskStatus);
Query query = session.getNamedQuery("getTasksCountByStatus").setParameterList("taskStatus", taskStatus);
return (Long) query.uniqueResult();
});
......@@ -509,8 +513,7 @@ public class SchedulerDBManager {
public long getRunningTasksCount() {
return executeReadOnlyTransaction(session -> {
Query query = session.getNamedQuery("getRunningTasksCount")
.setParameterList("jobStatus", NOT_FINISHED_JOB_STATUSES)
Query query = session.getNamedQuery("getTasksCountByStatus")
.setParameterList("taskStatus", Collections.singletonList(TaskStatus.RUNNING));
return (Long) query.uniqueResult();
......@@ -752,6 +755,16 @@ public class SchedulerDBManager {
});
}
public void setTaskDataOwnerIfNull() {
executeReadWriteTransaction((SessionWork<Void>) session -> {
Long nbOwnerNull = (Long) session.getNamedQuery("countTaskDataOwnerNull").uniqueResult();
if (nbOwnerNull != null && nbOwnerNull > 0L) {
session.getNamedQuery("setOwnerInTaskDataIfNull").executeUpdate();
}
return null;
});
}
public Map<JobId, String> getJobsToRemove(final long time) {
return executeReadOnlyTransaction(session -> {
Query query = session.createSQLQuery("select ID, OWNER from JOB_DATA where " +
......@@ -1168,7 +1181,7 @@ public class SchedulerDBManager {
.executeUpdate();
final int notReStarted = session.createQuery("update TaskData task set task.taskStatus = org.ow2.proactive.scheduler.common.task.TaskStatus.NOT_RESTARTED " +
" where task.jobData.id = :jobId and task.taskStatus in :taskStatuses ")
" where task.id.jobId = :jobId and task.taskStatus in :taskStatuses ")
.setParameter("jobId", jobId)
.setParameterList("taskStatuses",
Arrays.asList(TaskStatus.WAITING_ON_ERROR,
......@@ -1176,7 +1189,7 @@ public class SchedulerDBManager {
.executeUpdate();
final int notStarted = session.createQuery("update TaskData task set task.taskStatus = org.ow2.proactive.scheduler.common.task.TaskStatus.NOT_STARTED " +
" where task.jobData.id = :jobId and task.taskStatus in :taskStatuses ")
" where task.id.jobId = :jobId and task.taskStatus in :taskStatuses ")
.setParameter("jobId", jobId)
.setParameterList("taskStatuses",
TaskStatus.allExceptThese(TaskStatus.RUNNING,
......@@ -1190,7 +1203,7 @@ public class SchedulerDBManager {
.executeUpdate();
final int runningToAborted = session.createQuery("update TaskData task set task.taskStatus = org.ow2.proactive.scheduler.common.task.TaskStatus.ABORTED, " +
" task.finishedTime = :finishedTime where task.jobData.id = :jobId " +
" task.finishedTime = :finishedTime where task.id.jobId = :jobId " +
" and task.taskStatus = org.ow2.proactive.scheduler.common.task.TaskStatus.RUNNING " +
" and ( task.startTime <= 0 or task.executionDuration >= 0 )")
.setParameter("finishedTime", System.currentTimeMillis())
......@@ -1200,7 +1213,7 @@ public class SchedulerDBManager {
final int runningToAbortedWithDuration = session.createQuery("update TaskData task set task.taskStatus = org.ow2.proactive.scheduler.common.task.TaskStatus.ABORTED, " +
" task.finishedTime = :finishedTime, " +
" task.executionDuration = task.finishedTime - task.startTime " +
" where task.jobData.id = :jobId " +
" where task.id.jobId = :jobId " +
" and task.taskStatus = org.ow2.proactive.scheduler.common.task.TaskStatus.RUNNING " +
" and task.startTime > 0 and task.executionDuration < 0 ")
.setParameter("jobId", jobId)
......@@ -1256,7 +1269,7 @@ public class SchedulerDBManager {
}
final int notReStarted = session.createQuery("update TaskData task set task.taskStatus = org.ow2.proactive.scheduler.common.task.TaskStatus.NOT_RESTARTED " +
" where task.jobData.id in :jobIds and task.taskStatus in :taskStatuses ")
" where task.id.jobId in :jobIds and task.taskStatus in :taskStatuses ")
.setParameterList("jobIds", jobIds)
.setParameterList("taskStatuses",
Arrays.asList(TaskStatus.WAITING_ON_ERROR,
......@@ -1264,7 +1277,7 @@ public class SchedulerDBManager {
.executeUpdate();
final int notStarted = session.createQuery("update TaskData task set task.taskStatus = org.ow2.proactive.scheduler.common.task.TaskStatus.NOT_STARTED " +
" where task.jobData.id in :jobIds and task.taskStatus in :taskStatuses ")
" where task.id.jobId in :jobIds and task.taskStatus in :taskStatuses ")
.setParameterList("jobIds", jobIds)
.setParameterList("taskStatuses",
TaskStatus.allExceptThese(TaskStatus.RUNNING,
......@@ -1278,7 +1291,7 @@ public class SchedulerDBManager {
.executeUpdate();
final int runningToAborted = session.createQuery("update TaskData task set task.taskStatus = org.ow2.proactive.scheduler.common.task.TaskStatus.ABORTED, " +
" task.finishedTime = :finishedTime where task.jobData.id in :jobIds " +
" task.finishedTime = :finishedTime where task.id.jobId in :jobIds " +
" and task.taskStatus = org.ow2.proactive.scheduler.common.task.TaskStatus.RUNNING " +
" and ( task.startTime <= 0 or task.executionDuration >= 0 )")
.setParameter("finishedTime", System.currentTimeMillis())
......@@ -1288,7 +1301,7 @@ public class SchedulerDBManager {
final int runningToAbortedWithDuration = session.createQuery("update TaskData task set task.taskStatus = org.ow2.proactive.scheduler.common.task.TaskStatus.ABORTED, " +
" task.finishedTime = :finishedTime, " +
" task.executionDuration = task.finishedTime - task.startTime " +
" where task.jobData.id in :jobIds " +
" where task.id.jobId in :jobIds " +
" and task.taskStatus = org.ow2.proactive.scheduler.common.task.TaskStatus.RUNNING " +
" and task.startTime > 0 and task.executionDuration < 0 ")
.setParameterList("jobIds", jobIds)
......
......@@ -71,6 +71,7 @@ public class SchedulerStateRecoverHelper {
}
public RecoveredSchedulerState recover(long loadJobPeriod, RMProxy rmProxy) {
dbManager.setTaskDataOwnerIfNull();
List<InternalJob> notFinishedJobs = dbManager.loadNotFinishedJobs(true);
Vector<InternalJob> pendingJobs = new Vector<>();
......
......@@ -125,31 +125,38 @@ public class TaskDBUtils {
boolean hasDateTo, SortSpecifierContainer sortParams) {
StringBuilder result = new StringBuilder();
result.append("T.jobData.removedTime = -1 ");
// Support for removedTime in queries has been discontinued
//result.append("T.jobData.removedTime = -1 ");
boolean oneClause = false;
// if 'from' and 'to' values are set
if (hasDateFrom && hasDateTo) {
result.append("and ( ( startTime >= :dateFrom and startTime <= :dateTo ) " +
result.append("( ( startTime >= :dateFrom and startTime <= :dateTo ) " +
"or ( scheduledTime >= :dateFrom and scheduledTime <= :dateTo ) " +
"or ( finishedTime >= :dateFrom and finishedTime <= :dateTo ) ) ");
oneClause = true;
} else if (hasDateFrom && !hasDateTo) { // if 'from' only is set
result.append("and ( startTime >= :dateFrom or finishedTime >= :dateFrom or scheduledTime >= :dateFrom ) ");
result.append("( startTime >= :dateFrom or finishedTime >= :dateFrom or scheduledTime >= :dateFrom ) ");
oneClause = true;
} else if (!hasDateFrom && hasDateTo) { // if 'to' only is set
result.append("and ( startTime <= :dateTo or finishedTime <= :dateTo or scheduledTime >= :dateTo ) ");
result.append("( startTime <= :dateTo or finishedTime <= :dateTo or scheduledTime >= :dateTo ) ");
oneClause = true;
} else {
// no datetime filtering required
// nothing to do
}
if (hasUser) {
result.append("and T.jobData.owner = :user ");
result.append((oneClause ? "and " : "") + "owner = :user ");
oneClause = true;
}
if (hasTag) {
result.append("and tag = :taskTag ");
result.append((oneClause ? "and " : "") + "tag = :taskTag ");
oneClause = true;
}
result.append("and taskStatus in (:taskStatus) ");
result.append((oneClause ? "and " : "") + "taskStatus in (:taskStatus) ");
if (!sortParams.getSortParameters().isEmpty()) {
result.append("order by ");
......
......@@ -101,21 +101,20 @@ import org.ow2.proactive.topology.descriptor.TopologyDescriptor;
@Entity
@NamedQueries({ @NamedQuery(name = "deleteTaskDataInBulk", query = "delete from TaskData where jobData.id in :jobIdList"),
@NamedQueries({ @NamedQuery(name = "deleteTaskDataInBulk", query = "delete from TaskData where id.jobId in :jobIdList"),
@NamedQuery(name = "countTaskData", query = "select count (*) from TaskData"),
@NamedQuery(name = "countTaskDataOwnerNull", query = "select count (*) from TaskData where owner is null"),
@NamedQuery(name = "setOwnerInTaskDataIfNull", query = "update TaskData task set task.owner = (select job.owner from JobData job where job.id = task.id.jobId)"),
@NamedQuery(name = "countTaskDataNotFinished", query = "select count (*) from TaskData where taskStatus <> org.ow2.proactive.scheduler.common.task.TaskStatus.FINISHED"),
@NamedQuery(name = "getFinishedTasksCount", query = "select count(*) from TaskData task where taskStatus in (:taskStatus) and task.jobData.removedTime = -1"),
@NamedQuery(name = "getMeanTaskPendingTime", query = "select avg(startTime - :jobSubmittedTime) from TaskData task where task.jobData.id = :id and task.startTime > 0"),
@NamedQuery(name = "getMeanTaskRunningTime", query = "select avg(task.finishedTime - task.startTime) from TaskData task where task.startTime > 0 and task.finishedTime > 0 and task.jobData.id = :id"),
@NamedQuery(name = "getTasksCount", query = "select count(*) from TaskData task where taskStatus = :taskStatus and task.jobData.removedTime = -1"),
@NamedQuery(name = "getTasksCountForUsername", query = "select count(*) from TaskData task where task.jobData.owner = :username and taskStatus in (:taskStatus) and task.jobData.removedTime = -1"),
@NamedQuery(name = "getPendingTasksCount", query = "select count(*) from TaskData task where taskStatus in (:taskStatus) and task.jobData.status in (:jobStatus) and task.jobData.removedTime = -1"),
@NamedQuery(name = "getRunningTasksCount", query = "select count(*) from TaskData task where taskStatus in (:taskStatus) " +
"and task.jobData.status in (:jobStatus) and task.jobData.removedTime = -1"),
@NamedQuery(name = "getTasksCountByStatus", query = "select count(*) from TaskData task where taskStatus in (:taskStatus)"),
@NamedQuery(name = "getMeanTaskPendingTime", query = "select avg(startTime - :jobSubmittedTime) from TaskData task where task.id.jobId = :id and task.startTime > 0"),
@NamedQuery(name = "getMeanTaskRunningTime", query = "select avg(task.finishedTime - task.startTime) from TaskData task where task.startTime > 0 and task.finishedTime > 0 and task.id.jobId = :id"),
@NamedQuery(name = "getTasksCount", query = "select count(*) from TaskData task where taskStatus = :taskStatus"),
@NamedQuery(name = "getTasksCountForUsername", query = "select count(*) from TaskData task where task.owner = :username and taskStatus in (:taskStatus)"),
@NamedQuery(name = "findTaskData", query = "from TaskData where id in (:ids)"),
@NamedQuery(name = "findTaskDataById", query = "from TaskData td where td.id = :taskId"),
@NamedQuery(name = "getTotalNumberOfHostsUsed", query = "select count(distinct executionHostName) from TaskData task where task.jobData.id = :id"),
@NamedQuery(name = "getTotalTasksCount", query = "select count(*) from TaskData task where task.jobData.removedTime = -1"),
@NamedQuery(name = "getTotalNumberOfHostsUsed", query = "select count(distinct executionHostName) from TaskData task where task.id.jobId = :id"),
@NamedQuery(name = "getTotalTasksCount", query = "select count(*) from TaskData task"),
@NamedQuery(name = "loadJobsTasks", query = "from TaskData as task " +
"left outer join fetch task.dependentTasks " +
"left outer join fetch task.variables " +
......@@ -124,7 +123,7 @@ import org.ow2.proactive.topology.descriptor.TopologyDescriptor;
"left outer join fetch task.envModifiers " +
"where task.id.jobId in (:ids)"),
@NamedQuery(name = "readAccountTasks", query = "select count(*), sum(task.finishedTime) - sum(task.startTime) from TaskData task " +
"where task.finishedTime > 0 and task.jobData.owner = :username"),
"where task.finishedTime > 0 and task.owner = :username"),
@NamedQuery(name = "updateTaskData", query = "update TaskData task set task.taskStatus = :taskStatus, " +
"task.numberOfExecutionLeft = :numberOfExecutionLeft, " +
"task.numberOfExecutionOnFailureLeft = :numberOfExecutionOnFailureLeft, " +
......@@ -185,7 +184,8 @@ import org.ow2.proactive.topology.descriptor.TopologyDescriptor;
@Index(name = "TASK_DATA_TAG", columnList = "TAG"),
@Index(name = "TASK_DATA_TASK_ID_JOB", columnList = "TASK_ID_JOB"),
@Index(name = "TASK_DATA_TASK_ID_TASK", columnList = "TASK_ID_TASK"),
@Index(name = "TASK_DATA_TASK_NAME", columnList = "TASK_NAME") })
@Index(name = "TASK_DATA_TASK_NAME", columnList = "TASK_NAME"),
@Index(name = "TASK_DATA_OWNER", columnList = "OWNER") })
public class TaskData {
private static final String SCRIPT_TASK = "SCRIPT_TASK";
......@@ -222,6 +222,8 @@ public class TaskData {
private String taskName;
private String owner;
private String tag;
private String description;
......@@ -530,6 +532,7 @@ public class TaskData {
taskId.setTaskId(task.getTaskInfo().getTaskId().longValue());
taskData.setId(taskId);
taskData.setOwner(jobRuntimeData.getOwner());
taskData.setDescription(task.getDescription());
taskData.setTag(task.getTag());
taskData.setParallelEnvironment(task.getParallelEnvironment());
......@@ -901,6 +904,15 @@ public class TaskData {
this.taskName = taskName;
}
@Column(name = "OWNER")
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
@Column(name = "TYPE", nullable = false, updatable = false)
public String getTaskType() {
return taskType;
......
......@@ -56,9 +56,6 @@ public class SchedulerDbManagerConcurrencyTest extends BaseSchedulerDBTest {
ConcurrentJobInsertionScenario.class.getSimpleName() },
{ new ConcurrentJobDeletionScenario(true),
ConcurrentJobDeletionScenario.class.getSimpleName() + "DeleteData" },
{ new ConcurrentJobDeletionScenario(false),
ConcurrentJobDeletionScenario.class.getSimpleName() +
"DoNotDeleteData" },
{ new ConcurrentJobInsertionAndDeletionScenario(),
ConcurrentJobInsertionAndDeletionScenario.class.getSimpleName() } });
}
......@@ -133,7 +130,7 @@ public class SchedulerDbManagerConcurrencyTest extends BaseSchedulerDBTest {
private AtomicInteger expectedNumberOfJobs;
public ConcurrentJobInsertionAndDeletionScenario() {
super(30);
super(20);
expectedNumberOfJobs = new AtomicInteger(nbJobs);
}
......@@ -146,7 +143,7 @@ public class SchedulerDbManagerConcurrencyTest extends BaseSchedulerDBTest {
threadPool.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
int value = iCopy % 3;
int value = iCopy % 2;
switch (value) {
case 0:
......@@ -154,10 +151,6 @@ public class SchedulerDbManagerConcurrencyTest extends BaseSchedulerDBTest {
expectedNumberOfJobs.getAndIncrement();
break;
case 1:
test.deleteJob(jobIds.get(iCopy), false);
expectedNumberOfJobs.getAndDecrement();
break;
case 2:
test.deleteJob(jobIds.get(iCopy), true);
expectedNumberOfJobs.getAndDecrement();
break;
......
......@@ -63,7 +63,7 @@ public class TestJobOperations extends BaseSchedulerDBTest {
Assert.assertEquals(JobStatus.PENDING, job.getJobInfo().getStatus());
Assert.assertEquals(JobPriority.HIGHEST, job.getJobInfo().getPriority());
dbManager.removeJob(job.getId(), System.currentTimeMillis(), false);
dbManager.removeJob(job.getId(), System.currentTimeMillis(), true);
Assert.assertTrue(dbManager.loadJobWithTasksIfNotRemoved(job.getId()).isEmpty());
Assert.assertTrue(dbManager.loadJobWithTasksIfNotRemoved(JobIdImpl.makeJobId("123456789")).isEmpty());
......
......@@ -237,7 +237,7 @@ public class TestLoadJobsPagination extends BaseSchedulerDBTest {
// job marked as removed, method 'getJobs' shouldn't return it
job = defaultSubmitJob(createJob());
dbManager.removeJob(job.getId(), System.currentTimeMillis(), false);
dbManager.removeJob(job.getId(), System.currentTimeMillis(), true);
List<JobInfo> jobs;
......
......@@ -136,7 +136,7 @@ public class TestLoadSchedulerClientState extends BaseSchedulerDBTest {
TaskFlowJob jobDef = new TaskFlowJob();
jobDef.addTask(createDefaultTask("task1"));
InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
dbManager.removeJob(job.getId(), System.currentTimeMillis(), false);
dbManager.removeJob(job.getId(), System.currentTimeMillis(), true);
jobDef = new TaskFlowJob();
jobDef.addTask(createDefaultTask("task1"));
......
......@@ -145,17 +145,17 @@ public class TestReportingQueries extends BaseSchedulerDBTest {
checkMeanTaskRunningTime(job2);
checkJobAndTasksNumbers(0, 0, 2, 2, 0, 0, 6, 6);
// remove job2
dbManager.removeJob(job2.getId(), System.currentTimeMillis(), false);
checkJobAndTasksNumbers(0, 0, 1, 1, 0, 0, 3, 3);
checkMeanPendingTime(job1, job2);
checkMeanExecutionTime(job1, job2);
checkMeanSubmittingPeriod(job1, job2);
// remove job2
dbManager.removeJob(job2.getId(), System.currentTimeMillis(), true);
checkJobAndTasksNumbers(0, 0, 1, 1, 0, 0, 3, 3);
InternalJob job3 = defaultSubmitJobAndLoadInternal(true, jobDef1);
checkMeanSubmittingPeriod(job1, job2, job3);
checkMeanSubmittingPeriod(job1, job3);
}
private void checkNumberOfHosts(InternalJob job, int expected) {
......
......@@ -28,6 +28,8 @@ package functionaltests.service;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
......@@ -43,7 +45,6 @@ import org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl;
import org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl;
import org.ow2.proactive.scheduler.job.InternalJob;
import org.ow2.proactive.scheduler.policy.DefaultPolicy;
import org.ow2.proactive.scheduler.synchronization.Synchronization;
import org.ow2.proactive.scheduler.synchronization.SynchronizationInternal;
import org.ow2.proactive.scheduler.task.TaskLauncher;
import org.ow2.proactive.scheduler.task.internal.ExecuterInformation;
......@@ -67,6 +68,7 @@ public class BaseServiceTest extends ProActiveTest {
@Before
public void init() throws Exception {
Logger.getLogger("org.hibernate.SQL").setLevel(Level.DEBUG);
dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
infrastructure = new MockSchedulingInfrastructure(dbManager);
listener = new MockSchedulingListener();
......
......@@ -193,6 +193,7 @@ public class MockSchedulingInfrastructure implements SchedulingInfrastructure {
try {
future.get();
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Unexpected exception");
}
}
......@@ -204,6 +205,7 @@ public class MockSchedulingInfrastructure implements SchedulingInfrastructure {
try {
future.get();
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Unexpected exception");
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment