Search in sources :

Example 6 with JobSystemException

use of com.dangdang.ddframe.job.exception.JobSystemException in project elastic-job by dangdangdotcom.

the class SchedulerElectionCandidate method startLeadership.

@Override
public void startLeadership() throws Exception {
    try {
        schedulerService = new SchedulerService(regCenter);
        schedulerService.start();
    //CHECKSTYLE:OFF
    } catch (final Throwable throwable) {
        throw new JobSystemException(throwable);
    }
}
Also used : SchedulerService(com.dangdang.ddframe.job.cloud.scheduler.mesos.SchedulerService) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException)

Example 7 with JobSystemException

use of com.dangdang.ddframe.job.exception.JobSystemException in project elastic-job by dangdangdotcom.

the class DaemonTaskScheduler method scheduleJob.

private void scheduleJob(final Scheduler scheduler, final JobDetail jobDetail, final String triggerIdentity, final String cron) {
    try {
        if (!scheduler.checkExists(jobDetail.getKey())) {
            scheduler.scheduleJob(jobDetail, createTrigger(triggerIdentity, cron));
        }
        scheduler.start();
        RUNNING_SCHEDULERS.putIfAbsent(scheduler.getSchedulerName(), scheduler);
    } catch (final SchedulerException ex) {
        throw new JobSystemException(ex);
    }
}
Also used : SchedulerException(org.quartz.SchedulerException) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException)

Example 8 with JobSystemException

use of com.dangdang.ddframe.job.exception.JobSystemException in project elastic-job by dangdangdotcom.

the class DaemonTaskScheduler method init.

/**
     * 初始化作业.
     */
public void init() {
    JobDetail jobDetail = JobBuilder.newJob(DaemonJob.class).withIdentity(jobRootConfig.getTypeConfig().getCoreConfig().getJobName()).build();
    jobDetail.getJobDataMap().put(ELASTIC_JOB_DATA_MAP_KEY, elasticJob);
    jobDetail.getJobDataMap().put(JOB_FACADE_DATA_MAP_KEY, jobFacade);
    jobDetail.getJobDataMap().put(EXECUTOR_DRIVER_DATA_MAP_KEY, executorDriver);
    jobDetail.getJobDataMap().put(TASK_ID_DATA_MAP_KEY, taskId);
    try {
        scheduleJob(initializeScheduler(), jobDetail, taskId.getValue(), jobRootConfig.getTypeConfig().getCoreConfig().getCron());
    } catch (final SchedulerException ex) {
        throw new JobSystemException(ex);
    }
}
Also used : JobDetail(org.quartz.JobDetail) SchedulerException(org.quartz.SchedulerException) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException)

Example 9 with JobSystemException

use of com.dangdang.ddframe.job.exception.JobSystemException in project elastic-job by dangdangdotcom.

the class JobScheduler method createScheduler.

private Scheduler createScheduler(final boolean isMisfire) {
    Scheduler result;
    try {
        StdSchedulerFactory factory = new StdSchedulerFactory();
        factory.initialize(getBaseQuartzProperties(isMisfire));
        result = factory.getScheduler();
        result.getListenerManager().addTriggerListener(jobExecutor.getSchedulerFacade().newJobTriggerListener());
    } catch (final SchedulerException ex) {
        throw new JobSystemException(ex);
    }
    return result;
}
Also used : StdSchedulerFactory(org.quartz.impl.StdSchedulerFactory) SchedulerException(org.quartz.SchedulerException) Scheduler(org.quartz.Scheduler) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException)

Example 10 with JobSystemException

use of com.dangdang.ddframe.job.exception.JobSystemException in project elastic-job by dangdangdotcom.

the class Encryption method md5.

/**
     * 采用MD5算法加密字符串.
     * 
     * @param str 需要加密的字符串
     * @return 加密后的字符串
     */
public static String md5(final String str) {
    try {
        MessageDigest messageDigest = MessageDigest.getInstance(MD5);
        messageDigest.update(str.getBytes());
        return new BigInteger(1, messageDigest.digest()).toString(16);
    } catch (final NoSuchAlgorithmException ex) {
        throw new JobSystemException(ex);
    }
}
Also used : BigInteger(java.math.BigInteger) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) MessageDigest(java.security.MessageDigest) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException)

Aggregations

JobSystemException (com.dangdang.ddframe.job.exception.JobSystemException)12 SchedulerException (org.quartz.SchedulerException)5 Field (java.lang.reflect.Field)3 TaskThread (com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread)2 TaskInfo (org.apache.mesos.Protos.TaskInfo)2 Test (org.junit.Test)2 SchedulerService (com.dangdang.ddframe.job.cloud.scheduler.mesos.SchedulerService)1 BigInteger (java.math.BigInteger)1 MessageDigest (java.security.MessageDigest)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 JobDetail (org.quartz.JobDetail)1 JobKey (org.quartz.JobKey)1 Scheduler (org.quartz.Scheduler)1 StdSchedulerFactory (org.quartz.impl.StdSchedulerFactory)1