ernjvr commented on a change in pull request #2739: Async jobs add endtime
URL: https://github.com/apache/cloudstack/pull/2739#discussion_r202326838
##########
File path:
framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
##########
@@ -1025,21 +1027,24 @@ public void
doInTransactionWithoutResult(TransactionStatus status) {
// purge sync queue item running on this ms node
_queueMgr.cleanupActiveQueueItems(msid, true);
// reset job status for all jobs running on this ms node
- List<AsyncJobVO> jobs = _jobDao.getResetJobs(msid);
- for (AsyncJobVO job : jobs) {
+ final List<AsyncJobVO> jobs = _jobDao.getResetJobs(msid);
+ for (final AsyncJobVO job : jobs) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Cancel left-over job-" +
job.getId());
}
job.setStatus(JobInfo.Status.FAILED);
job.setResultCode(ApiErrorCode.INTERNAL_ERROR.getHttpCode());
job.setResult("job cancelled because of management
server restart or shutdown");
job.setCompleteMsid(msid);
+ final Date currentGMTTime = DateUtil.currentGMTTime();
+ job.setLastUpdated(currentGMTTime);
+ job.setRemoved(currentGMTTime);
_jobDao.update(job.getId(), job);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Purge queue item for cancelled
job-" + job.getId());
}
_queueMgr.purgeAsyncJobQueueItemId(job.getId());
- if
(job.getInstanceType().equals(ApiCommandJobType.Volume.toString())) {
+ if (job.getInstanceType() != null &&
job.getInstanceType().equals(ApiCommandJobType.Volume.toString())) {
Review comment:
This is a better way. Thanks.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services