
作者介绍:李进勇,优秀创作者,大数据架构师/Apache DolphinScheduler Committer
01
背景

02
工作流定义接口


03
任务定义接口
| 接口名称 | 接口地址 |
请求方式 |
功能介绍 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
04
工作流任务关系接口
| 接口名称 |
接口地址 |
请求方式 |
功能介绍 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
05
代码调用接口方式
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
private static String DOLPHIN_BASE_URI = "http://ip:port";
private static String token = "xxx";
private static String sendPost(String uri, List<NameValuePair> params) throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
CloseableHttpResponse response = null;
try {
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(params, Consts.UTF_8);
HttpPost httpPost = new HttpPost(DOLPHIN_BASE_URI + uri);
httpPost.setEntity(formEntity);
httpPost.setHeader("token", token);
response = httpclient.execute(httpPost);
return EntityUtils.toString(response.getEntity(), Consts.UTF_8);
} catch (Exception e) {
throw new Exception(String.format("[dolphin] The %s call failed", uri));
} finally {
try {
if (response != null) {
response.close();
}
httpclient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private static String sendGet(String uri, List<NameValuePair> params) throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
CloseableHttpResponse response = null;
try {
HttpGet httpGet = new HttpGet(new URIBuilder(DOLPHIN_BASE_URI + uri).setParameters(params).build());
httpGet.setHeader("token", token);
response = httpclient.execute(httpGet);
return EntityUtils.toString(response.getEntity(), Consts.UTF_8);
} catch (Exception e) {
throw new Exception(String.format("[dolphin] The %s call failed", uri));
} finally {
if (response != null) {
response.close();
}
httpclient.close();
}
}
06
创建工作流的两种方式
(1) 调用 createProcessDefinition
| 参数 |
参数说明 |
实例值 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
操作系统租户
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
long projectCode = 4362891840832L;
String uri = String.format("/dolphinscheduler/projects/%d/process-definition", projectCode);
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("name", "lee-test-04"));
params.add(new BasicNameValuePair("projectCode", projectCode + ""));
String taskDefinitionJson = "[{\"code\":4143298469059,\"name\":\"lee-test-4\",\"description\":\"\",\"delayTime\":0,\"taskType\":\"SHELL\"," +
"\"taskParams\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"echo 11333\",\"dependence\":{},\"conditionResult\"" +
":{\"successNode\":[],\"failedNode\":[]},\"waitStartTimeout\":{},\"switchResult\":{}},\"flag\":\"YES\",\"taskPriority\":\"MEDIUM\"," +
"\"workerGroup\":\"default\",\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\",\"timeoutNotifyStrategy\":\"WARN\"," +
"\"timeout\":0,\"environmentCode\":-1}]";
params.add(new BasicNameValuePair("taskDefinitionJson", taskDefinitionJson));
params.add(new BasicNameValuePair("taskRelationJson", "[{\"name\":\"\",\"preTaskCode\":0,\"preTaskVersion\":0,\"postTaskCode\":4143298469059,\"conditionType\":0,\"conditionParams\":{}}]"));
params.add(new BasicNameValuePair("tenantCode", "root"));
params.add(new BasicNameValuePair("description", ""));
params.add(new BasicNameValuePair("globalParams", "[]"));
params.add(new BasicNameValuePair("timeout", "0"));
sendPost(uri, params);
}
(2) 调用工作流 createEmptyProcessDefinition、任务 save、工作流任务关系 save
| 参数 |
参数说明 |
示例值 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
操作系统租户
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 参数 |
参数说明 |
示例值 |
|
|
|
|
|
|
|
|
| 参数 |
参数说明 | 示例值 |
|
|
|
|
|
|
|
|
|
|
操作系统租户
|
|
|
|
|
07
参与贡献
随着国内开源的迅猛崛起,Apache DolphinScheduler 社区迎来蓬勃发展,为了做更好用、易用的调度,真诚欢迎热爱开源的伙伴加入到开源社区中来,为中国开源崛起献上一份自己的力量,让本土开源走向全球。
参与 DolphinScheduler 社区有非常多的参与贡献的方式,包括:
贡献第一个PR(文档、代码) 我们也希望是简单的,第一个PR用于熟悉提交的流程和社区协作以及感受社区的友好度。
社区汇总了以下适合新手的问题列表:https://github.com/apache/dolphinscheduler/issues/5689
非新手问题列表:https://github.com/apache/dolphinscheduler/issues?q=is%3Aopen+is%3Aissue+label%3A%22volunteer+wanted%22
如何参与贡献链接:https://dolphinscheduler.apache.org/zh-cn/docs/development/contribute.html
来吧,DolphinScheduler开源社区需要您的参与,为中国开源崛起添砖加瓦吧,哪怕只是小小的一块瓦,汇聚起来的力量也是巨大的。
参与开源可以近距离与各路高手切磋,迅速提升自己的技能,如果您想参与贡献,我们有个贡献者种子孵化群,可以添加社区小助手微信(Leonard-ds) ,手把手教会您( 贡献者不分水平高低,有问必答,关键是有一颗愿意贡献的心 )。
添加小助手微信时请说明想参与贡献。
来吧,开源社区非常期待您的参与。
https://dolphinscheduler.apache.org/
您的 Star,是 Apache DolphinScheduler 为爱发电的动力❤️ ~
(Leonard-ds)


