Schedule a job.
@param newSJE new job entry.
8972
private synchronized void schedule(final ScheduledJobEntry newSJE) {
        // disallow new jobs after shutdown
        if (shutdown) {
            return;
        }
        int max = jobList.size();
        long desiredExecutionTime = newSJE.desiredExecutionTime;

        // find the index i such that timeInMillis < jobList[i]
        int i = 0;
        for (; i < max; i++) {

            ScheduledJobEntry sje = (ScheduledJobEntry) jobList.get(i);

            if (desiredExecutionTime < sje.desiredExecutionTime) {
                break;
            }
        }
        jobList.add(i, newSJE);
        // if the jobList was empty, then notify the scheduler thread
        if (i == 0) {
            this.notifyAll();
        }
    }
759630
public void unschedule(final org.easybatch.core.job.Job job) throws JobSchedulerException {
        String jobName = job.getName();
        LOGGER.info("Unscheduling job ''{}'' ", jobName);
        try {
            scheduler.unscheduleJob(TriggerKey.triggerKey(TRIGGER_NAME_PREFIX + jobName));
        } catch (SchedulerException e) {
            throw new JobSchedulerException(format("Unable to unschedule job '%s'", jobName), e);
        }
    }
1281152
public void scheduleInternalEvent(String name, Date time, String message, String reference) {
        schedule(name, time, message, reference);
    }
302010
public void setJobs(java.util.Collection<String> jobs) {
        if (jobs == null) {
            this.jobs = null;
            return;
        }

        this.jobs = new java.util.ArrayList<String>(jobs);
    }
997100
private void runJobLauncherLoop() throws JobException {
    try {
      while (true) {
        currentJobLauncher = this.jobScheduler.buildJobLauncher(jobProps);
        // in "run once" case, job scheduler will remove current job from the scheduler
        boolean isEarlyStopped = this.jobScheduler.runJob(jobProps, jobListener, currentJobLauncher);
        boolean isRetriggerEnabled = this.isRetriggeringEnabled();
        if (isEarlyStopped && isRetriggerEnabled) {
          log.info("Job {} will be re-triggered.", jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY));
        } else {
          break;
        }
        currentJobLauncher = null;
      }
    } catch (Exception e) {
      log.error("Failed to run job {}", jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e);
      throw new JobException("Failed to run job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e);
    }
  }
366062
function addToSchedule(service, record) {
    if (record && record.schedule) {
        record.jobId = schedule.scheduleJob({
            start: Date.now() + record.delay,
            period: record.interval
        },
        doScheduleJob, {
            service: service,
            record: record
        });
    }
}
891936
private Acknowledge startJobExecution(JobMasterId newJobMasterId) throws Exception {

		validateRunsInMainThread();

		checkNotNull(newJobMasterId, "The new JobMasterId must not be null.");

		if (Objects.equals(getFencingToken(), newJobMasterId)) {
			log.info("Already started the job execution with JobMasterId {}.", newJobMasterId);

			return Acknowledge.get();
		}

		setNewFencingToken(newJobMasterId);

		startJobMasterServices();

		log.info("Starting execution of job {} ({}) under job master id {}.", jobGraph.getName(), jobGraph.getJobID(), newJobMasterId);

		resetAndScheduleExecutionGraph();

		return Acknowledge.get();
	}
829085
@Override
  public synchronized void scheduleJob(Properties jobProps, JobListener jobListener) throws JobException {
    Map<String, Object> additionalJobDataMap = Maps.newHashMap();
    additionalJobDataMap.put(ServiceConfigKeys.GOBBLIN_SERVICE_FLOWSPEC,
        this.scheduledFlowSpecs.get(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY)));

    try {
      scheduleJob(jobProps, jobListener, additionalJobDataMap, GobblinServiceJob.class);
    } catch (Exception e) {
      throw new JobException("Failed to schedule job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e);
    }
  }
1005437
public void addTask(Object objJobDef)
    {
        synchronized (this)
        {
            gvJobs.addElement(objJobDef); // Vector is thread safe.
            if (giCurrentThreads >= giMaxThreads)
                return;             // The max threads are running... let the scheduler process them in order
            giCurrentThreads++;     // I'm going to start another thread
        }
        TaskScheduler js = this.makeNewTaskScheduler(0);
        // This should be done more efficiently... having the threads waiting in a pool to be awakened when needed.
        Thread thread = new Thread(js, "TaskSchedulerThread");
        thread.start();
    }
1192642
public static void doEnqueue(final Jedis jedis, final String namespace, final String queue, final String jobJson) {
        jedis.sadd(JesqueUtils.createKey(namespace, QUEUES), queue);
        jedis.rpush(JesqueUtils.createKey(namespace, QUEUE, queue), jobJson);
    }
241265
public final void update( final long newworked, final String msg) {
    if( newworked > 0 || (msg != null && !msg.equals(_msg)) ) {
      new JAtomic() {
        @Override boolean abort(Job job) { return newworked==0 && ((msg==null && _msg==null) || (msg != null && msg.equals(job._msg))); }
        @Override void update(Job old) { old._worked += newworked; old._msg = msg; }
      }.apply(this);
    }
  }
402057
public boolean isScheduled(final org.easybatch.core.job.Job job) throws JobSchedulerException {
        String jobName = job.getName();
        try {
            return scheduler.checkExists(TriggerKey.triggerKey(TRIGGER_NAME_PREFIX + jobName));
        } catch (SchedulerException e) {
            throw new JobSchedulerException(format("Unable to check if the job '%s' is scheduled", jobName), e);
        }
    }
703197
private void runJob(Job jobToRun) {
		long startExecutionTime = timeProvider.currentTime();
		long timeBeforeNextExecution = jobToRun.nextExecutionTimeInMillis() - startExecutionTime;
		if(timeBeforeNextExecution < 0) {
			logger.debug("Job '{}' execution is {}ms late", jobToRun.name(), -timeBeforeNextExecution);
		}
		jobToRun.status(JobStatus.RUNNING);
		jobToRun.lastExecutionStartedTimeInMillis(startExecutionTime);
		jobToRun.threadRunningJob(Thread.currentThread());

		try {
			jobToRun.runnable().run();
		} catch(Throwable t) {
			logger.error("Error during job '{}' execution", jobToRun.name(), t);
		}
		jobToRun.executionsCount(jobToRun.executionsCount() + 1);
		jobToRun.lastExecutionEndedTimeInMillis(timeProvider.currentTime());
		jobToRun.threadRunningJob(null);

		if(logger.isDebugEnabled()) {
			logger.debug(
				"Job '{}' executed in {}ms", jobToRun.name(),
				timeProvider.currentTime() - startExecutionTime
			);
		}

		if(shuttingDown) {
			return;
		}
		synchronized (this) {
			scheduleNextExecution(jobToRun);
		}
	}
607696
public void loadFromBean(CmsScheduledJobInfo info) {

        // all other fields already populated by field group, we still need to handle the parameters

        for (Map.Entry<String, String> entry : info.getParameters().entrySet()) {
            addParamLine(entry.getKey(), entry.getValue());
        }
    }
1002450
@Override
	public void executeJob(String groupName, String jobName) throws SchedulerException {
		if (!config.isExecuteJobAllowed()) {
			LOGGER.warn("not allowed to execute any job");
			return;
		}
		scheduler.triggerJob(new JobKey(jobName, groupName));
	}
812666
public void setJobQueues(java.util.Collection<String> jobQueues) {
        if (jobQueues == null) {
            this.jobQueues = null;
            return;
        }

        this.jobQueues = new java.util.ArrayList<String>(jobQueues);
    }
1334307
public void setJobClass(Class<? extends Job> jobClass) {

    if (jobClass == null) {
      throw new IllegalArgumentException("Job class cannot be null.");
    }

    if (!Job.class.isAssignableFrom(jobClass)) {
      throw new IllegalArgumentException("Job class must implement the Job interface.");
    }

    this.jobClass = jobClass;
  }