Elastic-Job-Lite分析——作业调度器 JobScheduler 的创建过程

-----------------------------------1. 创建注册中心的对象-------------------------------------------------------------
ZookeeperConfiguration zkConfig = new ZookeeperConfiguration(ZOOKEEPER_CONNECTION_STRING, JOB_NAMESPACE);
CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(zkConfig);
regCenter.init();
-----------------------------------2. 作业事件配置--------------------------------------------------------------------
BasicDataSource dataSource = new BasicDataSource(); //创建数据源
................... //数据源的设置
//作业数据库事件配置
JobEventConfiguration jobEventConfig = new JobEventRdbConfiguration(dataSource);
 
 
 
------------------------------------3.创建作业核心配置--------------------------------------------------------------
//创建简单作业配置构建器.
JobCoreConfiguration.Builder builder = JobCoreConfiguration.newBuilder("javaSimpleJob", "0/5 * * * * ?", 3) ;
//设置分片参数
builder.shardingItemParameters("0=Beijing,1=Shanghai,2=Guangzhou") ;
 
//创建作业核心配置
JobCoreConfiguration coreConfig = builder.build() ;
 
------------------------------------4.创建作业类型配置-------------------------------------------------------------
//创建作业类型配置
SimpleJobConfiguration simpleJobConfig = new SimpleJobConfiguration(coreConfig, JavaSimpleJob.class.getCanonicalName());
 
------------------------------------5.创建 Lite作业配置---------------------------------------------------------------
LiteJobConfiguration.Builder jobBuilder = LiteJobConfiguration.newBuilder(simpleJobConfig) ;
LiteJobConfiguration liteJobConfiguration jobBuilder.build() ;
 
-----------------------------------6.创建调度器-----------------------------------------------------------------------
JobScheduler jobScheduler = new JobScheduler(regCenter, liteJobConfiguration , jobEventConfig) ;
 
-----------------------------------7.启动调度器----------------------------------------------------------------------
上一篇:HDU 3092 Least common multiple 01背包


下一篇:Spring Boot+MyBabits静态连接多个数据库