You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
560 lines
18 KiB
560 lines
18 KiB
|
|
<!DOCTYPE HTML> |
|
<html lang="zh-hans" > |
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> |
|
<title>自定义任务插件文档 · 调度系统-EasyScheduler</title> |
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
|
<meta name="description" content=""> |
|
<meta name="generator" content="GitBook 3.2.3"> |
|
<meta name="author" content="YIGUAN"> |
|
|
|
|
|
|
|
<link rel="stylesheet" href="gitbook/style.css"> |
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css"> |
|
|
|
|
|
|
|
<link rel="stylesheet" href="gitbook/gitbook-plugin-insert-logo-link/plugin.css"> |
|
|
|
|
|
|
|
<link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css"> |
|
|
|
|
|
|
|
<link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css"> |
|
|
|
|
|
|
|
<link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="styles/website.css"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
<meta name="HandheldFriendly" content="true"/> |
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> |
|
<meta name="apple-mobile-web-app-capable" content="yes"> |
|
<meta name="apple-mobile-web-app-status-bar-style" content="black"> |
|
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png"> |
|
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon"> |
|
|
|
|
|
|
|
|
|
</head> |
|
<body> |
|
|
|
<div class="book"> |
|
<div class="book-summary"> |
|
|
|
|
|
<div id="book-search-input" role="search"> |
|
<input type="text" placeholder="输入并搜索" /> |
|
</div> |
|
|
|
|
|
<nav role="navigation"> |
|
|
|
|
|
|
|
<ul class="summary"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="chapter " data-level="1.1" data-path="./"> |
|
|
|
<a href="./"> |
|
|
|
|
|
Easyscheduler简介 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2" > |
|
|
|
<span> |
|
|
|
|
|
前端部署文档 |
|
|
|
</span> |
|
|
|
|
|
|
|
<ul class="articles"> |
|
|
|
|
|
<li class="chapter " data-level="1.2.1" data-path="前端部署文档.html"> |
|
|
|
<a href="前端部署文档.html#前端项目环境构建及编译"> |
|
|
|
|
|
环境搭建 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.2" data-path="前端部署文档.html"> |
|
|
|
<a href="前端部署文档.html#安装及配置"> |
|
|
|
|
|
安装及配置 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.3" data-path="前端部署文档.html"> |
|
|
|
<a href="前端部署文档.html#项目生产环境配置"> |
|
|
|
|
|
项目生产环境Nginx配置 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.4" data-path="前端部署文档.html"> |
|
|
|
<a href="前端部署文档.html#前端项目发布"> |
|
|
|
|
|
前端项目发布 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.5" data-path="前端部署文档.html"> |
|
|
|
<a href="前端部署文档.html#问题"> |
|
|
|
|
|
问题 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
|
|
</ul> |
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.3" > |
|
|
|
<span> |
|
|
|
|
|
后端部署文档 |
|
|
|
</span> |
|
|
|
|
|
|
|
<ul class="articles"> |
|
|
|
|
|
<li class="chapter " data-level="1.3.1" data-path="后端部署文档.html"> |
|
|
|
<a href="后端部署文档.html#部署文档"> |
|
|
|
|
|
后端部署文档 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
|
|
</ul> |
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.4" data-path="系统使用手册.html"> |
|
|
|
<a href="系统使用手册.html#使用手册"> |
|
|
|
|
|
系统使用手册 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.5" data-path="系统架构设计.html"> |
|
|
|
<a href="系统架构设计.html#系统架构设计"> |
|
|
|
|
|
系统架构设计 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.6" > |
|
|
|
<span> |
|
|
|
|
|
前端开发文档 |
|
|
|
</span> |
|
|
|
|
|
|
|
<ul class="articles"> |
|
|
|
|
|
<li class="chapter " data-level="1.6.1" data-path="前端部署文档.html"> |
|
|
|
<a href="前端部署文档.html"> |
|
|
|
|
|
开发环境搭建 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.6.2" data-path="前端开发文档.html"> |
|
|
|
<a href="前端开发文档.html#项目目录结构"> |
|
|
|
|
|
项目目录结构 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.6.3" data-path="前端开发文档.html"> |
|
|
|
<a href="前端开发文档.html#系统功能模块"> |
|
|
|
|
|
系统功能模块 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.6.4" data-path="前端开发文档.html"> |
|
|
|
<a href="前端开发文档.html#路由和状态管理"> |
|
|
|
|
|
路由和状态管理 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.6.5" data-path="前端开发文档.html"> |
|
|
|
<a href="前端开发文档.html#规范"> |
|
|
|
|
|
规范 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.6.6" data-path="前端开发文档.html"> |
|
|
|
<a href="前端开发文档.html#接口"> |
|
|
|
|
|
接口 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.6.7" data-path="前端开发文档.html"> |
|
|
|
<a href="前端开发文档.html#扩展开发"> |
|
|
|
|
|
扩展开发 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
|
|
</ul> |
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.7" > |
|
|
|
<span> |
|
|
|
|
|
后端开发文档 |
|
|
|
</span> |
|
|
|
|
|
|
|
<ul class="articles"> |
|
|
|
|
|
<li class="chapter " data-level="1.7.1" data-path="任务插件开发.html"> |
|
|
|
<a href="任务插件开发.html#任务插件开发"> |
|
|
|
|
|
自定义任务插件文档 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
|
|
</ul> |
|
|
|
</li> |
|
|
|
|
|
|
|
|
|
<li class="divider"></li> |
|
|
|
<li> |
|
<a href="https://www.gitbook.com" target="blank" class="gitbook-link"> |
|
本书使用 GitBook 发布 |
|
</a> |
|
</li> |
|
</ul> |
|
|
|
|
|
</nav> |
|
|
|
|
|
</div> |
|
|
|
<div class="book-body"> |
|
|
|
<div class="body-inner"> |
|
|
|
|
|
|
|
<div class="book-header" role="navigation"> |
|
|
|
|
|
<!-- Title --> |
|
<h1> |
|
<i class="fa fa-circle-o-notch fa-spin"></i> |
|
<a href="." >自定义任务插件文档</a> |
|
</h1> |
|
</div> |
|
|
|
|
|
|
|
|
|
<div class="page-wrapper" tabindex="-1" role="main"> |
|
<div class="page-inner"> |
|
|
|
<div id="book-search-results"> |
|
<div class="search-noresults"> |
|
|
|
<section class="normal markdown-section"> |
|
|
|
<h2 id="任务插件开发">任务插件开发</h2> |
|
<p>提醒:目前任务插件开发暂不支持热部署</p> |
|
<h3 id="基于shell的任务">基于SHELL的任务</h3> |
|
<h4 id="基于yarn的计算(参见mapreducetask)">基于YARN的计算(参见MapReduceTask)</h4> |
|
<ul> |
|
<li>需要在 <strong>cn.escheduler.server.worker.task</strong> 下的 <strong>TaskManager</strong> 类中创建自定义任务(也需在TaskType注册对应的任务类型)</li> |
|
<li>需要继承<strong>cn.escheduler.server.worker.task</strong> 下的 <strong>AbstractYarnTask</strong></li> |
|
<li>构造方法调度 <strong>AbstractYarnTask</strong> 构造方法</li> |
|
<li>继承 <strong>AbstractParameters</strong> 自定义任务参数实体</li> |
|
<li>重写 <strong>AbstractTask</strong> 的 <strong>init</strong> 方法中解析<strong>自定义任务参数</strong></li> |
|
<li>重写 <strong>buildCommand</strong> 封装command</li> |
|
</ul> |
|
<h4 id="基于非yarn的计算(参见shelltask)">基于非YARN的计算(参见ShellTask)</h4> |
|
<ul> |
|
<li><p>需要在 <strong>cn.escheduler.server.worker.task</strong> 下的 <strong>TaskManager</strong> 中创建自定义任务</p> |
|
</li> |
|
<li><p>需要继承<strong>cn.escheduler.server.worker.task</strong> 下的 <strong>AbstractTask</strong></p> |
|
</li> |
|
<li><p>构造方法中实例化 <strong>ShellCommandExecutor</strong></p> |
|
<pre><code>public ShellTask(TaskProps props, Logger logger) { |
|
super(props, logger); |
|
|
|
this.taskDir = props.getTaskDir(); |
|
|
|
this.processTask = new ShellCommandExecutor(this::logHandle, |
|
props.getTaskDir(), props.getTaskAppId(), |
|
props.getTenantCode(), props.getEnvFile(), props.getTaskStartTime(), |
|
props.getTaskTimeout(), logger); |
|
this.processDao = DaoFactory.getDaoInstance(ProcessDao.class); |
|
} |
|
</code></pre><p>传入自定义任务的 <strong>TaskProps</strong>和自定义<strong>Logger</strong>,TaskProps 封装了任务的信息,Logger分装了自定义日志信息</p> |
|
</li> |
|
<li><p>继承 <strong>AbstractParameters</strong> 自定义任务参数实体</p> |
|
</li> |
|
<li><p>重写 <strong>AbstractTask</strong> 的 <strong>init</strong> 方法中解析<strong>自定义任务参数实体</strong></p> |
|
</li> |
|
<li><p>重写 <strong>handle</strong> 方法,调用 <strong>ShellCommandExecutor</strong> 的 <strong>run</strong> 方法,第一个参数传入自己的<strong>command</strong>,第二个参数传入 ProcessDao,设置相应的 <strong>exitStatusCode</strong></p> |
|
</li> |
|
</ul> |
|
<h3 id="基于非shell的任务(参见sqltask)">基于非SHELL的任务(参见SqlTask)</h3> |
|
<ul> |
|
<li>需要在 <strong>cn.escheduler.server.worker.task</strong> 下的 <strong>TaskManager</strong> 中创建自定义任务</li> |
|
<li>需要继承<strong>cn.escheduler.server.worker.task</strong> 下的 <strong>AbstractTask</strong></li> |
|
<li>继承 <strong>AbstractParameters</strong> 自定义任务参数实体</li> |
|
<li>构造方法或者重写 <strong>AbstractTask</strong> 的 <strong>init</strong> 方法中,解析自定义任务参数实体</li> |
|
<li>重写 <strong>handle</strong> 方法实现业务逻辑并设置相应的<strong>exitStatusCode</strong></li> |
|
</ul> |
|
|
|
|
|
</section> |
|
|
|
</div> |
|
<div class="search-results"> |
|
<div class="has-results"> |
|
|
|
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1> |
|
<ul class="search-results-list"></ul> |
|
|
|
</div> |
|
<div class="no-results"> |
|
|
|
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1> |
|
|
|
</div> |
|
</div> |
|
</div> |
|
|
|
</div> |
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
<script> |
|
var gitbook = gitbook || []; |
|
gitbook.push(function() { |
|
gitbook.page.hasChanged({"page":{"title":"自定义任务插件文档","level":"1.7.1","depth":2,"previous":{"title":"后端开发文档","level":"1.7","depth":1,"ref":"","articles":[{"title":"自定义任务插件文档","level":"1.7.1","depth":2,"anchor":"#任务插件开发","path":"任务插件开发.md","ref":"任务插件开发.md#任务插件开发","articles":[]}]},"dir":"ltr"},"config":{"plugins":["expandable-chapters","insert-logo-link","livereload"],"styles":{"website":"./styles/website.css"},"pluginsConfig":{"livereload":{},"insert-logo-link":{"src":"http://geek.analysys.cn/static/upload/236/2019-03-29/379450b4-7919-4707-877c-4d33300377d4.png","url":"https://github.com/analysys/EasyScheduler"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"YIGUAN","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"调度系统-EasyScheduler","language":"zh-hans","gitbook":"3.2.3","description":"调度系统"},"file":{"path":"任务插件开发.md","mtime":"2019-04-08T02:29:27.998Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-04-10T07:14:01.407Z"},"basePath":".","book":{"language":""}}); |
|
}); |
|
</script> |
|
</div> |
|
|
|
|
|
<script src="gitbook/gitbook.js"></script> |
|
<script src="gitbook/theme.js"></script> |
|
|
|
|
|
<script src="gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script> |
|
|
|
|
|
|
|
<script src="gitbook/gitbook-plugin-insert-logo-link/plugin.js"></script> |
|
|
|
|
|
|
|
<script src="gitbook/gitbook-plugin-livereload/plugin.js"></script> |
|
|
|
|
|
|
|
<script src="gitbook/gitbook-plugin-search/search-engine.js"></script> |
|
|
|
|
|
|
|
<script src="gitbook/gitbook-plugin-search/search.js"></script> |
|
|
|
|
|
|
|
<script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script> |
|
|
|
|
|
|
|
<script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script> |
|
|
|
|
|
|
|
<script src="gitbook/gitbook-plugin-sharing/buttons.js"></script> |
|
|
|
|
|
|
|
<script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script> |
|
|
|
|
|
|
|
</body> |
|
</html> |
|
|
|
|