synchronized ( this.startedJobsLists ) {
this.startedJobsLists.remove(jobId);
}
// get job handler
final JobHandler handler;
// let's remove the event from our processing list
synchronized ( this.processingJobsLists ) {
handler = this.processingJobsLists.remove(jobId);
}
if ( !this.running ) {
this.logger.warn("Queue is not running anymore. Discarding finish for {}", jobId);
return false;
}
if ( handler == null ) {
if ( this.logger.isDebugEnabled() ) {
this.logger.debug("This job has never been started by this queue: {}", jobId);
}
return false;
}
// handle the reschedule, a new job might be returned with updated reschedule info!
final RescheduleInfo rescheduleInfo = this.handleReschedule(handler, resultState);
if ( resultState == Job.JobState.QUEUED && !rescheduleInfo.reschedule ) {
resultState = Job.JobState.GIVEN_UP;
}
if ( !rescheduleInfo.reschedule ) {
// we keep cancelled jobs and succeeded jobs if the queue is configured like this.
final boolean keepJobs = resultState != Job.JobState.SUCCEEDED || this.configuration.isKeepJobs();
handler.finished(resultState, keepJobs, rescheduleInfo.processingTime);
} else {
this.reschedule(handler);
}
this.notifyFinished(rescheduleInfo.reschedule);