@param Key $triggerKey

@throws JobPersistenceException
485999
public function doResetTriggerFromErrorState(Key $triggerKey)
    {
        if (null == $trigger = $this->retrieveTrigger($triggerKey)) {
            throw new JobPersistenceException(sprintf('There is no trigger with identity: "%s"', (string) $triggerKey));
        }

        if ($trigger->getState() !== Trigger::STATE_ERROR) {
            return;
        }

        $state = Trigger::STATE_WAITING;
        if ($this->isTriggerGroupPaused($triggerKey->getGroup())) {
            $state = Trigger::STATE_PAUSED;
        }

        $this->res->getTriggerStorage()->getCollection()->updateOne([
            'name' => $trigger->getKey()->getName(),
            'group' => $trigger->getKey()->getGroup(),
        ], [
            '$set' => [
                'state' => $state,
            ]
        ]);
    }
1145410
public static void validatePersistedJobInstanceIds(JobInstanceEntity instance) throws PersistenceException {
        if (instance.getInstanceId() <= 0) {

            long id = instance.getInstanceId();

            PersistenceException e = new PersistenceException(new BatchIllegalIDPersistedException(Long.toString(id)));
            logger.log(Level.SEVERE, "error.invalid.persisted.job.id",
                       new Object[] { Long.toString(id), e });

            throw e;
        }

    }
413271
public void unlock( Key job_key ) { 
    if( _key != null ) {
      Log.debug(Log.Tag.Sys.LOCKS,"unlock "+_key+" by job "+job_key);
      new Unlock(job_key).invoke(_key); 
    }
  }
169551
@Override
    public List<OperableTrigger> getTriggersForJob(final JobKey jobKey) throws JobPersistenceException {
        return doWithLock(new LockCallback<List<OperableTrigger>>() {
            @Override
            public List<OperableTrigger> doWithLock(JedisCommands jedis) throws JobPersistenceException {
                return storage.getTriggersForJob(jobKey, jedis);
            }
        }, "Could not retrieve triggers for job.");
    }
1352855
private function copyKey(string $key): void
    {
        $source = $this->sourceDictionary->get($key);
        if ($source->isSourceEmpty()) {
            $this->logger->debug(
                '{key}: Is empty in source language and therefore skipped.',
                ['key' => $key]
            );
            return;
        }

        if (!$this->targetDictionary->has($key)) {
            $this->logger->log($this->logLevel, 'Adding key {key}.', ['key' => $key]);
            if ($this->dryRun) {
                return;
            }

            $this->targetDictionary->add($key);
        }
        $target = $this->targetDictionary->getWritable($key);

        $this->copySource($source, $target);
        $this->copyTarget($source, $target);
    }
766919
protected function addTableKey(string $key) : void
    {
        if (!$this->keyStore->isValidTableKey($key)) {
            throw new DumpException("The table key \"{$key}\" has already been defined previously.");
        }

        if ($this->keyStore->isRegisteredAsArrayTableKey($key)) {
            throw new DumpException("The table \"{$key}\" has already been defined as previous array of tables.");
        }

        $this->keyStore->addTableKey($key);
    }
804601
protected function triggerRequest(\PermissionKey $pk)
    {
        if (!$this->wrID) {
            $this->save();
        }

        if (!$pk->canPermissionKeyTriggerWorkflow()) {
            throw new \Exception(t('This permission key cannot start a workflow.'));
        }

        $pa = $pk->getPermissionAccessObject();
        $skipWorkflow = true;
        if (is_object($pa)) {
            $workflows = $pa->getWorkflows();
            foreach ($workflows as $wf) {
                if ($wf->validateTrigger($this)) {
                    $wp = $this->addWorkflowProgress($wf);
                    $response = $wp->getWorkflowProgressResponseObject();
                    if ($response instanceof SkippedResponse) {
                        // Since the response was skipped, we delete the workflow progress operation and keep moving.
                        $wp->delete();
                    } else {
                        $skipWorkflow = false;
                    }
                    $event = new GenericEvent();
                    $event->setArgument('progress', $wp);
                    Events::dispatch('workflow_triggered', $event);
                }
            }
        }

        if ($skipWorkflow) {
            $defaultWorkflow = new EmptyWorkflow();
            $wp = $this->addWorkflowProgress($defaultWorkflow);

            $event = new GenericEvent();
            $event->setArgument('progress', $wp);
            Events::dispatch('workflow_triggered', $event);

            return $wp->getWorkflowProgressResponseObject();
        }
    }
298133
protected function lock(string $key)
    {
        if (isset($this->locks[$key])) {
            throw new InvalidArgumentError('Key was already locked.');
        }

        $this->locks[$key] = new Delayed();
    }
1053511
@Override
    public void resumeTrigger(TriggerKey triggerKey, JedisCluster jedis) throws JobPersistenceException {
        final String triggerHashKey = redisSchema.triggerHashKey(triggerKey);
        Boolean exists = jedis.sismember(redisSchema.triggersSet(), triggerHashKey);
        Double isPaused = jedis.zscore(redisSchema.triggerStateKey(RedisTriggerState.PAUSED), triggerHashKey);
        Double isPausedBlocked = jedis.zscore(redisSchema.triggerStateKey(RedisTriggerState.PAUSED_BLOCKED), triggerHashKey);

        if (!exists) {
            // Trigger does not exist.  Nothing to do.
            return;
        }
        if (isPaused == null && isPausedBlocked == null) {
            // Trigger is not paused. Nothing to do.
            return;
        }
        OperableTrigger trigger = retrieveTrigger(triggerKey, jedis);
        final String jobHashKey = redisSchema.jobHashKey(trigger.getJobKey());
        final Date nextFireTime = trigger.getNextFireTime();

        if (nextFireTime != null) {
            if (isBlockedJob(jobHashKey, jedis)) {
                setTriggerState(RedisTriggerState.BLOCKED, (double) nextFireTime.getTime(), triggerHashKey, jedis);
            } else {
                setTriggerState(RedisTriggerState.WAITING, (double) nextFireTime.getTime(), triggerHashKey, jedis);
            }
        }
        applyMisfire(trigger, jedis);
    }
985235
protected function doResumeTrigger(Key $triggerKey)
    {
        if (false == $trigger = $this->retrieveTrigger($triggerKey)) {
            return;
        }

        if (false == $trigger->getNextFireTime()) {
            return;
        }

        $misfired = false;
        if (((int) $trigger->getNextFireTime()->format('U')) < time()) {
            $misfired = $this->updateMisfiredTrigger($triggerKey, Trigger::STATE_WAITING);
        }

        if (false == $misfired) {
            $trigger->setState(Trigger::STATE_WAITING);
            $result = $this->res->getTriggerStorage()->update($trigger);

            if (false == $result->isAcknowledged() || false == $result->getModifiedCount()) {
                throw new JobPersistenceException(sprintf('Couldn\'t resume trigger: "%s"', $triggerKey));
            }
        }
    }
208815
@Override
    public void pauseTrigger(TriggerKey triggerKey, Jedis jedis) throws JobPersistenceException {
        final String triggerHashKey = redisSchema.triggerHashKey(triggerKey);
        Pipeline pipe = jedis.pipelined();
        Response<Boolean> exists = pipe.exists(triggerHashKey);
        Response<Double> completedScore = pipe.zscore(redisSchema.triggerStateKey(RedisTriggerState.COMPLETED), triggerHashKey);
        Response<String> nextFireTimeResponse = pipe.hget(triggerHashKey, TRIGGER_NEXT_FIRE_TIME);
        Response<Double> blockedScore = pipe.zscore(redisSchema.triggerStateKey(RedisTriggerState.BLOCKED), triggerHashKey);
        pipe.sync();

        if(!exists.get()){
            return;
        }
        if(completedScore.get() != null){
            // doesn't make sense to pause a completed trigger
            return;
        }

        final long nextFireTime = nextFireTimeResponse.get() == null
                || nextFireTimeResponse.get().isEmpty() ? -1 : Long.parseLong(nextFireTimeResponse.get());
        if(blockedScore.get() != null){
            setTriggerState(RedisTriggerState.PAUSED_BLOCKED, (double) nextFireTime, triggerHashKey, jedis);
        }
        else{
            setTriggerState(RedisTriggerState.PAUSED, (double) nextFireTime, triggerHashKey, jedis);
        }
    }
415160
public void triggerJob (final JobKey jobKey, final JobDataMap data) throws SchedulerException
  {
    m_aSched.triggerJob (jobKey, data);
  }
539970
public ETriggerState getTriggerState (final TriggerKey triggerKey) throws SchedulerException
  {
    validateState ();

    return m_aResources.getJobStore ().getTriggerState (triggerKey);
  }
819834
public List<OperableTrigger> getTriggersForJob(JobKey jobKey, T jedis) throws JobPersistenceException {
        final String jobTriggerSetKey = redisSchema.jobTriggersSetKey(jobKey);
        final Set<String> triggerHashKeys = jedis.smembers(jobTriggerSetKey);
        List<OperableTrigger> triggers = new ArrayList<>();
        for (String triggerHashKey : triggerHashKeys) {
            triggers.add(retrieveTrigger(redisSchema.triggerKey(triggerHashKey), jedis));
        }
        return  triggers;
    }
176487
@Override
  public OperableTrigger retrieveTrigger(String triggerKey) {

    synchronized (lock) {
      TriggerWrapper tw = wrappedTriggersByKey.get(triggerKey);

      return (tw != null) ? (OperableTrigger) tw.getTrigger().clone() : null;
    }
  }
818877
@Override
	public boolean isPaused(JobKey jobKey) throws SchedulerException {
		List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
		boolean result = true; 
		if (null != triggers && triggers.size() > 0) {
			for (Trigger trigger : triggers) {
				result = result && scheduler.getTriggerState(trigger.getKey()) == TriggerState.PAUSED;
			}
			return result;
		}
		return false;
	}
1139332
protected void releaseTriggersCron(T jedis) throws JobPersistenceException {
        // has it been more than 10 minutes since we last released orphaned triggers
        // or is this the first check upon initialization
        if(isTriggerLockTimeoutExceeded(jedis) || !isActiveInstance(schedulerInstanceId, jedis)){
            releaseOrphanedTriggers(RedisTriggerState.ACQUIRED, RedisTriggerState.WAITING, jedis);
            releaseOrphanedTriggers(RedisTriggerState.BLOCKED, RedisTriggerState.WAITING, jedis);
            releaseOrphanedTriggers(RedisTriggerState.PAUSED_BLOCKED, RedisTriggerState.PAUSED, jedis);
            settLastTriggerReleaseTime(System.currentTimeMillis(), jedis);
        }
    }