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.
517 lines
18 KiB
517 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"> |
|
|
|
|
|
<link rel="next" href="user-manual.md" /> |
|
|
|
|
|
<link rel="prev" href="backend-deploy.html" /> |
|
|
|
|
|
</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="frontend-deploy.html"> |
|
|
|
<a href="frontend-deploy.html#前端项目环境构建及编译"> |
|
|
|
|
|
环境搭建 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.2" data-path="frontend-deploy.html"> |
|
|
|
<a href="frontend-deploy.html#安装及配置"> |
|
|
|
|
|
安装及配置 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.3" data-path="frontend-deploy.html"> |
|
|
|
<a href="frontend-deploy.html#项目生产环境配置"> |
|
|
|
|
|
项目生产环境Nginx配置 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.4" data-path="frontend-deploy.html"> |
|
|
|
<a href="frontend-deploy.html#前端项目发布"> |
|
|
|
|
|
前端项目发布 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.5" data-path="frontend-deploy.html"> |
|
|
|
<a href="frontend-deploy.html#问题"> |
|
|
|
|
|
问题 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.6" data-path="frontend-development.html"> |
|
|
|
<a href="frontend-development.html#项目目录结构"> |
|
|
|
|
|
项目目录结构 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.7" data-path="frontend-development.html"> |
|
|
|
<a href="frontend-development.html#系统功能模块"> |
|
|
|
|
|
系统功能模块 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.8" data-path="frontend-development.html"> |
|
|
|
<a href="frontend-development.html#路由和状态管理"> |
|
|
|
|
|
路由和状态管理 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.9" data-path="frontend-development.html"> |
|
|
|
<a href="frontend-development.html#规范"> |
|
|
|
|
|
规范 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.10" data-path="frontend-development.html"> |
|
|
|
<a href="frontend-development.html#接口"> |
|
|
|
|
|
接口 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.2.11" data-path="frontend-development.html"> |
|
|
|
<a href="frontend-development.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="architecture-design.html"> |
|
|
|
<a href="architecture-design.html#调度系统架构设计"> |
|
|
|
|
|
系统架构设计 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.3.2" data-path="backend-deploy.html"> |
|
|
|
<a href="backend-deploy.html#部署文档"> |
|
|
|
|
|
部署文档 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.3.3" data-path="task-plugin-development.html"> |
|
|
|
<a href="task-plugin-development.html#任务插件开发"> |
|
|
|
|
|
自定义任务插件文档 |
|
|
|
</a> |
|
|
|
|
|
|
|
</li> |
|
|
|
|
|
</ul> |
|
|
|
</li> |
|
|
|
<li class="chapter " data-level="1.4" data-path="user-manual.md"> |
|
|
|
<span> |
|
|
|
|
|
使用说明文档 |
|
|
|
</a> |
|
|
|
|
|
|
|
</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> |
|
|
|
|
|
|
|
<a href="backend-deploy.html#部署文档" class="navigation navigation-prev " aria-label="Previous page: 部署文档"> |
|
<i class="fa fa-angle-left"></i> |
|
</a> |
|
|
|
|
|
<a href="user-manual.md#使用手册" class="navigation navigation-next " aria-label="Next page: 使用说明文档"> |
|
<i class="fa fa-angle-right"></i> |
|
</a> |
|
|
|
|
|
|
|
</div> |
|
|
|
<script> |
|
var gitbook = gitbook || []; |
|
gitbook.push(function() { |
|
gitbook.page.hasChanged({"page":{"title":"自定义任务插件文档","level":"1.3.3","depth":2,"next":{"title":"使用说明文档","level":"1.4","depth":1,"anchor":"#使用手册","path":"user-manual.md","ref":"user-manual.md#使用手册","articles":[]},"previous":{"title":"部署文档","level":"1.3.2","depth":2,"anchor":"#部署文档","path":"backend-deploy.md","ref":"backend-deploy.md#部署文档","articles":[]},"dir":"ltr"},"config":{"plugins":["expandable-chapters","insert-logo-link"],"styles":{"website":"./styles/website.css"},"pluginsConfig":{"insert-logo-link":{"src":"../images/logo.png","url":"/"},"expandable-chapters":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"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}},"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":"task-plugin-development.md","mtime":"2019-03-28T11:14:39.616Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-03-28T11:15:13.750Z"},"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-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> |
|
|
|
|