Search in sources :

Example 1 with JobSystemException

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

the class AopTargetUtils method getTargetObject.

private static Object getTargetObject(final Object object) {
    try {
        Field advised = object.getClass().getDeclaredField("advised");
        advised.setAccessible(true);
        return ((AdvisedSupport) advised.get(object)).getTargetSource().getTarget();
    // CHECKSTYLE:OFF
    } catch (final Exception ex) {
        // CHECKSTYLE:ON
        throw new JobSystemException(ex);
    }
}
Also used : Field(java.lang.reflect.Field) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException)

Example 2 with JobSystemException

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

the class AopTargetUtils method getProxyTargetObject.

private static Object getProxyTargetObject(final Object proxy, final String proxyType) {
    Field h;
    try {
        h = proxy.getClass().getSuperclass().getDeclaredField(proxyType);
    } catch (final NoSuchFieldException ex) {
        return getProxyTargetObjectForCglibAndSpring4(proxy);
    }
    h.setAccessible(true);
    try {
        return getTargetObject(h.get(proxy));
    } catch (final IllegalAccessException ex) {
        throw new JobSystemException(ex);
    }
}
Also used : Field(java.lang.reflect.Field) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException)

Example 3 with JobSystemException

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

the class TransientProducerScheduler method deregister.

void deregister(final CloudJobConfiguration jobConfig) {
    repository.remove(jobConfig.getJobName());
    String cron = jobConfig.getTypeConfig().getCoreConfig().getCron();
    if (!repository.containsKey(buildJobKey(cron))) {
        try {
            scheduler.unscheduleJob(TriggerKey.triggerKey(cron));
        } catch (final SchedulerException ex) {
            throw new JobSystemException(ex);
        }
    }
}
Also used : SchedulerException(org.quartz.SchedulerException) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException)

Example 4 with JobSystemException

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

the class TaskExecutorThreadTest method assertLaunchTaskWithWrongElasticJobClass.

@Test
public void assertLaunchTaskWithWrongElasticJobClass() {
    TaskInfo taskInfo = buildWrongElasticJobClass();
    TaskThread taskThread = new TaskExecutor().new TaskThread(executorDriver, taskInfo);
    try {
        taskThread.run();
    } catch (final JobSystemException ex) {
        assertTrue(ex.getMessage().startsWith("Elastic-Job: Class 'com.dangdang.ddframe.job.cloud.executor.TaskExecutorThreadTest' must implements ElasticJob interface."));
    }
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) TaskThread(com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException) Test(org.junit.Test)

Example 5 with JobSystemException

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

the class TransientProducerScheduler method register.

// TODO 并发优化
synchronized void register(final CloudJobConfiguration jobConfig) {
    String cron = jobConfig.getTypeConfig().getCoreConfig().getCron();
    JobKey jobKey = buildJobKey(cron);
    repository.put(jobKey, jobConfig.getJobName());
    try {
        if (!scheduler.checkExists(jobKey)) {
            scheduler.scheduleJob(buildJobDetail(jobKey), buildTrigger(jobKey.getName()));
        }
    } catch (final SchedulerException ex) {
        throw new JobSystemException(ex);
    }
}
Also used : JobKey(org.quartz.JobKey) SchedulerException(org.quartz.SchedulerException) 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