Git Product home page Git Product logo

distribute-job-scheduler's Introduction

Introduction

thales是一款自主研发的分布式任务调度系统,系统支持command,shell,hive,spark,python,http,sql,flink,clickhouse等任务类型。实测每天可调度百万次任务,满足市场上90%以上公司调度需求。

Architecture

image

Feature

  • 动态任务依赖
  • 可定义复杂的任务依赖关系
  • 分布式部署
  • 基于真实资源
  • 资源隔离,相同类型的任务可以提交到对应的资源池
  • 支持大规模任务调度
  • 节点掉线自动发现
  • 任务失败后自动重试
  • 任务失败或超时告警
  • 提供HA
  • 可以通过页面调度,停止,查看任务详情和依赖等等
  • 可以调度hive,spark,flink等大数据任务
  • 提供各种图表方便用户查看任务执行情况
  • 提供数据源管理
  • 提供参数管理

目录结构

1. Project structure

  • thales-scheduler
    • scheduler-alert --任务告警
    • scheduler-api --对外接口
      • scheduler-controller --任务控制层
      • scheduler-dao --任务数据层
      • scheduler-service --任务服务层
      • scheduler-common --通用帮助类
    • scheduler-master --任务调度
      • quartz --任务调度
      • master manager --任务资源管理
      • task status management --任务状态管理
      • rpc client --提交任务
    • scheduler-worker --任务执行
      • rpc server --接收任务请求
      • log --日志服务器
      • executor-- 任务执行器
    • scheduler-core --核心实现
    • scheduler-model --对外服务接口模型
    • sql --系统使用表ddl

scheduler-api

api作为接口层,主要有如下功能:

  • 和前端交互,负责任务调度,下线,重跑,看日志等。

scheduler-master

master作为调度的核心,主要有如下功能:

  • 初始化任务实例状态
  • 通过quartz调度所有任务
  • 检查任务状态
  • 启动master rpc服务供worker汇报资源和心跳
  • master ha
  • 启动jetty server接受api的调用
  • 根据机器cpu,内存,任务负载个数等选择最优的worker调度
  • 节点的上线与下线管理

scheduler-worker

worker作为执行器,主要有如下功能:

  • 负责任务的执行,目前可执行shell,hive,spark等任务
  • 启动jetty server供查看任务日志,
  • 上报资源信息,发送心跳给master.

scheduler-alert

alert主要提供告警功能:

  • 任务失败时告警。
  • 任务超时告警。
  • 目前只支持email.

系统运行

  • git clone https://github.com/ylpu/distribute-job-scheduler.git ,将项目导入到intellij或eclipse中并安装lombok.
  • 本地安装mysql,zookeeper,如非本地安装,需要修改controller,master,worker config目录里config.properties,application.yml文件的zookeeper和mysql地址和端口
  • 在mysql数据库中执行语句
    • distribute-job-scheduler/thales-scheduler/sql/thales-scheduler.sql
    • insert into t_thales_scheduler_user(user_name,password,create_time,update_time) values ('test','test',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);
    • insert into t_thales_scheduler_role(role_name,create_time,update_time) values ('ROLE_ADMIN',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);
    • insert into t_thales_scheduler_user_role(user_id,role_id,create_time,update_time) values ($user_id,$role_id,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);(其中$user_id,$role_id为上面插入语句的相应id)
  • 在distribute-job-scheduler中执行mvn clean install -Dmaven.test.skip=true
  • 依次执行如下脚本
    • scheduler-api/bin/api-server.sh start ,启动成功后可以通过http://localhost:8085/swagger-ui.html 查看接口文档
    • scheduler-master/bin/master-server.sh start,启动成功后可以通过 http://localhost:9095/ 查看master jmx信息
    • scheduler-worker/bin/worker-server.sh start,启动后可以通过查看10001端口判断logserver是否成功(启动worker前确保通过页面执行组管理添加相应的执行器组)
  • 运行distribute-job-scheduler-frontend(https://github.com/ylpu/distribute-job-scheduler-frontend) 项目并以如上用户名,密码登陆

系统使用

  • 创建任务(创建任务后点击调度)
    • 任务名称 : 任务名称,必须唯一
    • 任务工作组: 任务会被提交到相应的组里
    • 任务依赖: 选择需要依赖的任务
    • 任务优先级: 任务的优先度,有低,中,高三种
    • 任务责任人:任务的所属人
    • 任务类型:目前command,shell,hive,spark,flink,clickhouse,http,sql,python 9种。
    • 任务告警人: 任务失败,超时的时候需要通知的人(邮箱格式)
    • 告警类型:有sms,webchat,email三种,目前只支持emai(请在thales-scheduler/scheduler-alert/src/main/resources/email.properties配置相应的邮件服务器信息)。
    • 调度时间:cron表达式
    • 任务周期:分钟,小时,天,周,月,年等
    • 重试次数:任务失败时最多重试的次数
    • 超时时间:超过多少分钟任务将会被杀死。
    • 任务描述:任务的详细信息
    • 任务配置:根据类型不同有不同的配置(以下为简单例子):
      • command: {"command" :"pwd;cat /tmp/log/scheduler-worker/info.log","parameters" : {"param1":"test"}}
      • shell: {"fileName" : "/tmp/shell/test.sh","parameters" : {"param1":"test"}}
      • python: {"fileName" : "/tmp/python/test.py","parameters" : {"param1":"test"}}
      • hive: {"fileName" : "/tmp/shell/test.hql","config" : "","parameters":{"dt":"20191205","hm":"1000"}
      • spark: {"fileName":"/tmp/shell/test.sql","config":{"masterUrl":"spark://localhost:7077","executorMemory":"2g","executorCores":2,"totalExecutorCores":20},"parameters":{"dt":"20191205","hm":"1000"}
      • http:
        • get:{"url":"http://localhost:8085/api/job/getJobById", "method": "get", "parameters":{ "id":45 } }
        • post:{"url":"http://localhost:8085/api/job/addJob", "method": "post", "parameters":{ "alertTypes": "email", "alertUsers": "string", "creatorId": "string", "dependIds": [], "description": "string", "executionTimeout": 0, "isSelfdependent": true, "jobConfiguration": "string", "jobCycle": "DAY", "jobName": "rest-test", "jobPriority": "HIGH", "jobReleasestate": 0, "jobType": "shell", "maxRetrytimes": 0, "ownerIds": "test", "retryInterval": 0, "scheduleCron": "0 3 15 * * ?", "workerGroupname": "hive" } }
      • sql : { "dsName":"mysql-test(连接管理里的连接名称)", "operator":"select", "sql":"select * from t_thales_scheduler_job_instance where id = ?", "parameters":{"param1":76} }
      • flink : { "className":"", "jarName":"", "config": {"mode":"","slotNumber":2,"applicationName":"","taskManagerNumber":2,"taskManagerMemory":"2g","jobManagerMemory":"2g"} }
      • clickhouse : { "dsName":"ck-test(连接管理里的连接名称)", "query":"select * from t_thales_scheduler_job_instance where id = ?", "config":{"sendTimeout":10000,"receiveTimeout":10000}, "parameters":{"dt":"20191205","hm":"1000"} }
  • 修改任务
    • 参数与创建任务相同(修改后需要点击重新调度)
  • 任务图
    • 查看整个任务的依赖关系
  • 实例图
    • 图表方式查看任务近30天的运行情况

系统图

  • 整体图 image
  • 任务管理 image
  • 添加任务 image
  • 任务依赖图 image
  • 任务实例管理 image
  • 任务近30次运行时间图 image

distribute-job-scheduler's People

Contributors

puyulu avatar ylpu avatar yulupu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

liutoutou

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.