use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithIncorrectStatusForLoadedNotFinishedJobs.
public void testRecoverWithIncorrectStatusForLoadedNotFinishedJobs(JobStatus jobStatus) {
InternalJob job = new InternalTaskFlowJob();
job.setStatus(jobStatus);
SchedulerDBManager dbManager = Mockito.mock(SchedulerDBManager.class);
SchedulerStateRecoverHelper stateRecoverHelper = new SchedulerStateRecoverHelper(dbManager);
Mockito.when(dbManager.loadNotFinishedJobs(true)).thenReturn(ImmutableList.of(job));
stateRecoverHelper.recover(-1);
}
use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager in project scheduling by ow2-proactive.
the class JobRemoveHandler method call.
@Override
public Boolean call() {
long start = 0;
if (logger.isInfoEnabled()) {
start = System.currentTimeMillis();
logger.info("Removing job " + jobId);
}
SchedulerDBManager dbManager = service.getInfrastructure().getDBManager();
List<InternalJob> jobs = dbManager.loadJobWithTasksIfNotRemoved(jobId);
TerminationData terminationData;
// if the context is not in sync with the database
if (jobs.size() != 1) {
terminationData = service.getJobs().removeJob(jobId);
} else {
// if the job was already finished we just remove it from the context
if (isInFinishedState(jobs.get(0))) {
terminationData = service.getJobs().removeJob(jobId);
} else {
terminationData = service.getJobs().killJob(jobId);
}
}
service.submitTerminationDataHandler(terminationData);
// if the job doesn't exist in the DB anymore we can stop here
if (jobs.size() != 1) {
return false;
}
jobs.get(0).setRemovedTime(System.currentTimeMillis());
boolean removeFromDb = PASchedulerProperties.JOB_REMOVE_FROM_DB.getValueAsBoolean();
dbManager.removeJob(jobId, jobs.get(0).getRemovedTime(), removeFromDb);
ServerJobAndTaskLogs.remove(jobId);
if (logger.isInfoEnabled()) {
logger.info("Job " + jobId + " removed in " + (System.currentTimeMillis() - start) + "ms");
}
// send event to front-end
service.getListener().jobStateUpdated(jobs.get(0).getOwner(), new NotificationData<JobInfo>(SchedulerEvent.JOB_REMOVE_FINISHED, new JobInfoImpl((JobInfoImpl) jobs.get(0).getJobInfo())));
service.wakeUpSchedulingThread();
return true;
}
Aggregations