if (s_logger.isTraceEnabled()) {
s_logger.trace("Security Group take: no work found");
}
return null;
}
SecurityGroupWorkVO work = vos.get(0);
boolean processing = false;
if ( findByVmIdStep(work.getInstanceId(), Step.Processing) != null) {
//ensure that there is no job in Processing state for the same VM
processing = true;
if (s_logger.isTraceEnabled()) {
s_logger.trace("Security Group work take: found a job in Scheduled and Processing vmid=" + work.getInstanceId());
}
}
work.setServerId(serverId);
work.setDateTaken(new Date());
if (processing) {
//the caller to take() should check the step and schedule another work item to come back
//and take a look.
work.setStep(SecurityGroupWork.Step.Done);
} else {
work.setStep(SecurityGroupWork.Step.Processing);
}
update(work.getId(), work);
txn.commit();
return work;