🙂🙂🙂关注**微信公众号:【芋艿的后端小屋】**有福利:
- RocketMQ / MyCAT / Sharding-JDBC 所有源码分析文章列表
- RocketMQ / MyCAT / Sharding-JDBC 中文注释源码 GitHub 地址
- 您对于源码的疑问每条留言都将得到认真回复。甚至不知道如何读源码也可以请教噢。
- 新的源码解析文章实时收到通知。每周更新一篇左右。
-
调度作业中间件 Elastic-Job-Lite
- 《Elastic-Job 源码分析 —— 为什么阅读 Elastic-Job 源码?》
- 《Elastic-Job-Lite 源码分析 —— 作业配置》
- 《Elastic-Job-Lite 源码分析 —— 作业初始化》
- 《Elastic-Job-Lite 源码分析 —— 作业执行》
- 《Elastic-Job-Lite 源码分析 —— 注册中心》
- 《Elastic-Job-Lite 源码分析 —— 作业数据存储》
- 《Elastic-Job-Lite 源码分析 —— 注册中心监听器》
- 《Elastic-Job-Lite 源码分析 —— 主节点选举》
- 《Elastic-Job-Lite 源码分析 —— 作业分片策略》
- 《Elastic-Job-Lite 源码分析 —— 作业分片》
- 《Elastic-Job-Lite 源码分析 —— 作业失效转移》
- 《Elastic-Job-Lite 源码分析 —— 作业事件追踪》
- 《Elastic-Job-Lite 源码分析 —— 作业监听器》
- 《Elastic-Job-Lite 源码分析 —— 自诊断修复》
- 《Elastic-Job-Lite 源码分析 —— 作业监控服务》
- 《Elastic-Job-Lite 源码分析 —— 运维平台》
-
调度作业中间件 Elastic-Job-Cloud
Elastic-Job is a distributed scheduled job solution. Elastic-Job is composited from 2 independent sub projects: Elastic-Job-Lite and Elastic-Job-Cloud.
Elastic-Job-Lite is a centre-less solution, use lightweight jar to coordinate distributed jobs. Elastic-Job-Cloud is a Mesos framework which use Mesos + Docker(todo) to manage and isolate resources and processes.
Elastic-Job-Lite and Elastic-Job-Cloud provide unified API. Developers only need code one time, then decide to deploy Lite or Cloud as you want.
- Distributed schedule job coordinate
- Elastic scale in and scale out supported
- Failover
- Misfired jobs refire
- Sharding consistently, same sharding item for a job only one running instance
- Self diagnose and recover when distribute environment unstable
- Parallel scheduling supported
- Job lifecycle operation
- Lavish job types
- Spring integrated and namespace supported
- Web console
- All Elastic-Job-Lite features included
- Application distributed automatically
- Fenzo based resources allocated elastically
- Docker based processes isolation support (TBD)
<!-- import elastic-job lite core -->
<dependency>
<groupId>com.dangdang</groupId>
<artifactId>elastic-job-lite-core</artifactId>
<version>${lasted.release.version}</version>
</dependency>
<!-- import other module if need -->
<dependency>
<groupId>com.dangdang</groupId>
<artifactId>elastic-job-lite-spring</artifactId>
<version>${lasted.release.version}</version>
</dependency>
public class MyElasticJob implements SimpleJob {
@Override
public void execute(ShardingContext context) {
switch (context.getShardingItem()) {
case 0:
// do something by sharding item 0
break;
case 1:
// do something by sharding item 1
break;
case 2:
// do something by sharding item 2
break;
// case n: ...
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:reg="http://www.dangdang.com/schema/ddframe/reg"
xmlns:job="http://www.dangdang.com/schema/ddframe/job"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.dangdang.com/schema/ddframe/reg
http://www.dangdang.com/schema/ddframe/reg/reg.xsd
http://www.dangdang.com/schema/ddframe/job
http://www.dangdang.com/schema/ddframe/job/job.xsd
">
<!--configure registry center -->
<reg:zookeeper id="regCenter" server-lists="yourhost:2181" namespace="dd-job" base-sleep-time-milliseconds="1000" max-sleep-time-milliseconds="3000" max-retries="3" />
<!--configure job -->
<job:simple id="myElasticJob" class="xxx.MyElasticJob" registry-center-ref="regCenter" cron="0/10 * * * * ?" sharding-total-count="3" sharding-item-parameters="0=A,1=B,2=C" />
</beans>
<!-- import elastic-job cloud executor -->
<dependency>
<groupId>com.dangdang</groupId>
<artifactId>elastic-job-cloud-executor</artifactId>
<version>${lasted.release.version}</version>
</dependency>
Same with Elastic-Job-Lite
curl -l -H "Content-type: application/json" -X POST -d '{"appName":"yourAppName","appURL":"http://app_host:8080/foo-job.tar.gz","cpuCount":0.1,"memoryMB":64.0,"bootstrapScript":"bin/start.sh","appCacheEnable":true}' http://elastic_job_cloud_host:8899/api/app
curl -l -H "Content-type: application/json" -X POST -d '{"jobName":"foo_job","appName":"yourAppName","jobClass":"yourJobClass","jobType":"SIMPLE","jobExecutionType":"TRANSIENT","cron":"0/5 * * * * ?","shardingTotalCount":5,"cpuCount":0.1,"memoryMB":64.0,"failover":true,"misfire":true,"bootstrapScript":"bin/start.sh"}' http://elastic_job_cloud_host:8899/api/job/register