コード例 #1
0
 /**
  * Relock trigger if its lock has expired.
  *
  * @param key trigger to lock
  * @return true when successfully relocked
  */
 public boolean relockExpired(TriggerKey key) {
   Document existingLock = locksDao.findTriggerLock(key);
   if (existingLock != null) {
     if (expiryCalculator.isTriggerLockExpired(existingLock)) {
       // When a scheduler is defunct then its triggers become expired
       // after sometime and can be recovered by other schedulers.
       // To check that a trigger is owned by a defunct scheduler we evaluate
       // its LOCK_TIME and try to reassign it to this scheduler.
       // Relock may not be successful when some other scheduler has done
       // it first.
       log.info("Trigger {} is expired - re-locking", key);
       return locksDao.relock(key, existingLock.getDate(Constants.LOCK_TIME));
     } else {
       log.info(
           "Trigger {} hasn't expired yet. Lock time: {}",
           key,
           existingLock.getDate(Constants.LOCK_TIME));
     }
   } else {
     log.warn(
         "Error retrieving expired lock from the database for trigger {}. Maybe it was deleted",
         key);
   }
   return false;
 }
コード例 #2
0
 /**
  * Unlock job that have existing, expired lock.
  *
  * @param job job to potentially unlock
  */
 public void unlockExpired(JobDetail job) {
   Document existingLock = locksDao.findJobLock(job.getKey());
   if (existingLock != null) {
     if (expiryCalculator.isJobLockExpired(existingLock)) {
       log.debug("Removing expired lock for job {}", job.getKey());
       locksDao.remove(existingLock);
     }
   }
 }
コード例 #3
0
 /**
  * Try to lock given trigger, ignoring errors.
  *
  * @param key trigger to lock
  * @return true when successfully locked, false otherwise
  */
 public boolean tryLock(TriggerKey key) {
   try {
     locksDao.lockTrigger(key);
     return true;
   } catch (MongoWriteException e) {
     log.info("Failed to lock trigger {}, reason: {}", key, e.getError());
   }
   return false;
 }
コード例 #4
0
 public void unlockAcquiredTrigger(OperableTrigger trigger) {
   locksDao.unlockTrigger(trigger);
 }
コード例 #5
0
 /**
  * Lock job if it doesn't allow concurrent executions.
  *
  * @param job job to lock
  */
 public void lockJob(JobDetail job) {
   if (job.isConcurrentExectionDisallowed()) {
     locksDao.lockJob(job);
   }
 }