Package org.terracotta.quartz.wrappers

Examples of org.terracotta.quartz.wrappers.JobWrapper


  }

  private void evalOrphanedTrigger(TriggerWrapper tw, boolean newNode) {
    getLog().info("Evaluating orphaned trigger " + tw);

    JobWrapper jobWrapper = jobFacade.get(tw.getJobKey());

    if (jobWrapper == null) {
      getLog().error("No job found for orphaned trigger: " + tw);
      // even if it was deleted, there may be cleanup to do
      jobFacade.removeBlockedJob(tw.getJobKey());
      return;
    }

    if (newNode && tw.getState() == TriggerState.ERROR) {
      tw.setState(TriggerState.WAITING, terracottaClientId, triggerFacade);
      timeTriggers.add(tw);
    }

    if (tw.getState() == TriggerState.BLOCKED) {
      tw.setState(TriggerState.WAITING, terracottaClientId, triggerFacade);
      timeTriggers.add(tw);
    } else if (tw.getState() == TriggerState.PAUSED_BLOCKED) {
      tw.setState(TriggerState.PAUSED, terracottaClientId, triggerFacade);
    }

    if (tw.getState() == TriggerState.ACQUIRED) {
      tw.setState(TriggerState.WAITING, terracottaClientId, triggerFacade);
      timeTriggers.add(tw);
    }

    if (!tw.mayFireAgain() && !jobWrapper.requestsRecovery()) {
      try {
        removeTrigger(tw.getKey());
      } catch (JobPersistenceException e) {
        getLog().error("Can't remove completed trigger (and related job) " + tw, e);
      }
    }

    if (jobWrapper.isConcurrentExectionDisallowed()) {
      jobFacade.removeBlockedJob(jobWrapper.getKey());
      List<TriggerWrapper> triggersForJob = triggerFacade.getTriggerWrappersForJob(jobWrapper.getKey());

      for (TriggerWrapper trigger : triggersForJob) {
        if (trigger.getState() == TriggerState.BLOCKED) {
          trigger.setState(TriggerState.WAITING, terracottaClientId, triggerFacade);
          timeTriggers.add(trigger);
View Full Code Here


      }
    }
  }

  private void scheduleRecoveryIfNeeded(TriggerWrapper tw, FiredTrigger recovering) {
    JobWrapper jobWrapper = jobFacade.get(tw.getJobKey());

    if (jobWrapper == null) {
      getLog().error("No job found for orphaned trigger: " + tw);
      return;
    }

    if (jobWrapper.requestsRecovery()) {
      OperableTrigger recoveryTrigger = createRecoveryTrigger(tw, jobWrapper, "recover_" + terracottaClientId + "_"
                                                                          + ftrCtr++, recovering);

      JobDataMap jd = tw.getTriggerClone().getJobDataMap();
      jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_NAME, tw.getKey().getName());
View Full Code Here

    JobDetail clone = (JobDetail) newJob.clone();

    lock();
    try {
      // wrapper construction must be done in lock since serializer is unlocked
      JobWrapper jw = wrapperFactory.createJobWrapper(clone);

      if (jobFacade.containsKey(jw.getKey())) {
        if (!replaceExisting) { throw new ObjectAlreadyExistsException(newJob); }
      } else {
        // get job group
        Set<String> grpSet = toolkitDSHolder.getOrCreateJobsGroupMap(newJob.getKey().getGroup());
        // add to jobs by group
        grpSet.add(jw.getKey().getName());

        if (!jobFacade.hasGroup(jw.getKey().getGroup())) {
          jobFacade.addGroup(jw.getKey().getGroup());
        }
      }

      // add/update jobs FQN map
      jobFacade.put(jw.getKey(), jw);
    } finally {
      unlock();
    }
  }
View Full Code Here

        }
        // remove from triggers array
        timeTriggers.remove(tw);

        if (removeOrphanedJob) {
          JobWrapper jw = jobFacade.get(tw.getJobKey());
          List<OperableTrigger> trigs = getTriggersForJob(tw.getJobKey());
          if ((trigs == null || trigs.size() == 0) && !jw.isDurable()) {
            JobKey jobKey = tw.getJobKey();
            if (removeJob(jobKey)) {
              signaler.notifySchedulerListenersJobDeleted(jobKey);
            }
          }
View Full Code Here

   * @param jobKey The key of the <code>Job</code> to be retrieved.
   * @return The desired <code>Job</code>, or null if there is no match.
   */
  @Override
  public JobDetail retrieveJob(JobKey jobKey) throws JobPersistenceException {
    JobWrapper jobWrapper = getJob(jobKey);
    return jobWrapper == null ? null : (JobDetail) jobWrapper.getJobDetailClone();
  }
View Full Code Here

            getLog().warn("No fired trigger record found for " + trigger + " (" + fireId + ")");
            break;
          }

          JobKey jobKey = jobDetail.getKey();
          JobWrapper jw = jobFacade.get(jobKey);
          TriggerWrapper tw = triggerFacade.get(trigger.getKey());

          // It's possible that the job is null if:
          // 1- it was deleted during execution
          // 2- RAMJobStore is being used only for volatile jobs / triggers
          // from the JDBC job store
          if (jw != null) {
            if (jw.isPersistJobDataAfterExecution()) {
              JobDataMap newData = jobDetail.getJobDataMap();
              if (newData != null) {
                newData = (JobDataMap) newData.clone();
                newData.clearDirtyFlag();
              }
              jw.setJobDataMap(newData, jobFacade);
            }
            if (jw.isConcurrentExectionDisallowed()) {
              jobFacade.removeBlockedJob(jw.getKey());
              tw.setState(TriggerState.WAITING, terracottaClientId, triggerFacade);
              timeTriggers.add(tw);

              List<TriggerWrapper> trigs = triggerFacade.getTriggerWrappersForJob(jw.getKey());

              for (TriggerWrapper ttw : trigs) {
                if (ttw.getState() == TriggerState.BLOCKED) {
                  ttw.setState(TriggerState.WAITING, terracottaClientId, triggerFacade);
                  timeTriggers.add(ttw);
View Full Code Here

TOP

Related Classes of org.terracotta.quartz.wrappers.JobWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.