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);
}
}
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);
}
}
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);
}
}
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;
}
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);
}
}
Aggregations