Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
DolphinScheduler
提交
890faffd
DolphinScheduler
项目概览
apache
/
DolphinScheduler
上一次同步 1 年多
通知
704
Star
9572
Fork
3514
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
890faffd
编写于
12月 29, 2021
作者:
J
JinYong Li
提交者:
GitHub
12月 29, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Bug][ApiServer] workflow copy (#7694)
* fix workflow copy * fix copy * fix copy * code style
上级
24747b3d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
10 deletion
+38
-10
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
...in/java/org/apache/dolphinscheduler/api/enums/Status.java
+1
-1
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
...eduler/api/service/impl/ProcessDefinitionServiceImpl.java
+37
-9
未找到文件。
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
浏览文件 @
890faffd
...
...
@@ -293,7 +293,7 @@ public enum Status {
PROJECT_PROCESS_NOT_MATCH
(
50054
,
"the project and the process is not match"
,
"项目和工作流不匹配"
),
DELETE_EDGE_ERROR
(
50055
,
"delete edge error"
,
"删除工作流任务连接线错误"
),
NOT_SUPPORT_UPDATE_TASK_DEFINITION
(
50056
,
"task state does not support modification"
,
"当前任务不支持修改"
),
NOT_SUPPORT_COPY_TASK_TYPE
(
50057
,
"task type [{
}] does not support copy"
,
"不支持复制的任务类型[{
}]"
),
NOT_SUPPORT_COPY_TASK_TYPE
(
50057
,
"task type [{
0}] does not support copy"
,
"不支持复制的任务类型[{0
}]"
),
HDFS_NOT_STARTUP
(
60001
,
"hdfs not startup"
,
"hdfs未启用"
),
/**
...
...
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
浏览文件 @
890faffd
...
...
@@ -76,8 +76,6 @@ import org.apache.dolphinscheduler.service.process.ProcessService;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.hadoop.mapred.TaskLog.LogName
;
import
org.apache.yetus.audience.InterfaceAudience.Public
;
import
java.io.BufferedOutputStream
;
import
java.io.IOException
;
...
...
@@ -108,6 +106,7 @@ import org.springframework.web.multipart.MultipartFile;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.google.common.collect.Lists
;
...
...
@@ -1099,13 +1098,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
putMsg
(
result
,
Status
.
PROCESS_DEFINE_NOT_EXIST
,
codes
);
return
result
;
}
HashMap
<
Long
,
Project
>
userProjects
=
new
HashMap
(
Constants
.
DEFAULT_HASH_MAP_SIZE
);
HashMap
<
Long
,
Project
>
userProjects
=
new
HashMap
<>
(
Constants
.
DEFAULT_HASH_MAP_SIZE
);
projectMapper
.
queryProjectCreatedAndAuthorizedByUserId
(
loginUser
.
getId
())
.
forEach
(
userProject
->
userProjects
.
put
(
userProject
.
getCode
(),
userProject
));
.
forEach
(
userProject
->
userProjects
.
put
(
userProject
.
getCode
(),
userProject
));
// check processDefinition exist in project
List
<
ProcessDefinition
>
processDefinitionListInProject
=
processDefinitionList
.
stream
()
.
filter
(
o
->
userProjects
.
containsKey
(
o
.
getProjectCode
())).
collect
(
Collectors
.
toList
());
List
<
ProcessDefinition
>
processDefinitionListInProject
=
processDefinitionList
.
stream
()
.
filter
(
o
->
userProjects
.
containsKey
(
o
.
getProjectCode
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
processDefinitionListInProject
))
{
putMsg
(
result
,
Status
.
PROCESS_DEFINE_NOT_EXIST
,
codes
);
return
result
;
...
...
@@ -1309,6 +1308,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
List
<
String
>
failedProcessList
=
new
ArrayList
<>();
doBatchOperateProcessDefinition
(
loginUser
,
targetProjectCode
,
failedProcessList
,
codes
,
result
,
true
);
if
(
result
.
get
(
Constants
.
STATUS
)
==
Status
.
NOT_SUPPORT_COPY_TASK_TYPE
)
{
return
result
;
}
checkBatchOperateResult
(
projectCode
,
targetProjectCode
,
result
,
failedProcessList
,
true
);
return
result
;
}
...
...
@@ -1386,18 +1388,35 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
processDefinition
.
setProjectCode
(
targetProjectCode
);
if
(
isCopy
)
{
List
<
TaskDefinitionLog
>
taskDefinitionLogs
=
processService
.
genTaskDefineList
(
processTaskRelations
);
Map
<
Long
,
Long
>
taskCodeMap
=
new
HashMap
<>();
for
(
TaskDefinitionLog
taskDefinitionLog
:
taskDefinitionLogs
)
{
if
(
TaskType
.
CONDITIONS
.
getDesc
().
equals
(
taskDefinitionLog
.
getTaskType
())
||
TaskType
.
SWITCH
.
getDesc
().
equals
(
taskDefinitionLog
.
getTaskType
())
||
TaskType
.
SUB_PROCESS
.
getDesc
().
equals
(
taskDefinitionLog
.
getTaskType
()))
{
||
TaskType
.
SUB_PROCESS
.
getDesc
().
equals
(
taskDefinitionLog
.
getTaskType
())
||
TaskType
.
DEPENDENT
.
getDesc
().
equals
(
taskDefinitionLog
.
getTaskType
()))
{
putMsg
(
result
,
Status
.
NOT_SUPPORT_COPY_TASK_TYPE
,
taskDefinitionLog
.
getTaskType
());
throw
new
ServiceException
(
Status
.
NOT_SUPPORT_COPY_TASK_TYPE
);
return
;
}
try
{
long
taskCode
=
CodeGenerateUtils
.
getInstance
().
genCode
();
taskCodeMap
.
put
(
taskDefinitionLog
.
getCode
(),
taskCode
);
taskDefinitionLog
.
setCode
(
taskCode
);
}
catch
(
CodeGenerateException
e
)
{
putMsg
(
result
,
Status
.
INTERNAL_SERVER_ERROR_ARGS
);
throw
new
ServiceException
(
Status
.
INTERNAL_SERVER_ERROR_ARGS
);
}
taskDefinitionLog
.
setProjectCode
(
targetProjectCode
);
taskDefinitionLog
.
setCode
(
0L
);
taskDefinitionLog
.
setVersion
(
0
);
taskDefinitionLog
.
setName
(
taskDefinitionLog
.
getName
()
+
"_copy_"
+
DateUtils
.
getCurrentTimeStamp
());
}
for
(
ProcessTaskRelationLog
processTaskRelationLog
:
taskRelationList
)
{
if
(
processTaskRelationLog
.
getPreTaskCode
()
>
0
)
{
processTaskRelationLog
.
setPreTaskCode
(
taskCodeMap
.
get
(
processTaskRelationLog
.
getPreTaskCode
()));
}
if
(
processTaskRelationLog
.
getPostTaskCode
()
>
0
)
{
processTaskRelationLog
.
setPostTaskCode
(
taskCodeMap
.
get
(
processTaskRelationLog
.
getPostTaskCode
()));
}
}
try
{
processDefinition
.
setCode
(
CodeGenerateUtils
.
getInstance
().
genCode
());
}
catch
(
CodeGenerateException
e
)
{
...
...
@@ -1407,6 +1426,15 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
processDefinition
.
setId
(
0
);
processDefinition
.
setUserId
(
loginUser
.
getId
());
processDefinition
.
setName
(
processDefinition
.
getName
()
+
"_copy_"
+
DateUtils
.
getCurrentTimeStamp
());
if
(
StringUtils
.
isNotBlank
(
processDefinition
.
getLocations
()))
{
ArrayNode
jsonNodes
=
JSONUtils
.
parseArray
(
processDefinition
.
getLocations
());
for
(
int
i
=
0
;
i
<
jsonNodes
.
size
();
i
++)
{
ObjectNode
node
=
(
ObjectNode
)
jsonNodes
.
path
(
i
);
node
.
put
(
"taskCode"
,
taskCodeMap
.
get
(
node
.
get
(
"taskCode"
).
asLong
()));
jsonNodes
.
set
(
i
,
node
);
}
processDefinition
.
setLocations
(
JSONUtils
.
toJsonString
(
jsonNodes
));
}
try
{
result
.
putAll
(
createDagDefine
(
loginUser
,
taskRelationList
,
processDefinition
,
taskDefinitionLogs
));
}
catch
(
Exception
e
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录