-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] [admin] 2 new APIs in openapi: 1. create catalogues ,task and send it to DolphinScheduer 2. save task content #3578
Draft
Yangxiaotian
wants to merge
35
commits into
DataLinkDC:dev
Choose a base branch
from
Yangxiaotian:detached12
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 33 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
3548432
feat: 新增从 DS 获取任务组接口
8b93776
feat: 调用 DolphinScheduler 接口 ProcessClient.createOrUpdateProcessDefin…
5cfc1dd
feat: 注册任务组类型
195a610
feat: 任务组联调
ceab412
fix:dinky推送任务字段dolphinTaskDefinition做非空处理
bafce4a
feat: dinky-任务推送增加回显数据操作
a59d965
chore: resolve conflict caused by cherry-pick
c8fa711
style: remove print code & add license
e26587b
style: remove print code & add license
c47efb0
Merge branch 'dev' of github.com:Yangxiaotian/dinky into dev
689450b
refactor: Remove new classes, and use existed classes
913e872
feat: 新增任务组内优先级
0e41186
feat: 增加组内优先级选项
375dcb9
feat: 创建目录和任务,往 DolphinScheduler 推送
0d2d506
feat: 创建目录和任务,往 DolphinScheduler 推送
2d65f93
fix: 创建任务接口推送任务时参数设错
78008c4
fix: token 已被冻结
3b65e36
feat: 新增保存任务的接口
20aa8d7
fix: /openapi 接口去掉 sa-token 机制,验证有报错
d76abf0
fix: 参数中的 json 字符串换成标准的 Java 类
fe4d4e3
fix: 把 /openapi/createTaskAndSend2Ds、saveTask 两个接口加 sa-token 机制
3a403f9
chore: 冲突解决
7d339fe
chore: add license info
349b7b9
chore: add license info
f0937cd
chore: code style
a916971
chore: code style
3a39e59
chore: code style
9cc5d5b
chore: code style
df1d27b
chore: package path changed
c725eeb
chore: code style
c2160a8
chore: package path changed
78c6445
chore: package path changed
ca9db19
fix: 低版本 jdk 不支持 List.of
15c6a2b
fix: sa-token 校验机制写的有问题
a824e34
fix: sa-token 校验机制写的有问题
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
dinky-admin/src/main/java/org/dinky/data/dto/CreatingCatalogueTaskDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.dinky.data.dto; | ||
|
||
import org.dinky.scheduler.model.DinkyTaskRequest; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class CreatingCatalogueTaskDTO { | ||
/** | ||
* 目录名称列表 | ||
* 例子:["catalogue1", "catalogue2"] | ||
* 数组第 0 个元素为根目录,依次下一个元素是上一个元素的子目录 | ||
* 目录不存在会新建,已存在就保持原来的目录 | ||
*/ | ||
private List<String> catalogueNames; | ||
/** | ||
* 作业类型:FlinkSql、Mysql 等,详见 dinky 创建作业时的作业类型下拉菜单 | ||
*/ | ||
private String type; | ||
/** | ||
* 任务信息 | ||
* 例子:{"name": "test", "note": "作业描述", "statement": "sql 语句", "type": "kubernetes-session", "clusterId": 36} | ||
* 例子只列出了部分属性,其他属性请参考 TaskDTO 类 | ||
*/ | ||
private TaskDTO task; | ||
/** | ||
* Dinky 推送时的作业配置 | ||
* 例子: {"delayTime": 0, "taskPriority": "MEDIUM", "failRetryInterval": 2, "failRetryTimes": 3, "flag": "YES" } | ||
* 例子只列出了部分属性,其他属性请参考 DinkyTaskRequest 类 | ||
*/ | ||
private DinkyTaskRequest jobConfig; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
dinky-admin/src/test/java/org/dinky/service/impl/TestServiceImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.dinky.service.impl; | ||
|
||
import org.dinky.Dinky; | ||
import org.dinky.data.dto.CatalogueTaskDTO; | ||
import org.dinky.data.dto.CreatingCatalogueTaskDTO; | ||
import org.dinky.data.dto.TaskDTO; | ||
import org.dinky.data.enums.JobLifeCycle; | ||
import org.dinky.data.exception.SqlExplainExcepition; | ||
import org.dinky.data.model.Catalogue; | ||
import org.dinky.scheduler.model.DinkyTaskRequest; | ||
import org.dinky.service.SchedulerService; | ||
import org.dinky.service.TaskService; | ||
import org.dinky.service.catalogue.CatalogueService; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@SpringBootTest(classes = Dinky.class) | ||
public class TestServiceImplTest { | ||
@Autowired | ||
private CatalogueService catalogueService; | ||
|
||
@Autowired | ||
private TaskService taskService; | ||
|
||
@Autowired | ||
SchedulerService schedulerService; | ||
|
||
@Test | ||
@Ignore | ||
public void testCreateCatalogueAndTask() throws SqlExplainExcepition { | ||
CreatingCatalogueTaskDTO dto = new CreatingCatalogueTaskDTO(); | ||
List<String> catalogueNames = new ArrayList<>(); | ||
catalogueNames.add("test"); | ||
catalogueNames.add("test2"); | ||
catalogueNames.add("test3"); | ||
dto.setCatalogueNames(catalogueNames); | ||
int parentId = 0; | ||
for (String catalogueName : catalogueNames) { | ||
Catalogue catalogue = catalogueService.findByParentIdAndName(parentId, catalogueName); | ||
// 目录不存在则创建 | ||
if (catalogue == null) { | ||
catalogue = new Catalogue(); | ||
catalogue.setName(catalogueName); | ||
catalogue.setIsLeaf(false); | ||
catalogue.setParentId(parentId); | ||
catalogueService.save(catalogue); | ||
} | ||
parentId = catalogue.getId(); | ||
} | ||
CatalogueTaskDTO catalogueTaskDTO = getCatalogueTaskDTO(parentId); | ||
// 新建任务 | ||
Catalogue catalogue = catalogueService.saveOrUpdateCatalogueAndTask(catalogueTaskDTO); | ||
|
||
// 发布任务 | ||
taskService.changeTaskLifeRecyle(catalogue.getTaskId(), JobLifeCycle.PUBLISH); | ||
DinkyTaskRequest dinkyTaskRequest = new DinkyTaskRequest(); | ||
dinkyTaskRequest.setTaskId(catalogue.getTaskId() + ""); | ||
dinkyTaskRequest.setDelayTime(0); | ||
dinkyTaskRequest.setFailRetryTimes(3); | ||
dinkyTaskRequest.setFailRetryInterval(2); | ||
dinkyTaskRequest.setFlag("YES"); | ||
dinkyTaskRequest.setTaskPriority("MEDIUM"); | ||
// 推送任务 | ||
schedulerService.pushAddTask(dinkyTaskRequest); | ||
} | ||
|
||
private static @NotNull CatalogueTaskDTO getCatalogueTaskDTO(int parentId) { | ||
TaskDTO taskDTO = new TaskDTO(); | ||
taskDTO.setSavePointStrategy(0); | ||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); | ||
taskDTO.setName("Flink 测试任务" + sdf.format(new Date())); | ||
taskDTO.setNote("备注信息"); | ||
taskDTO.setStatement("select now()"); | ||
taskDTO.setParallelism(5); | ||
taskDTO.setEnvId(-1); | ||
taskDTO.setStep(1); | ||
taskDTO.setAlertGroupId(-1); | ||
taskDTO.setType("kubernetes-session"); | ||
taskDTO.setClusterId(36); | ||
CatalogueTaskDTO catalogueTaskDTO = new CatalogueTaskDTO(); | ||
catalogueTaskDTO.setLeaf(false); | ||
catalogueTaskDTO.setName(taskDTO.getName()); | ||
catalogueTaskDTO.setNote(taskDTO.getNote()); | ||
catalogueTaskDTO.setParentId(parentId); | ||
catalogueTaskDTO.setType("FlinkSql"); | ||
catalogueTaskDTO.setTask(taskDTO); | ||
|
||
return catalogueTaskDTO; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do this, openapi can't add authentication at the moment, it will cause Dolphinscheduler to be unable to schedule tasks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I realized this, and the last code was only applying 2 new apis