启用job接口
URL: /api/jobs/on.do
METHOD: POST
BODY:
{
"jobs":["qschedule.demo.job1","qschedule.demo.job2"],
"token":"a1b2c3d4"
}
RESPONSE:
1.{"ret":false,"message":"参数错误"}
2.{"ret":false, "message":"授权失败"}
3.{"ret":false,"message":"启用失败"}
4.{"ret":true,"message":"操作成功"}
禁用job接口
URL: /api/jobs/off.do
METHOD: POST
BODY:
{
"jobs":["qschedule.demo.job1","qschedule.demo.job2"],
"token":"a1b2c3d4"
}
RESPONSE:
1.{"ret":false,"message":"参数错误"}
2.{"ret":false, "message":"授权失败"}
3.{"ret":false,"message":"停止失败"}
4.{"ret":true,"message":"操作成功"}
查询job信息接口
URL: /api/jobs/$job_name.do?token=$token
METHOD: GET
RESPONSE:
1.{"ret":false,"message":"参数错误"}
2.{"ret":false, "message":"授权失败"}
3.{"ret":false,"message":"job不存在"}
4.{"ret":false, "message":"查询失败"}
5. {"data":{
"appId":163,
"appName":"qschedule.demo",
"lastRun":1402545989000,
"lastState":0,
"name":"qschedule.demo.job1_dev",
"recover":"discard",
"state":false,
"type":"remote"},
"ret":true}
立即执行任务接口
URL: /api/tasks.do
METHOD: POST
BODY:
{
"job":"qschedule.demo.job1",
"token":"a1b2c3d4",
"param":{}
}
RESPONSE:
1.{"ret":false,"message":"参数错误"}
2.{"ret":false, "message":"授权失败"}
3.{"ret":false,"message":"重试失败"}
4.{"ret":false, "message":"内部错误"}
5. {"ret":true,"message":"140727.123745.192.168.236.130.26859.2531970"}
Worker上下线接口
URL: /api/workers/state.do
METHOD: POST
BODY:
{
"jobName":"qschedule.demo.job1",
"workers":'{"192.168.1.1:20010":true,"192.168.1.2:20010":false}',
"token":"a1b2c3d4"
}
RESPONSE:
1.{"ret":false,"message":"参数错误"}
2.{"ret":false, "message":"授权失败"}
3.{"ret":false,"message":"workers json 格式非法"}
4.{"ret":false,"message":"所有机器不能全部下线"}
5.{"ret":false,"message":"可能存在未操作成功的机器,请调用查看接口验证"}
6.{"ret":false,"message":"操作失败"}
7.{"ret":true,"message":"操作成功"}
Worker上下线查询接口
URL: /api/workers/$job_name.do?token=$token
METHOD: GET
RESPONSE:
1.{"ret":false,"message":"参数错误"}
2.{"ret":false, "message":"授权失败"}
3.{"ret":false,"message":"job不存在"}
4.{"ret":false, "message":"查询失败"}
5.{"data":[
{"address":"192.168.1.1:20010","canSchedule":true,"hostname":"192.168.1.1:20010","jobName":"qschedule.demo.job1"}
],"ret":true}
检查是否有任务在执行接口
URL: /api/check/$ip.do
METHOD: GET
RESPONSE:
1.{"ret":false,"message":"参数错误"}
2.{"ret":false, "message":"查询失败"}
3.{"data":[
{"appId":233,"appName":"m_car_coupon_dis_entity","consecutiveFailTimesAlertThreshold":1,"cron":"0 30 9 * * ?","desc":"发送即将过期短信","lastDuration":26249000,"lastRun":1423704600000,"lastState":200,"lastUpdate":1423730849000,"loadBalance":"random","name":"car.coupon.sendOutdateMsg","nextRun":1423791000000,"recover":"retry","state":true,"timeout":0,"type":"remote"},
{"appId":233,"appName":"m_car_coupon_dis_entity","consecutiveFailTimesAlertThreshold":1,"cron":"0 0 1 * * ?","desc":"","lastDuration":56849000,"lastRun":1423674000000,"lastState":200,"lastUpdate":1423730849000,"loadBalance":"random","name":"car.coupon.execOutdate","nextRun":1423760400000,"recover":"retry","state":true,"timeout":0,"type":"remote"}
],"ret":true}
支持 ip和域名
如:
http://dev.qschedule.corp.qunar.com/api/check/l-payserver23.pay.dev.cn6.qunar.com.do
http://dev.qschedule.corp.qunar.com/api/check/l-payserver23.pay.dev.cn6.do
http://dev.qschedule.corp.qunar.com/api/check/192.168.236.182.do
name 作业名
desc 作业描述
cron 作业执行周期表达式
parameter 作业执行参数
createdAt 作业创建时间
updatedAt 作业更新时间
lastState 作业最后一次执行的状态( 任务正在开始(100),任务已开始(200),任务已完成(300),任务被忽略(400),
任务处理失败(-100),没有找到runner来执行任务(-200),Worker任务队列已满,任务被拒绝(-300),
初始化(0),未知状态(-9999)
lastRun 作业最后一次执行的ip
lastUpdate 作业最后一次执行的更新时间
lastDuration 作业最后一次执行的时长
loadBalance 作业负载平衡策略
consecutiveFailTimesAlertThreshold 作业失败次数报警阈值
timeout 作业运行执行的最长时间,超过报警
nextRun 作业预计下次执行的时间
state 作业是否可用
type 作业类型
recover 作业恢复策略(discard 、 retry)
appId 作业所在应用id
appName 作业所在应用名
appCode 作业所在应用编码
cronParamJson 作业cron表达式集合json串