use of com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener in project elastic-job by dangdangdotcom.
the class LiteJobFacadeTest method setUp.
@Before
public void setUp() throws NoSuchFieldException {
MockitoAnnotations.initMocks(this);
liteJobFacade = new LiteJobFacade(null, "test_job", Collections.<ElasticJobListener>singletonList(new TestElasticJobListener(caller)), eventBus);
ReflectionUtils.setFieldValue(liteJobFacade, "configService", configService);
ReflectionUtils.setFieldValue(liteJobFacade, "serverService", serverService);
ReflectionUtils.setFieldValue(liteJobFacade, "shardingService", shardingService);
ReflectionUtils.setFieldValue(liteJobFacade, "executionContextService", executionContextService);
ReflectionUtils.setFieldValue(liteJobFacade, "executionService", executionService);
ReflectionUtils.setFieldValue(liteJobFacade, "failoverService", failoverService);
}
use of com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener in project elastic-job by dangdangdotcom.
the class SchedulerFacadeTest method setUp.
@Before
public void setUp() throws NoSuchFieldException {
MockitoAnnotations.initMocks(this);
schedulerFacade = new SchedulerFacade(null, "test_job", Collections.<ElasticJobListener>emptyList());
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), false)).build());
ReflectionUtils.setFieldValue(schedulerFacade, "configService", configService);
ReflectionUtils.setFieldValue(schedulerFacade, "leaderElectionService", leaderElectionService);
ReflectionUtils.setFieldValue(schedulerFacade, "serverService", serverService);
ReflectionUtils.setFieldValue(schedulerFacade, "shardingService", shardingService);
ReflectionUtils.setFieldValue(schedulerFacade, "executionService", executionService);
ReflectionUtils.setFieldValue(schedulerFacade, "monitorService", monitorService);
ReflectionUtils.setFieldValue(schedulerFacade, "listenerManager", listenerManager);
}
use of com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener in project loc-framework by lord-of-code.
the class LocElasticJobAutoConfiguration method createBean.
private void createBean(ZookeeperRegistryCenter registryCenter, @Nullable JobEventConfiguration jobEventConfiguration, String[] jobs) {
if (ArrayUtils.isNotEmpty(jobs)) {
Arrays.stream(jobs).forEach(job -> {
try {
ElasticJob elasticJob = this.applicationContext.getBean(job, ElasticJob.class);
LocElasticJob locElasticJob = elasticJob.getClass().getAnnotation(LocElasticJob.class);
LiteJobConfiguration liteJobConfiguration;
if (elasticJob instanceof SimpleJob) {
liteJobConfiguration = createSimpleJobLiteJobConfiguration(elasticJob, locElasticJob);
} else if (elasticJob instanceof DataflowJob) {
liteJobConfiguration = createDataFlowJobConfiguration(elasticJob, locElasticJob);
} else if (elasticJob instanceof ScriptJob) {
liteJobConfiguration = createScriptJobConfiguration(elasticJob, locElasticJob);
} else {
throw new IllegalArgumentException("error elasticJob type");
}
Preconditions.checkNotNull(liteJobConfiguration, "liteJobConfiguration不能为空");
ElasticJobListener[] elasticJobListeners = getElasticJobListeners(locElasticJob.elasticJobListeners());
List<Object> argList = Lists.newArrayList();
if (elasticJob instanceof ScriptJob) {
argList.add(null);
} else {
argList.add(elasticJob);
}
argList.add(registryCenter);
argList.add(liteJobConfiguration);
Optional.ofNullable(jobEventConfiguration).ifPresent(argList::add);
argList.add(elasticJobListeners);
createSpringJobScheduler(elasticJob.getClass().getSimpleName() + "JobScheduler", argList);
} catch (Exception e) {
throw Throwables.propagate(e);
}
});
}
}
Aggregations