Search in sources :

Example 1 with JobScheduleController

use of com.dangdang.ddframe.job.lite.internal.schedule.JobScheduleController in project elastic-job by dangdangdotcom.

the class JobScheduler method init.

/**
     * 初始化作业.
     */
public void init() {
    jobExecutor.init();
    JobTypeConfiguration jobTypeConfig = jobExecutor.getSchedulerFacade().loadJobConfiguration().getTypeConfig();
    JobScheduleController jobScheduleController = new JobScheduleController(createScheduler(jobTypeConfig.getCoreConfig().isMisfire()), createJobDetail(jobTypeConfig.getJobClass()), jobExecutor.getSchedulerFacade(), jobName);
    jobScheduleController.scheduleJob(jobTypeConfig.getCoreConfig().getCron());
    jobRegistry.addJobScheduleController(jobName, jobScheduleController);
}
Also used : JobScheduleController(com.dangdang.ddframe.job.lite.internal.schedule.JobScheduleController) JobTypeConfiguration(com.dangdang.ddframe.job.config.JobTypeConfiguration)

Example 2 with JobScheduleController

use of com.dangdang.ddframe.job.lite.internal.schedule.JobScheduleController in project elastic-job by dangdangdotcom.

the class ExecutionService method registerJobBegin.

/**
     * 注册作业启动信息.
     * 
     * @param shardingContexts 分片上下文
     */
public void registerJobBegin(final ShardingContexts shardingContexts) {
    if (!shardingContexts.getShardingItemParameters().isEmpty() && configService.load(true).isMonitorExecution()) {
        serverService.updateServerStatus(ServerStatus.RUNNING);
        for (int each : shardingContexts.getShardingItemParameters().keySet()) {
            jobNodeStorage.fillEphemeralJobNode(ExecutionNode.getRunningNode(each), "");
            jobNodeStorage.replaceJobNode(ExecutionNode.getLastBeginTimeNode(each), System.currentTimeMillis());
            JobScheduleController jobScheduleController = JobRegistry.getInstance().getJobScheduleController(jobName);
            if (null == jobScheduleController) {
                continue;
            }
            Date nextFireTime = jobScheduleController.getNextFireTime();
            if (null != nextFireTime) {
                jobNodeStorage.replaceJobNode(ExecutionNode.getNextFireTimeNode(each), nextFireTime.getTime());
            }
        }
    }
}
Also used : JobScheduleController(com.dangdang.ddframe.job.lite.internal.schedule.JobScheduleController) Date(java.util.Date)

Example 3 with JobScheduleController

use of com.dangdang.ddframe.job.lite.internal.schedule.JobScheduleController in project elastic-job by dangdangdotcom.

the class AbstractBaseStdJobTest method tearDown.

@After
public void tearDown() throws SchedulerException, NoSuchFieldException {
    JobScheduleController jobScheduleController = JobRegistry.getInstance().getJobScheduleController(jobName);
    if (null != jobScheduleController) {
        JobRegistry.getInstance().getJobScheduleController(jobName).shutdown();
    }
    ReflectionUtils.setFieldValue(JobRegistry.getInstance(), "instance", null);
}
Also used : JobScheduleController(com.dangdang.ddframe.job.lite.internal.schedule.JobScheduleController) After(org.junit.After)

Aggregations

JobScheduleController (com.dangdang.ddframe.job.lite.internal.schedule.JobScheduleController)3 JobTypeConfiguration (com.dangdang.ddframe.job.config.JobTypeConfiguration)1 Date (java.util.Date)1 After (org.junit.After)1