Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
三久
DolphinScheduler
提交
c34503e3
DolphinScheduler
项目概览
三久
/
DolphinScheduler
与 Fork 源项目一致
Fork自
apache / DolphinScheduler
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
未验证
提交
c34503e3
编写于
8月 04, 2022
作者:
Z
zhuxt2015
提交者:
GitHub
8月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[fix] Process definition length too long when copy or import (#10621)
上级
acd3d3fa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
4 deletion
+45
-4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
...eduler/api/service/impl/ProcessDefinitionServiceImpl.java
+27
-4
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
...inscheduler/api/service/ProcessDefinitionServiceTest.java
+14
-0
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
...in/java/org/apache/dolphinscheduler/common/Constants.java
+4
-0
未找到文件。
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
浏览文件 @
c34503e3
...
...
@@ -32,8 +32,10 @@ import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationCon
import
static
org
.
apache
.
dolphinscheduler
.
api
.
constants
.
ApiFuncIdentificationConstant
.
WORKFLOW_TREE_VIEW
;
import
static
org
.
apache
.
dolphinscheduler
.
api
.
constants
.
ApiFuncIdentificationConstant
.
WORKFLOW_UPDATE
;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
CMD_PARAM_SUB_PROCESS_DEFINE_CODE
;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
COPY_SUFFIX
;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
DEFAULT_WORKER_GROUP
;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
EMPTY_STRING
;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
IMPORT_SUFFIX
;
import
static
org
.
apache
.
dolphinscheduler
.
plugin
.
task
.
api
.
TaskConstants
.
COMPLEX_TASK_TYPES
;
import
static
org
.
apache
.
dolphinscheduler
.
plugin
.
task
.
api
.
TaskConstants
.
TASK_TYPE_SQL
;
...
...
@@ -1010,7 +1012,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
if
(
index
>
0
)
{
processDefinitionName
=
processDefinitionName
.
substring
(
0
,
index
);
}
processDefinitionName
=
processDefinitionName
+
"_import_"
+
DateUtils
.
getCurrentTimeStamp
(
);
processDefinitionName
=
getNewName
(
processDefinitionName
,
IMPORT_SUFFIX
);
ProcessDefinition
processDefinition
;
List
<
TaskDefinitionLog
>
taskDefinitionList
=
new
ArrayList
<>();
...
...
@@ -1206,8 +1208,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
// generate import processDefinitionName
String
processDefinitionName
=
recursionProcessDefinitionName
(
projectCode
,
processDefinition
.
getName
(),
1
);
String
importProcessDefinitionName
=
processDefinitionName
+
"_import_"
+
DateUtils
.
getCurrentTimeStamp
();
String
importProcessDefinitionName
=
getNewName
(
processDefinitionName
,
IMPORT_SUFFIX
);
//unique check
Map
<
String
,
Object
>
checkResult
=
verifyProcessDefinitionName
(
loginUser
,
projectCode
,
importProcessDefinitionName
);
if
(
Status
.
SUCCESS
.
equals
(
checkResult
.
get
(
Constants
.
STATUS
)))
{
...
...
@@ -1844,7 +1845,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
processDefinition
.
setId
(
0
);
processDefinition
.
setUserId
(
loginUser
.
getId
());
processDefinition
.
setName
(
processDefinition
.
getName
()
+
"_copy_"
+
DateUtils
.
getCurrentTimeStamp
(
));
processDefinition
.
setName
(
getNewName
(
processDefinition
.
getName
(),
COPY_SUFFIX
));
final
Date
date
=
new
Date
();
processDefinition
.
setCreateTime
(
date
);
processDefinition
.
setUpdateTime
(
date
);
...
...
@@ -1891,6 +1892,28 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
/**
* get new Task name or Process name when copy or import operate
* @param originalName Task or Process original name
* @param suffix "_copy_" or "_import_"
* @return
*/
public
String
getNewName
(
String
originalName
,
String
suffix
)
{
StringBuilder
newName
=
new
StringBuilder
();
String
regex
=
String
.
format
(
".*%s\\d{17}$"
,
suffix
);
if
(
originalName
.
matches
(
regex
))
{
//replace timestamp of originalName
return
newName
.
append
(
originalName
,
0
,
originalName
.
lastIndexOf
(
suffix
))
.
append
(
suffix
)
.
append
(
DateUtils
.
getCurrentTimeStamp
())
.
toString
();
}
return
newName
.
append
(
originalName
)
.
append
(
suffix
)
.
append
(
DateUtils
.
getCurrentTimeStamp
())
.
toString
();
}
/**
* switch the defined process definition version
*
...
...
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
浏览文件 @
c34503e3
...
...
@@ -41,6 +41,7 @@ import org.apache.dolphinscheduler.common.enums.ReleaseState;
import
org.apache.dolphinscheduler.common.enums.UserType
;
import
org.apache.dolphinscheduler.common.enums.WarningType
;
import
org.apache.dolphinscheduler.common.graph.DAG
;
import
org.apache.dolphinscheduler.common.utils.DateUtils
;
import
org.apache.dolphinscheduler.common.utils.JSONUtils
;
import
org.apache.dolphinscheduler.dao.entity.DagData
;
import
org.apache.dolphinscheduler.dao.entity.DataSource
;
...
...
@@ -761,6 +762,19 @@ public class ProcessDefinitionServiceTest {
Assert
.
assertEquals
(
result
.
get
(
Constants
.
STATUS
),
Status
.
SUCCESS
);
}
@Test
public
void
testGetNewProcessName
()
{
String
processName1
=
"test_copy_"
+
DateUtils
.
getCurrentTimeStamp
();
final
String
newName1
=
processDefinitionService
.
getNewName
(
processName1
,
Constants
.
COPY_SUFFIX
);
Assert
.
assertEquals
(
2
,
newName1
.
split
(
Constants
.
COPY_SUFFIX
).
length
);
String
processName2
=
"wf_copy_all_ods_data_to_d"
;
final
String
newName2
=
processDefinitionService
.
getNewName
(
processName2
,
Constants
.
COPY_SUFFIX
);
Assert
.
assertEquals
(
3
,
newName2
.
split
(
Constants
.
COPY_SUFFIX
).
length
);
String
processName3
=
"test_import_"
+
DateUtils
.
getCurrentTimeStamp
();
final
String
newName3
=
processDefinitionService
.
getNewName
(
processName3
,
Constants
.
IMPORT_SUFFIX
);
Assert
.
assertEquals
(
2
,
newName3
.
split
(
Constants
.
IMPORT_SUFFIX
).
length
);
}
/**
* get mock processDefinition
*
...
...
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
浏览文件 @
c34503e3
...
...
@@ -215,6 +215,10 @@ public final class Constants {
* date format of yyyyMMddHHmmssSSS
*/
public
static
final
String
YYYYMMDDHHMMSSSSS
=
"yyyyMMddHHmmssSSS"
;
public
static
final
String
IMPORT_SUFFIX
=
"_import_"
;
public
static
final
String
COPY_SUFFIX
=
"_copy_"
;
/**
* http connect time out
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录