karuturi commented on a change in pull request #1832: CLOUDSTACK-9652 Job
framework - Cancelling async jobs
URL: https://github.com/apache/cloudstack/pull/1832#discussion_r116164374
##########
File path:
framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
##########
@@ -762,12 +768,34 @@ protected void runInContext() {
protected void reallyRun() {
try {
List<SyncQueueItemVO> l =
_queueMgr.dequeueFromAny(getMsid(), MAX_ONETIME_SCHEDULE_SIZE);
+ boolean isPurged = false;
if (l != null && l.size() > 0) {
for (SyncQueueItemVO item : l) {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Execute sync-queue item: " +
item.toString());
+ if
(item.getContentType().equalsIgnoreCase(SyncQueueItem.AsyncJobContentType)) {
+ AsyncJob job =
_jobDao.findById(item.getContentId());
+ if (job != null &&
StringUtils.isNotBlank(job.getRelated())) {
+ AsyncJob parentJob =
_jobDao.findById(Long.valueOf(job.getRelated()));
+ //If the parent job is done, do not
execute the child. complete it and purge it
+ // from queue
+ if (parentJob != null &&
parentJob.getStatus().done() && !isPseudoJob(parentJob)) {
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("Purging sync-queue
item: " + item.toString());
+ }
+ completeAsyncJob(item.getContentId(),
parentJob.getStatus(), 0, "Job is not "
+ + "scheduled for execution as
the parent job is done. Parent Job " +
+ "state:" + " " +
parentJob.getStatus());
+
_jobMonitor.unregisterByJobId(item.getContentId());
+ _queueMgr.purgeItem(item.getId());
+ isPurged = true;
+ }
+ }
+ }
+ if (!isPurged) {
Review comment:
modified. see above comment.
----------------------------------------------------------------
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