@Transactional(readOnly = false)
@Override
public ScheduleResult reScheduleUpdateTask(long updateWorkerTaskId, long time, boolean incrementRetries,
UpdateWorkerTask.AuditTrailEntry auditTrailEntry) {
UpdateWorkerTask updt = em
.find(UpdateWorkerTask.class, updateWorkerTaskId);
// Check if updt is null. This can happen if we were in the process of updating a
// connector instance which was subsequently deleted. In that case, print a message
// and return
if(updt==null) {
StringBuilder sb = new StringBuilder("module=updateQueue component=connectorUpdateService action=reScheduleUpdateTask")
.append(" updateWorkerTaskId="+updateWorkerTaskId)
.append(" message=\"Ignoring reschedule of an update task which is no longer in the system (deleted connector?)");
logger.info(sb);
return null;
}
// Set the audit trail according to what just happened if a non-null auditTrailEntry is provided
if(auditTrailEntry!=null)
updt.addAuditTrailEntry(auditTrailEntry);
// Spawn a duplicate entry in the UpdateWorker table to record this failure and the reason for it
if (!incrementRetries) {
UpdateWorkerTask failed = new UpdateWorkerTask(updt);
failed.workerThreadName = updt.workerThreadName;
failed.startTime = updt.startTime;
failed.endTime = DateTimeUtils.currentTimeMillis();
failed.auditTrail = updt.auditTrail;
failed.apiKeyId = updt.apiKeyId;