Java Code Examples for org.quartz.JobDetail

The following examples show how to use org.quartz.JobDetail. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: rice   Source File: QuartzQueueAction.java    License: Educational Community License v2.0 6 votes vote down vote up
@Override
public ActionMessages establishRequiredState(HttpServletRequest request, ActionForm form) throws Exception {
    if ("moveToRouteQueue".equals(request.getParameter("methodToCall")) && request.getAttribute(RENDER_LIST_OVERRIDE) == null) {
        return null;
    }

    Scheduler scheduler = KSBServiceLocator.getScheduler();
    List<QuartzQueueForm> jobs = new ArrayList<QuartzQueueForm>();
    List<String> jobGroups = KSBServiceLocator.getScheduler().getJobGroupNames();

    for (int i = 0; i < jobGroups.size(); i++) {
        String jobGroup = KSBServiceLocator.getScheduler().getJobGroupNames().get(i);
        for(JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(jobGroup))) {
            Trigger trigger = scheduler.getTriggersOfJob(jobKey).get(0);
            JobDetail jobDetail = scheduler.getJobDetail(jobKey);
            jobs.add(new QuartzQueueForm(jobDetail, trigger) );
        }
    }

    request.setAttribute("jobs", jobs);
    return null;
}
 
Example 2
Source Project: nexus-public   Source File: SchedulerTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testAbilityToFireImmediatelyWhenStartedAfter() throws Exception {
  List<Long> jobExecTimestamps = Collections.synchronizedList(new ArrayList<Long>());
  CyclicBarrier barrier = new CyclicBarrier(2);

  Scheduler sched = createScheduler("testAbilityToFireImmediatelyWhenStartedAfter", 5);
  sched.getContext().put(BARRIER, barrier);
  sched.getContext().put(DATE_STAMPS, jobExecTimestamps);

  JobDetail job1 = JobBuilder.newJob(TestJobWithSync.class).withIdentity("job1").build();
  Trigger trigger1 = TriggerBuilder.newTrigger().forJob(job1).build();

  long sTime = System.currentTimeMillis();

  sched.scheduleJob(job1, trigger1);
  sched.start();

  barrier.await(TEST_TIMEOUT_SECONDS, TimeUnit.SECONDS);

  sched.shutdown(true);

  long fTime = jobExecTimestamps.get(0);

  assertTrue("Immediate trigger did not fire within a reasonable amount of time.",
      (fTime - sTime < 7000L));  // This is dangerously subjective!  but what else to do?
}
 
Example 3
Source Project: lams   Source File: JobDetailImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean equals(Object obj) {
    if (!(obj instanceof JobDetail)) {
        return false;
    }

    JobDetail other = (JobDetail) obj;

    if(other.getKey() == null || getKey() == null)
        return false;
    
    if (!other.getKey().equals(getKey())) {
        return false;
    }
        
    return true;
}
 
Example 4
Source Project: nexus-public   Source File: JobStoreImpl.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void storeJob(final ODatabaseDocumentTx db, final JobDetail jobDetail, final boolean replaceExisting)
    throws JobPersistenceException
{
  log.debug("Store job: jobDetail={}, replaceExisting={}", jobDetail, replaceExisting);

  JobDetailEntity entity = jobDetailEntityAdapter.readByKey(db, jobDetail.getKey());
  if (entity == null) {
    // no existing entity, add new one
    entity = new JobDetailEntity(jobDetail);
    jobDetailEntityAdapter.addEntity(db, entity);
  }
  else {
    // otherwise entity exists, maybe replace if allowed
    if (replaceExisting) {
      entity.setValue(jobDetail);
      jobDetailEntityAdapter.editEntity(db, entity);
    }
    else {
      throw new ObjectAlreadyExistsException(jobDetail);
    }
  }
}
 
Example 5
Source Project: JuniperBot   Source File: ReminderJob.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static JobDetail createDetails(MessageChannel channel, Member member, String message) {
    String userId;
    String guildId = null;
    if (channel instanceof PrivateChannel) {
        userId = ((PrivateChannel) channel).getUser().getId();
    } else {
        guildId = member.getGuild().getId();
        userId = member.getUser().getId();
    }
    return JobBuilder
            .newJob(ReminderJob.class)
            .withIdentity(GROUP + " - " + UUID.randomUUID(), GROUP)
            .usingJobData(ATTR_GUILD_ID, guildId)
            .usingJobData(ATTR_USER_ID, userId)
            .usingJobData(ATTR_CHANNEL_ID, channel.getId())
            .usingJobData(ATTR_MESSAGE, message)
            .build();
}
 
Example 6
Source Project: Lottery   Source File: CmsTaskAct.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 开始任务调度
 * @param task 任务
 * @param taskCode 任务名称
 * @throws ParseException
 * @throws SchedulerException
 * @throws ClassNotFoundException
 */
private void startTask(CmsTask task,String taskCode) throws ParseException, SchedulerException, ClassNotFoundException{
	String cronExpress=manager.getCronExpressionFromDB(task.getId());
	System.out.println(cronExpress);
	if(cronExpress.indexOf("null")==-1){
		JobDetail jobDetail = new JobDetail();
		jobDetail.setName(taskCode);
		jobDetail.setGroup(Scheduler.DEFAULT_GROUP);
		jobDetail.setJobClass(getClassByTask(task.getJobClass()));
		//任务需要参数attr属性 
		jobDetail.setJobDataMap(getJobDataMap(task.getAttr()));
		CronTrigger cronTrigger = new CronTrigger("cron_" + taskCode,Scheduler.DEFAULT_GROUP, jobDetail.getName(),Scheduler.DEFAULT_GROUP);
		cronTrigger.setCronExpression(cronExpress);
		scheduler.scheduleJob(jobDetail, cronTrigger); 
	}
}
 
Example 7
Source Project: quartz-redis-jobstore   Source File: RedisJobStoreTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void clearAllSchedulingData() throws Exception {
    // create and store some jobs, triggers, and calendars
    Map<JobDetail, Set<? extends Trigger>> jobsAndTriggers = getJobsAndTriggers(2, 2, 2, 2);
    jobStore.storeJobsAndTriggers(jobsAndTriggers, false);

    // ensure that the jobs, triggers, and calendars were stored
    assertEquals(2, (long) jedis.scard(schema.jobGroupsSet()));
    assertEquals(4, (long) jedis.scard(schema.jobsSet()));
    assertEquals(8, (long) jedis.scard(schema.triggerGroupsSet()));
    assertEquals(16, (long) jedis.scard(schema.triggersSet()));

    jobStore.clearAllSchedulingData();

    assertEquals(0, (long) jedis.scard(schema.jobGroupsSet()));
    assertEquals(0, (long) jedis.scard(schema.jobsSet()));
    assertEquals(0, (long) jedis.scard(schema.triggerGroupsSet()));
    assertEquals(0, (long) jedis.scard(schema.triggersSet()));
}
 
Example 8
@Test
void scheduleInactive() throws SchedulerException {
  ScheduledJob scheduledJob = scheduledJobFactory.create();
  scheduledJob.setId(id);
  scheduledJob.set(ScheduledJobMetadata.CRON_EXPRESSION, "	0/20 * * * * ?");
  scheduledJob.set(ScheduledJobMetadata.NAME, "name");
  scheduledJob.set(ScheduledJobMetadata.ACTIVE, false);
  scheduledJob.setType(scheduledJobType);

  when(quartzScheduler.checkExists(jobKey)).thenReturn(false);

  jobScheduler.schedule(scheduledJob);

  verify(quartzScheduler, Mockito.never())
      .scheduleJob(ArgumentMatchers.any(JobDetail.class), ArgumentMatchers.any(Trigger.class));
}
 
Example 9
Source Project: quartz-web   Source File: QuartzManager.java    License: Apache License 2.0 6 votes vote down vote up
public JobDetail addStatefulMethodJob(String schedulerName, String jobName, String jobGroup, String jobClass,
                                    Object[] constructorArguments, String jobClassMethodName,
                                    Object[] jobClassMethodArgs, String description) throws SchedulerException {
    Assert.notNull(jobClass, "jobClass can not be null");
    Assert.notEmpty(schedulerName, "schedulerName can not be empty");
    Assert.notEmpty(jobName, "jobName can not be empty");
    Assert.notEmpty(jobGroup, "jobGroup can not be empty");
    Assert.notEmpty(jobClassMethodName, "jobClassMethodName can not be empty");
    JobDataMap jobDataMap = new JobDataMap();
    jobDataMap.put("jobClass", jobClass);
    jobDataMap.put("constructorArguments", constructorArguments);
    jobDataMap.put("jobClassMethodName", jobClassMethodName);
    jobDataMap.put("jobClassMethodArgs", jobClassMethodArgs);
    JobDetail jobDetail = JobBuilder.newJob(StatefulMethodInvokeJob.class).withIdentity(jobName, jobGroup)
            .withDescription(description).setJobData(jobDataMap).storeDurably().build();
    addJob(schedulerName, jobDetail);
    return jobDetail;
}
 
Example 10
Source Project: springboot-quartz   Source File: ScheduleJobService.java    License: MIT License 6 votes vote down vote up
private void wrapScheduleJob(ScheduleJob scheduleJob,Scheduler scheduler,JobKey jobKey,Trigger trigger){  
    try {  
        scheduleJob.setJobName(jobKey.getName());  
        scheduleJob.setJobGroup(jobKey.getGroup()); 
  
        JobDetail jobDetail = scheduler.getJobDetail(jobKey);  
        ScheduleJob job = (ScheduleJob)jobDetail.getJobDataMap().get("scheduleJob");  
        scheduleJob.setDesc(job.getDesc());  
        scheduleJob.setJobId(job.getJobId());
  
        Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());  
        scheduleJob.setJobStatus(triggerState.name());  
        if(trigger instanceof CronTrigger){  
            CronTrigger cronTrigger = (CronTrigger)trigger;  
            String cronExpression = cronTrigger.getCronExpression();  
            scheduleJob.setCronExpression(cronExpression);  
        }  
    } catch (SchedulerException e) {  
        e.printStackTrace(); 
    }  
}
 
Example 11
private synchronized void schedule()
{
    try
    {
        scheduler = schedulerFactory.getScheduler();

        JobDetail job = JobBuilder.newJob()
                .withIdentity(jobName)
                .ofType(ConfigSchedulerJob.class)
                .build();
        jobKey = job.getKey();
        job.getJobDataMap().put(CONFIG_SCHEDULER, this);
        CronExpression cronExpression = normalCronSchedule ? this.cronExpression : initialAndOnErrorCronExpression;
        CronTrigger trigger = TriggerBuilder.newTrigger()
                .withIdentity(jobName+"Trigger", Scheduler.DEFAULT_GROUP)
                .withSchedule(CronScheduleBuilder.cronSchedule(cronExpression))
                .build();
        scheduler.startDelayed(0);
        scheduler.scheduleJob(job, trigger);
        log.debug("Schedule set "+cronExpression);
    }
    catch (Exception e)
    {
        log.error("Error scheduling "+e.getMessage());
    }
}
 
Example 12
/**
 * 创建定时任务
 */
public static void createScheduleJob(Scheduler scheduler, Job job)
{
    try
    {
        // 构建job信息
        JobDetail jobDetail = JobBuilder.newJob(ScheduleJob.class).withIdentity(getJobKey(job.getJobId())).build();

        // 表达式调度构建器
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
        cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder);

        // 按新的cronExpression表达式构建一个新的trigger
        CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(job.getJobId())).withSchedule(cronScheduleBuilder).build();

        // 放入参数,运行时的方法可以获取
        jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job);

        scheduler.scheduleJob(jobDetail, trigger);

        // 暂停任务
        if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue()))
        {
            pauseJob(scheduler, job.getJobId());
        }
    }
    catch (SchedulerException | TaskException e)
    {
        log.error("createScheduleJob 异常:", e);
    }
}
 
Example 13
public ScheduleLogRequest(JobExecutionContext jobExecutionContext, JobExecutionException jobExecutionException) {
	JobDetail jobDetail = jobExecutionContext.getJobDetail();
	this.className = jobDetail.getKey().getName();
	this.application = jobDetail.getKey().getGroup();
	this.node = jobDetail.getDescription();
	this.type = jobExecutionContext.getTrigger().getDescription();
	this.elapsed = jobExecutionContext.getJobRunTime();
	this.fireTime = jobExecutionContext.getFireTime();
	if (null != jobExecutionException) {
		this.stackTrace = ExceptionUtils.getStackTrace(jobExecutionException);
		this.success = false;
	} else {
		this.success = true;
	}
}
 
Example 14
Source Project: redis-quartz   Source File: RedisJobStore.java    License: MIT License 5 votes vote down vote up
@Override
public JobDetail retrieveJob(JobKey jobKey) throws JobPersistenceException {
	JobDetail jobDetail = null;
	String jobHashkey = createJobHashKey(jobKey.getGroup(), jobKey.getName());
     try (Jedis jedis = pool.getResource()) {
        lockPool.acquire();
		jobDetail = retrieveJob(jobKey, jedis);			
     } catch (JobPersistenceException | ClassNotFoundException | InterruptedException ex) {
		log.error("could not retrieve job: " + jobHashkey, ex);
		throw new JobPersistenceException(ex.getMessage(), ex.getCause());
	} finally {
        lockPool.release();
	}
	return jobDetail;
}
 
Example 15
@Override
    public JobDetail createJobDetails() {
        return JobBuilder.newJob(CacheUpdateJob.class)
                .withIdentity(getJobName())
                .withDescription(getJobDescription())
//                .usingJobData(REWRITE_AT_STARTUP, rewriteAtStartup)
                .build();
    }
 
Example 16
Source Project: lams   Source File: RemoteScheduler.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>
 * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
 * </p>
 */
public JobDetail getJobDetail(JobKey jobKey)
    throws SchedulerException {
    try {
        return getRemoteScheduler().getJobDetail(jobKey);
    } catch (RemoteException re) {
        throw invalidateHandleCreateException(
                "Error communicating with remote scheduler.", re);
    }
}
 
Example 17
Source Project: nextreports-server   Source File: DefaultReportService.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional(readOnly = true)
public void runMonitorReport(JobDetail jobDetail) {
	try {
		quartzJobHandler.runMonitorJob(jobDetail);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 18
Source Project: nexus-public   Source File: QuartzTaskUtils.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Saves {@link TaskConfiguration} back to the given {@link JobDetail}.
 */
public static void updateJobData(final JobDetail jobDetail, final TaskConfiguration taskConfiguration) {
  JobDataMap jobDataMap = jobDetail.getJobDataMap();
  taskConfiguration.asMap().forEach((key, value) -> {
    if (!value.equals(jobDataMap.get(key))) {
      jobDataMap.put(key, value); // only touch jobDataMap if value actually changed
    }
  });
}
 
Example 19
Source Project: smarthome   Source File: RuleTriggerManager.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates and schedules a new quartz-job and trigger with model and rule name as jobData.
 *
 * @param rule the rule to schedule
 * @param trigger the defined trigger
 *
 * @throws SchedulerException if there is an internal Scheduler error.
 */
private void createTimer(Rule rule, TimerTrigger trigger) throws SchedulerException {
    String cronExpression = trigger.getCron();
    if (trigger.getTime() != null) {
        if (trigger.getTime().equals("noon")) {
            cronExpression = "0 0 12 * * ?";
        } else if (trigger.getTime().equals("midnight")) {
            cronExpression = "0 0 0 * * ?";
        } else {
            logger.warn("Unrecognized time expression '{}' in rule '{}'", trigger.getTime(), rule.getName());
            return;
        }
    }

    String jobIdentity = getJobIdentityString(rule, trigger);

    try {
        JobDetail job = newJob(ExecuteRuleJob.class)
                .usingJobData(ExecuteRuleJob.JOB_DATA_RULEMODEL, rule.eResource().getURI().path())
                .usingJobData(ExecuteRuleJob.JOB_DATA_RULENAME, rule.getName()).withIdentity(jobIdentity).build();
        Trigger quartzTrigger = newTrigger().withSchedule(CronScheduleBuilder.cronSchedule(cronExpression)).build();
        scheduler.scheduleJob(job, Collections.singleton(quartzTrigger), true);

        logger.debug("Scheduled rule '{}' with cron expression '{}'", rule.getName(), cronExpression);
    } catch (RuntimeException e) {
        throw new SchedulerException(e.getMessage());
    }
}
 
Example 20
Source Project: sunbird-lms-service   Source File: SchedulerManager.java    License: MIT License 5 votes vote down vote up
public static void scheduleChannelReg(String identifier) {
  // add another job for registering channel to ekstep.
  // 1- create a job and bind with class which is implementing Job
  // interface.
  JobDetail channelRegistrationJob =
      JobBuilder.newJob(ChannelRegistrationScheduler.class)
          .requestRecovery(true)
          .withDescription("Scheduler for channel registration")
          .withIdentity("channelRegistrationScheduler", identifier)
          .build();

  // 2- Create a trigger object that will define frequency of run.
  // It will run only once after server startup
  Trigger channelRegistrationTrigger =
      TriggerBuilder.newTrigger()
          .withIdentity("channelRegistrationScheduler", identifier)
          .withSchedule(SimpleScheduleBuilder.repeatMinutelyForTotalCount(1))
          .build();
  try {
    if (scheduler.checkExists(channelRegistrationJob.getKey())) {
      scheduler.deleteJob(channelRegistrationJob.getKey());
    }
    scheduler.scheduleJob(channelRegistrationJob, channelRegistrationTrigger);
    scheduler.start();
    ProjectLogger.log(
        "SchedulerManager:scheduleChannelReg: channelRegistration schedular started",
        LoggerEnum.INFO.name());
  } catch (Exception e) {
    ProjectLogger.log(e.getMessage(), e);
  }
}
 
Example 21
Source Project: springbootexamples   Source File: CronSchedulerJobManger.java    License: Apache License 2.0 5 votes vote down vote up
private void scheduleJob2(Scheduler scheduler) throws SchedulerException{
    JobDetail jobDetail = JobBuilder.newJob(CronJob2.class) .withIdentity("job2", "group2")
    		.usingJobData("serviceCode","Live lesson reminder2").build();
    CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("0/10 * * * * ?");
    CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity("trigger2", "group2") .withSchedule(scheduleBuilder).build();
    scheduler.scheduleJob(jobDetail,cronTrigger);  
}
 
Example 22
Source Project: roboconf-platform   Source File: RoboconfSchedulerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test( expected = IOException.class )
public void testSaveJob_exception() throws Exception {

	this.scheduler.scheduler = Mockito.mock( Scheduler.class );
	Mockito.when( this.scheduler.scheduler.scheduleJob(
			Mockito.any( JobDetail.class ),
			Mockito.any( Trigger.class ))).thenThrow( new SchedulerException( "For test" ));

	this.scheduler.saveJob( null, "job", "cmd", "0 0 0 ? 1 *", "app" );
}
 
Example 23
Source Project: AsuraFramework   Source File: StdJDBCDelegate.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * Update the job detail record.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param job
 *          the job to update
 * @return number of rows updated
 * @throws IOException
 *           if there were problems serializing the JobDataMap
 */
public int updateJobDetail(Connection conn, JobDetail job)
    throws IOException, SQLException {
    ByteArrayOutputStream baos = serializeJobData(job.getJobDataMap());

    PreparedStatement ps = null;

    int insertResult = 0;

    try {
        ps = conn.prepareStatement(rtp(UPDATE_JOB_DETAIL));
        ps.setString(1, job.getDescription());
        ps.setString(2, job.getJobClass().getName());
        setBoolean(ps, 3, job.isDurable());
        setBoolean(ps, 4, job.isVolatile());
        setBoolean(ps, 5, job.isStateful());
        setBoolean(ps, 6, job.requestsRecovery());
        setBytes(ps, 7, baos);
        ps.setString(8, job.getName());
        ps.setString(9, job.getGroup());

        insertResult = ps.executeUpdate();
    } finally {
        closeStatement(ps);
    }

    if (insertResult > 0) {
        deleteJobListeners(conn, job.getName(), job.getGroup());

        String[] jobListeners = job.getJobListenerNames();
        for (int i = 0; jobListeners != null && i < jobListeners.length; i++) {
            insertJobListener(conn, job, jobListeners[i]);
        }
    }

    return insertResult;
}
 
Example 24
Source Project: centraldogma   Source File: FileBasedSessionManager.java    License: Apache License 2.0 5 votes vote down vote up
private Scheduler createScheduler(String cronExpr) throws SchedulerException {
    // The scheduler can be started and stopped several times in JUnit tests, but Quartz holds
    // every scheduler instances in a singleton SchedulerRepository. So it's possible to pick up
    // the scheduler which is going to be stopped if we use the same instance name for every scheduler,
    // because CentralDogmaExtension stops the server asynchronously using another thread.
    final String myInstanceId = String.valueOf(hashCode());

    final Properties cfg = new Properties();
    cfg.setProperty("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore");
    cfg.setProperty("org.quartz.scheduler.instanceName",
                    FileBasedSessionManager.class.getSimpleName() + '@' + myInstanceId);
    cfg.setProperty("org.quartz.scheduler.skipUpdateCheck", "true");
    cfg.setProperty("org.quartz.threadPool.threadCount", "1");

    final Scheduler scheduler = new StdSchedulerFactory(cfg).getScheduler();

    final JobDetail job = newJob(ExpiredSessionDeletingJob.class)
            .usingJobData(newJobDataMap(ImmutableMap.of(ROOT_DIR, rootDir)))
            .build();

    final Trigger trigger = newTrigger()
            .withIdentity(myInstanceId, ExpiredSessionDeletingJob.class.getSimpleName())
            .withSchedule(cronSchedule(cronExpr))
            .build();

    scheduler.scheduleJob(job, trigger);
    return scheduler;
}
 
Example 25
Source Project: lams   Source File: RemoteMBeanScheduler.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>
 * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
 * passing the <code>SchedulingContext</code> associated with this
 * instance.
 * </p>
 */
public void addJob(JobDetail jobDetail, boolean replace, boolean storeNonDurableWhileAwaitingScheduling)
        throws SchedulerException {
    invoke(
            "addJob",
            new Object[] { JobDetailSupport.toCompositeData(jobDetail), replace , storeNonDurableWhileAwaitingScheduling},
            new String[] { CompositeData.class.getName(), boolean.class.getName(), boolean.class.getName() });
}
 
Example 26
Source Project: griffin   Source File: SparkSubmitJob.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void execute(JobExecutionContext context) {
    JobDetail jd = context.getJobDetail();
    try {
        if (isNeedLivyQueue) {
            //livy batch limit
            livyTaskSubmitHelper.addTaskToWaitingQueue(jd);
        } else {
            saveJobInstance(jd);
        }
    } catch (Exception e) {
        LOGGER.error("Post spark task ERROR.", e);
    }
}
 
Example 27
Source Project: lams   Source File: JobStoreSupport.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>
 * Inform the <code>JobStore</code> that the scheduler has completed the
 * firing of the given <code>Trigger</code> (and the execution its
 * associated <code>Job</code>), and that the <code>{@link org.quartz.JobDataMap}</code>
 * in the given <code>JobDetail</code> should be updated if the <code>Job</code>
 * is stateful.
 * </p>
 */
public void triggeredJobComplete(final OperableTrigger trigger,
        final JobDetail jobDetail, final CompletedExecutionInstruction triggerInstCode) {
    retryExecuteInNonManagedTXLock(
        LOCK_TRIGGER_ACCESS,
        new VoidTransactionCallback() {
            public void executeVoid(Connection conn) throws JobPersistenceException {
                triggeredJobComplete(conn, trigger, jobDetail,triggerInstCode);
            }
        });    
}
 
Example 28
void verifyJobDetails(JobDetail job) {
    await().untilAsserted(() -> assertThat(reporter.getTransactions().size()).isEqualTo(1));
    assertThat(reporter.getTransactions().get(0).getType()).isEqualToIgnoringCase("scheduled");
    assertThat(reporter.getTransactions().get(0).getNameAsString())
        .isEqualToIgnoringCase(String.format("%s.%s", job.getKey().getGroup(), job.getKey().getName()));
    assertThat(reporter.getTransactions().get(0).getFrameworkName()).isEqualTo("Quartz");
    assertThat(reporter.getTransactions().get(0).getFrameworkVersion()).isEqualTo("2.3.1");
}
 
Example 29
/**
 * Gets the job list.
 * 
 * @return the job list
 */
public String getJobList() {
	String xml = "";
	try {
		Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); 
		List toReturn = new ArrayList();
		String[] groups = scheduler.getJobGroupNames();
		if (groups == null || groups.length == 0) {
			SpagoBITracer.warning(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), 
					              "getJobList", "No job groups defined!");
		} else {
			for (int i = 0; i < groups.length; i++) {
				String group = groups[i];
				String[] jobNames = scheduler.getJobNames(group);
				if (jobNames == null || jobNames.length == 0) {
					SpagoBITracer.warning(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), 
							              "getJobList", "No job defined for group " + group + "!");
				} else {
					for (int j = 0; j < jobNames.length; j++) {
						JobDetail aJob = scheduler.getJobDetail(jobNames[j], group);
						toReturn.add(aJob);
					}
				}
			}
		}
		xml = buildJobListXmlString(toReturn);
	} catch (Exception e) {
		SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), 
	              			"getJobList", "Error while recovering job list");
		xml = "<ROWS></ROWS>";
	}
	return xml;
}
 
Example 30
public TabularData getAllJobDetails() throws Exception {
    try {
        List<JobDetail> detailList = new ArrayList<JobDetail>();
        for (String jobGroupName : scheduler.getJobGroupNames()) {
            for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(jobGroupName))) {
                detailList.add(scheduler.getJobDetail(jobKey));
            }
        }
        return JobDetailSupport.toTabularData(detailList.toArray(new JobDetail[detailList.size()]));
    } catch (Exception e) {
        throw newPlainException(e);
    }
}