# elastic-job
**Repository Path**: java20150326/elastic-job
## Basic Information
- **Project Name**: elastic-job
- **Description**: Elastic-Job是一个分布式调度解决方案,由两个相互独立的子项目Elastic-Job-Lite和Elastic-Job-Cloud组成。
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 610
- **Created**: 2018-03-20
- **Last Updated**: 2021-11-02
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Elastic-Job - 分布式作业调度解决方案
[](https://travis-ci.org/elasticjob/elastic-job)
[](https://maven-badges.herokuapp.com/maven-central/com.dangdang/elastic-job)
[](https://coveralls.io/github/elasticjob/elastic-job?branch=master)
[](https://github.com/elasticjob/elastic-job/releases)
[](https://www.apache.org/licenses/LICENSE-2.0.html)
# 概述
Elastic-Job是一个分布式调度解决方案,由两个相互独立的子项目Elastic-Job-Lite和Elastic-Job-Cloud组成。
Elastic-Job-Lite定位为轻量级无中心化解决方案,使用jar包的形式提供分布式任务的协调服务。
Elastic-Job-Cloud使用Mesos + Docker的解决方案,额外提供资源治理、应用分发以及进程隔离等服务。
# 功能列表
## 1. Elastic-Job-Lite
* 分布式调度协调
* 弹性扩容缩容
* 失效转移
* 错过执行作业重触发
* 作业分片一致性,保证同一分片在分布式环境中仅一个执行实例
* 自诊断并修复分布式不稳定造成的问题
* 支持并行调度
* 支持作业生命周期操作
* 丰富的作业类型
* Spring整合以及命名空间提供
* 运维平台
## 2. Elastic-Job-Cloud
* 应用自动分发
* 基于Fenzo的弹性资源分配
* 分布式调度协调
* 弹性扩容缩容
* 失效转移
* 错过执行作业重触发
* 作业分片一致性,保证同一分片在分布式环境中仅一个执行实例
* 支持并行调度
* 支持作业生命周期操作
* 丰富的作业类型
* Spring整合
* 运维平台
* 基于Docker的进程隔离(TBD)
# 架构图
## Elastic-Job-Lite

***
## Elastic-Job-Cloud

# [Release Notes](https://github.com/elasticjob/elastic-job/releases)
# [Roadmap](ROADMAP.md)
# 快速入门
## Elastic-Job-Lite
### 引入maven依赖
```xml
com.dangdang
elastic-job-lite-core
${latest.release.version}
com.dangdang
elastic-job-lite-spring
${latest.release.version}
```
### 作业开发
```java
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
```
***
## Elastic-Job-Cloud
### 引入maven依赖
```xml
com.dangdang
elastic-job-cloud-executor
${latest.release.version}
```
### 作业开发
```java
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: ...
}
}
}
```
### 打包作业
tar -cvf yourJobs.tar.gz yourJobs
### 发布APP
```shell
curl -l -H "Content-type: application/json" -X POST -d '{"appName":"foo_app","appURL":"http://app_host:8080/yourJobs.gz","cpuCount":0.1,"memoryMB":64.0,"bootstrapScript":"bin/start.sh","appCacheEnable":true,"eventTraceSamplingCount":0}' http://elastic_job_cloud_host:8899/api/app
```
### 发布作业
```shell
curl -l -H "Content-type: application/json" -X POST -d '{"jobName":"foo_job","jobClass":"yourJobClass","jobType":"SIMPLE","jobExecutionType":"TRANSIENT","cron":"0/5 * * * * ?","shardingTotalCount":5,"cpuCount":0.1,"memoryMB":64.0,"appName":"foo_app","failover":true,"misfire":true,"bootstrapScript":"bin/start.sh"}' http://elastic_job_cloud_host:8899/api/job/register
```