Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyuan
byit-myth-job
Commits
ea296dda
Commit
ea296dda
authored
Jan 07, 2020
by
guominglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
插件端保存工作流修改
parent
0c38bcbb
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
88 additions
and
40 deletions
+88
-40
ApiFlowController.java
...h-admin/src/main/java/com/byit/api/ApiFlowController.java
+2
-2
ApiFlowService.java
...-admin/src/main/java/com/byit/service/ApiFlowService.java
+1
-2
ApiFlowServiceImpl.java
...c/main/java/com/byit/service/impl/ApiFlowServiceImpl.java
+26
-19
ApiWorkspaceServiceImpl.java
...n/java/com/byit/service/impl/ApiWorkspaceServiceImpl.java
+1
-1
NodeDependencyMapper.xml
...n-core/src/main/resources/mapper/NodeDependencyMapper.xml
+1
-1
NodeVersionMapper.xml
...dmin-core/src/main/resources/mapper/NodeVersionMapper.xml
+1
-1
PluginBaseNode.java
...src/main/java/com/byit/job/dto/plugin/PluginBaseNode.java
+1
-5
PluginFlow.java
...mon/src/main/java/com/byit/job/dto/plugin/PluginFlow.java
+3
-2
PluginNode.java
...mon/src/main/java/com/byit/job/dto/plugin/PluginNode.java
+4
-2
PluginPackage.java
.../src/main/java/com/byit/job/dto/plugin/PluginPackage.java
+4
-1
JobUtils.java
...exector-plugin/src/main/java/com/byit/utils/JobUtils.java
+5
-2
Test.java
...ent/byit-demo-client/src/main/java/com/byit/job/Test.java
+39
-2
No files found.
byit-myth-admin/src/main/java/com/byit/api/ApiFlowController.java
View file @
ea296dda
...
@@ -26,8 +26,8 @@ public class ApiFlowController {
...
@@ -26,8 +26,8 @@ public class ApiFlowController {
@PostMapping
(
"publish"
)
@PostMapping
(
"publish"
)
@ApiOperation
(
"发布工作流,并开始调度"
)
@ApiOperation
(
"发布工作流,并开始调度"
)
public
String
publishFlow
(
@RequestBody
PluginPackage
pluginPackage
)
throws
Exception
{
public
String
publishFlow
(
String
param
)
throws
Exception
{
apiFlowService
.
publishFlow
(
p
luginPackage
);
apiFlowService
.
publishFlow
(
p
aram
);
return
"SUCCESS"
;
return
"SUCCESS"
;
}
}
...
...
byit-myth-admin/src/main/java/com/byit/service/ApiFlowService.java
View file @
ea296dda
package
com
.
byit
.
service
;
package
com
.
byit
.
service
;
import
com.byit.job.dto.plugin.PluginFlow
;
import
com.byit.job.dto.plugin.PluginFlow
;
import
com.byit.job.dto.plugin.PluginPackage
;
/**
/**
* @description: 工作流的api请求业务处理接口
* @description: 工作流的api请求业务处理接口
...
@@ -22,7 +21,7 @@ public interface ApiFlowService {
...
@@ -22,7 +21,7 @@ public interface ApiFlowService {
void
reStartSchedule
(
String
runId
);
void
reStartSchedule
(
String
runId
);
void
publishFlow
(
PluginPackage
pluginPackage
)
throws
Exception
;
void
publishFlow
(
String
param
)
throws
Exception
;
/**
/**
* 判断工作流石佛存在
* 判断工作流石佛存在
...
...
byit-myth-admin/src/main/java/com/byit/service/impl/ApiFlowServiceImpl.java
View file @
ea296dda
package
com
.
byit
.
service
.
impl
;
package
com
.
byit
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.byit.enums.DagCheckEnum
;
import
com.byit.enums.DagCheckEnum
;
import
com.byit.enums.FlowPropertyEnum
;
import
com.byit.enums.FlowPropertyEnum
;
import
com.byit.enums.NodePropertyEnum
;
import
com.byit.enums.NodePropertyEnum
;
...
@@ -62,7 +63,10 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -62,7 +63,10 @@ public class ApiFlowServiceImpl implements ApiFlowService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
publishFlow
(
PluginPackage
pluginPackage
)
throws
Exception
{
public
void
publishFlow
(
String
param
)
throws
Exception
{
PluginPackage
pluginPackage
=
JSON
.
parseObject
(
param
,
PluginPackage
.
class
);
//校验参数
//校验参数
log
.
info
(
"校验参数是否符合规范"
);
log
.
info
(
"校验参数是否符合规范"
);
Workspace
workspace
=
validate
(
pluginPackage
);
Workspace
workspace
=
validate
(
pluginPackage
);
...
@@ -115,7 +119,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -115,7 +119,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
if
(
pluginFlow
.
isRePublish
()){
if
(
pluginFlow
.
isRePublish
()){
Flow
oldFlow
=
flowMapper
.
getByWorkSpaceAndName
(
workspaceId
,
pluginFlow
.
getName
());
Flow
oldFlow
=
flowMapper
.
getByWorkSpaceAndName
(
workspaceId
,
pluginFlow
.
getName
());
String
version
=
oldFlow
.
getVersionName
();
String
version
=
oldFlow
.
getVersionName
();
Integer
versionTag
=
Integer
.
valueOf
(
version
.
split
(
"."
)[
1
]);
Integer
versionTag
=
Integer
.
valueOf
(
version
.
split
(
"
\\
."
)[
1
]);
flow
.
setFlowId
(
oldFlow
.
getFlowId
());
flow
.
setFlowId
(
oldFlow
.
getFlowId
());
flow
.
setVersionName
(
"V."
+
(
versionTag
+
1
));
flow
.
setVersionName
(
"V."
+
(
versionTag
+
1
));
flowMapper
.
updateByIdSelective
(
flow
);
flowMapper
.
updateByIdSelective
(
flow
);
...
@@ -256,13 +260,15 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -256,13 +260,15 @@ public class ApiFlowServiceImpl implements ApiFlowService {
*/
*/
public
void
buildDepend
(
List
<
PluginBaseNode
>
nodeList
,
HashMap
<
String
,
Integer
>
nameIdRel
){
public
void
buildDepend
(
List
<
PluginBaseNode
>
nodeList
,
HashMap
<
String
,
Integer
>
nameIdRel
){
for
(
PluginBaseNode
pluginNode
:
nodeList
){
for
(
PluginBaseNode
pluginNode
:
nodeList
){
pluginNode
.
getDependNodeNameList
().
forEach
(
dependNodeName
->
{
if
(
null
!=
pluginNode
.
getDependNodeNameList
()
&&
pluginNode
.
getDependNodeNameList
().
size
()
>
0
){
Integer
nodeId
=
nameIdRel
.
get
(
pluginNode
.
getName
());
pluginNode
.
getDependNodeNameList
().
forEach
(
dependNodeName
->
{
Integer
dependNodeId
=
nameIdRel
.
get
(
dependNodeName
);
Integer
nodeId
=
nameIdRel
.
get
(
pluginNode
.
getName
());
ValidationUtil
.
isTrueValidation
(
null
==
nodeId
,
pluginNode
.
getName
()
+
"节点不存在!"
);
Integer
dependNodeId
=
nameIdRel
.
get
(
dependNodeName
);
ValidationUtil
.
isTrueValidation
(
null
==
dependNodeId
,
"依赖的节点"
+
dependNodeName
+
"不存在!"
);
ValidationUtil
.
isTrueValidation
(
null
==
nodeId
,
pluginNode
.
getName
()
+
"节点不存在!"
);
nodeDependencyMapper
.
insert
(
nodeId
,
dependNodeId
);
ValidationUtil
.
isTrueValidation
(
null
==
dependNodeId
,
"依赖的节点"
+
dependNodeName
+
"不存在!"
);
});
nodeDependencyMapper
.
insert
(
nodeId
,
dependNodeId
);
});
}
}
}
}
}
...
@@ -295,7 +301,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -295,7 +301,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
flowDagCheck
.
initDag
(
flowNameSet
,
fromFlowSet
,
toFlowSet
,
lineMap
);
flowDagCheck
.
initDag
(
flowNameSet
,
fromFlowSet
,
toFlowSet
,
lineMap
);
//校验是否存在环路
//校验是否存在环路
DagCheckEnum
loopCheck
=
flowDagCheck
.
checkDag
();
DagCheckEnum
loopCheck
=
flowDagCheck
.
checkDag
();
ValidationUtil
.
isTrueValidation
(
DagCheckEnum
.
PASS
.
getCode
().
equals
(
loopCheck
.
getCode
()),
loopCheck
.
getMsg
());
ValidationUtil
.
isTrueValidation
(
!
DagCheckEnum
.
PASS
.
getCode
().
equals
(
loopCheck
.
getCode
()),
loopCheck
.
getMsg
());
return
workspace
;
return
workspace
;
}
}
...
@@ -345,16 +351,16 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -345,16 +351,16 @@ public class ApiFlowServiceImpl implements ApiFlowService {
nodeDagCheck
.
initDag
(
nodeList
);
nodeDagCheck
.
initDag
(
nodeList
);
//校验开始节点名称
//校验开始节点名称
DagCheckEnum
checkStart
=
nodeDagCheck
.
checkStart
();
DagCheckEnum
checkStart
=
nodeDagCheck
.
checkStart
();
ValidationUtil
.
isTrueValidation
(
DagCheckEnum
.
PASS
.
getCode
().
equals
(
checkStart
.
getCode
()),
checkStart
.
getCode
()
==
0
?
checkStart
.
getMsg
()
:
checkStart
.
getMsg
()
+
"start"
);
ValidationUtil
.
isTrueValidation
(
!
DagCheckEnum
.
PASS
.
getCode
().
equals
(
checkStart
.
getCode
()),
checkStart
.
getCode
()
==
0
?
checkStart
.
getMsg
()
:
checkStart
.
getMsg
()
+
"start"
);
//校验结束节点名称
//校验结束节点名称
DagCheckEnum
endCheck
=
nodeDagCheck
.
checkEnd
();
DagCheckEnum
endCheck
=
nodeDagCheck
.
checkEnd
();
ValidationUtil
.
isTrueValidation
(
DagCheckEnum
.
PASS
.
getCode
().
equals
(
endCheck
.
getCode
()),
endCheck
.
getCode
()
==
0
?
endCheck
.
getMsg
()
:
endCheck
.
getMsg
()
+
"end"
);
ValidationUtil
.
isTrueValidation
(
!
DagCheckEnum
.
PASS
.
getCode
().
equals
(
endCheck
.
getCode
()),
endCheck
.
getCode
()
==
0
?
endCheck
.
getMsg
()
:
endCheck
.
getMsg
()
+
"end"
);
//校验是否有游离节点
//校验是否有游离节点
DagCheckEnum
freeCheck
=
nodeDagCheck
.
checkFreeNode
();
DagCheckEnum
freeCheck
=
nodeDagCheck
.
checkFreeNode
();
ValidationUtil
.
isTrueValidation
(
DagCheckEnum
.
PASS
.
getCode
().
equals
(
freeCheck
.
getCode
()),
freeCheck
.
getMsg
());
ValidationUtil
.
isTrueValidation
(
!
DagCheckEnum
.
PASS
.
getCode
().
equals
(
freeCheck
.
getCode
()),
freeCheck
.
getMsg
());
//校验是否存在环路
//校验是否存在环路
DagCheckEnum
loopCheck
=
nodeDagCheck
.
checkDag
();
DagCheckEnum
loopCheck
=
nodeDagCheck
.
checkDag
();
ValidationUtil
.
isTrueValidation
(
DagCheckEnum
.
PASS
.
getCode
().
equals
(
loopCheck
.
getCode
()),
loopCheck
.
getMsg
());
ValidationUtil
.
isTrueValidation
(
!
DagCheckEnum
.
PASS
.
getCode
().
equals
(
loopCheck
.
getCode
()),
loopCheck
.
getMsg
());
}
}
@Override
@Override
...
@@ -365,7 +371,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -365,7 +371,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
ValidationUtil
.
dataNotBank
(
pluginFlow
.
getConfig
().
getExecType
(),
"工作流的调度类型不允许为空!"
);
ValidationUtil
.
dataNotBank
(
pluginFlow
.
getConfig
().
getExecType
(),
"工作流的调度类型不允许为空!"
);
if
(
FlowPropertyEnum
.
SCHEDULE_MODE
.
getCode
().
equals
(
pluginFlow
.
getConfig
().
getExecType
())){
if
(
FlowPropertyEnum
.
SCHEDULE_MODE
.
getCode
().
equals
(
pluginFlow
.
getConfig
().
getExecType
())){
ValidationUtil
.
dataNotBank
(
pluginFlow
.
getConfig
().
getFlowCron
(),
"工作流cron表达式不允许为空!"
);
ValidationUtil
.
dataNotBank
(
pluginFlow
.
getConfig
().
getFlowCron
(),
"工作流cron表达式不允许为空!"
);
ValidationUtil
.
isTrueValidation
(
CronExpression
.
isValidExpression
(
pluginFlow
.
getConfig
().
getFlowCron
()),
"工作流cron表达式不符合规范!"
);
ValidationUtil
.
isTrueValidation
(
!
CronExpression
.
isValidExpression
(
pluginFlow
.
getConfig
().
getFlowCron
()),
"工作流cron表达式不符合规范!"
);
}
}
if
(!
FlowPropertyEnum
.
NO_ALARML
.
getCode
().
equals
(
pluginFlow
.
getConfig
().
getAlarmlAction
())){
if
(!
FlowPropertyEnum
.
NO_ALARML
.
getCode
().
equals
(
pluginFlow
.
getConfig
().
getAlarmlAction
())){
ValidationUtil
.
dataNotBank
(
pluginFlow
.
getConfig
().
getAlarmEmail
(),
"设置告警时机时告警邮箱不允许为空!"
);
ValidationUtil
.
dataNotBank
(
pluginFlow
.
getConfig
().
getAlarmEmail
(),
"设置告警时机时告警邮箱不允许为空!"
);
...
@@ -374,9 +380,9 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -374,9 +380,9 @@ public class ApiFlowServiceImpl implements ApiFlowService {
//判断是否是重发
//判断是否是重发
//是重发
//是重发
if
(
pluginFlow
.
isRePublish
()){
if
(
pluginFlow
.
isRePublish
()){
ValidationUtil
.
dataNotNull
(
flow
,
"工作流【"
+
flow
.
getFlow
Name
()
+
"】不存在!"
);
ValidationUtil
.
dataNotNull
(
flow
,
"工作流【"
+
pluginFlow
.
get
Name
()
+
"】不存在!"
);
}
else
{
//不是重发
}
else
{
//不是重发
ValidationUtil
.
isTrueValidation
(
null
!=
flow
,
"工作流【"
+
flow
.
getFlow
Name
()
+
"】已存在!"
);
ValidationUtil
.
isTrueValidation
(
null
!=
flow
,
"工作流【"
+
pluginFlow
.
get
Name
()
+
"】已存在!"
);
}
}
}
}
...
@@ -420,11 +426,12 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -420,11 +426,12 @@ public class ApiFlowServiceImpl implements ApiFlowService {
NodeVersion
nodeVersion
=
new
NodeVersion
();
NodeVersion
nodeVersion
=
new
NodeVersion
();
BeanUtils
.
copyProperties
(
node
,
nodeVersion
);
BeanUtils
.
copyProperties
(
node
,
nodeVersion
);
nodeVersion
.
setAddTime
(
currentDate
);
nodeVersion
.
setAddTime
(
currentDate
);
nodeVersion
.
setFlowVersionId
(
flowVersion
.
getFlowVersionId
());
nodeVersion
.
setVersionMark
(
FlowPropertyEnum
.
IS_CURRENTVERSION
.
getCode
());
nodeVersion
.
setVersionMark
(
FlowPropertyEnum
.
IS_CURRENTVERSION
.
getCode
());
if
(
null
!=
node
.
getIsVirtual
()
&&
NodePropertyEnum
.
IS_VIRTUAL
.
equals
(
node
.
getIsVirtual
())){
if
(
null
!=
node
.
getIsVirtual
()
&&
NodePropertyEnum
.
IS_VIRTUAL
.
getCode
().
equals
(
node
.
getIsVirtual
())){
Flow
innerFlow
=
flowMapper
.
getById
(
node
.
getMapFlowId
());
Flow
innerFlow
=
flowMapper
.
getById
(
node
.
getMapFlowId
());
FlowVersion
innerFlowVersion
=
saveFlowVersion
(
innerFlow
);
FlowVersion
innerFlowVersion
=
saveFlowVersion
(
innerFlow
);
node
.
setMapFlowId
(
innerFlowVersion
.
getFlowVersionId
());
node
Version
.
setMapFlowId
(
innerFlowVersion
.
getFlowVersionId
());
}
}
nodeVersionMapper
.
insertSelective
(
nodeVersion
);
nodeVersionMapper
.
insertSelective
(
nodeVersion
);
idVersionIdRel
.
put
(
node
.
getNodeId
(),
nodeVersion
.
getNodeVersionId
());
idVersionIdRel
.
put
(
node
.
getNodeId
(),
nodeVersion
.
getNodeVersionId
());
...
...
byit-myth-admin/src/main/java/com/byit/service/impl/ApiWorkspaceServiceImpl.java
View file @
ea296dda
...
@@ -26,7 +26,7 @@ public class ApiWorkspaceServiceImpl implements ApiWorkspaceService {
...
@@ -26,7 +26,7 @@ public class ApiWorkspaceServiceImpl implements ApiWorkspaceService {
public
void
add
(
String
workspaceName
)
{
public
void
add
(
String
workspaceName
)
{
ValidationUtil
.
dataNotBank
(
workspaceName
,
"工作空间名称为空!"
);
ValidationUtil
.
dataNotBank
(
workspaceName
,
"工作空间名称为空!"
);
Workspace
workspace
=
workspaceMapper
.
getByName
(
workspaceName
);
Workspace
workspace
=
workspaceMapper
.
getByName
(
workspaceName
);
ValidationUtil
.
dataNotNull
(
workspace
,
"工作空间已存在!"
);
ValidationUtil
.
isTrueValidation
(
null
!=
workspace
,
"工作空间已存在!"
);
workspace
=
new
Workspace
();
workspace
=
new
Workspace
();
workspace
.
setWorkspaceName
(
workspaceName
);
workspace
.
setWorkspaceName
(
workspaceName
);
workspace
.
setAddTime
(
new
Date
());
workspace
.
setAddTime
(
new
Date
());
...
...
byit-myth-core/myth-admin-core/src/main/resources/mapper/NodeDependencyMapper.xml
View file @
ea296dda
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
<insert
id=
"insert"
>
<insert
id=
"insert"
>
<!-- generated @mbg.generated date: 2019-12-31 -->
<!-- generated @mbg.generated date: 2019-12-31 -->
insert into node_dependency (node_id, dependency_id)
insert into node_dependency (node_id, dependency_id)
values (#{nodeId,jdbcType=INTEGER}, #{depend
ency
Id,jdbcType=INTEGER})
values (#{nodeId,jdbcType=INTEGER}, #{depend
Node
Id,jdbcType=INTEGER})
</insert>
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.byit.model.NodeDependencyKey"
>
<insert
id=
"insertSelective"
parameterType=
"com.byit.model.NodeDependencyKey"
>
<!-- generated @mbg.generated date: 2019-12-31 -->
<!-- generated @mbg.generated date: 2019-12-31 -->
...
...
byit-myth-core/myth-admin-core/src/main/resources/mapper/NodeVersionMapper.xml
View file @
ea296dda
...
@@ -72,7 +72,7 @@
...
@@ -72,7 +72,7 @@
where node_version_id = #{nodeVersionId,jdbcType=INTEGER}
where node_version_id = #{nodeVersionId,jdbcType=INTEGER}
</delete>
</delete>
<insert
id=
"insertSelective"
parameterType=
"com.byit.model.NodeVersion"
>
<insert
id=
"insertSelective"
useGeneratedKeys=
"true"
keyProperty=
"nodeVersionId"
parameterType=
"com.byit.model.NodeVersion"
>
<!-- generated @mbg.generated date: 2019-12-31 -->
<!-- generated @mbg.generated date: 2019-12-31 -->
insert into node_version
insert into node_version
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
...
...
byit-myth-core/myth-core-common/src/main/java/com/byit/job/dto/plugin/PluginBaseNode.java
View file @
ea296dda
...
@@ -2,7 +2,6 @@ package com.byit.job.dto.plugin;
...
@@ -2,7 +2,6 @@ package com.byit.job.dto.plugin;
import
lombok.Data
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -12,7 +11,7 @@ import java.util.List;
...
@@ -12,7 +11,7 @@ import java.util.List;
*/
*/
@Data
@Data
public
class
PluginBaseNode
implements
Serializable
{
public
class
PluginBaseNode
{
/**
/**
* 名称
* 名称
*/
*/
...
@@ -37,7 +36,4 @@ public class PluginBaseNode implements Serializable {
...
@@ -37,7 +36,4 @@ public class PluginBaseNode implements Serializable {
* 依赖的任务节点名称集合,只能是节点的名称,如果不是内嵌工作流不允许设置依赖
* 依赖的任务节点名称集合,只能是节点的名称,如果不是内嵌工作流不允许设置依赖
*/
*/
private
List
<
String
>
dependNodeNameList
;
private
List
<
String
>
dependNodeNameList
;
private
static
final
long
serialVersionUID
=
1L
;
}
}
byit-myth-core/myth-core-common/src/main/java/com/byit/job/dto/plugin/PluginFlow.java
View file @
ea296dda
...
@@ -2,6 +2,7 @@ package com.byit.job.dto.plugin;
...
@@ -2,6 +2,7 @@ package com.byit.job.dto.plugin;
import
lombok.Data
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -10,7 +11,7 @@ import java.util.List;
...
@@ -10,7 +11,7 @@ import java.util.List;
* @create: 2019-12-30 10:44
* @create: 2019-12-30 10:44
*/
*/
@Data
@Data
public
class
PluginFlow
extends
PluginBaseNode
{
public
class
PluginFlow
extends
PluginBaseNode
implements
Serializable
{
/**
/**
* 责任人
* 责任人
...
@@ -32,5 +33,5 @@ public class PluginFlow extends PluginBaseNode {
...
@@ -32,5 +33,5 @@ public class PluginFlow extends PluginBaseNode {
*/
*/
private
PluginFlowConfig
config
;
private
PluginFlowConfig
config
;
private
static
final
long
serialVersionUID
=
1
L
;
private
static
final
long
serialVersionUID
=
3
L
;
}
}
byit-myth-core/myth-core-common/src/main/java/com/byit/job/dto/plugin/PluginNode.java
View file @
ea296dda
...
@@ -2,13 +2,15 @@ package com.byit.job.dto.plugin;
...
@@ -2,13 +2,15 @@ package com.byit.job.dto.plugin;
import
lombok.Data
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
/**
* @description: 插件端的任务节点
* @description: 插件端的任务节点
* @author: gml
* @author: gml
* @create: 2019-12-30 10:45
* @create: 2019-12-30 10:45
*/
*/
@Data
@Data
public
class
PluginNode
extends
PluginBaseNode
{
public
class
PluginNode
extends
PluginBaseNode
implements
Serializable
{
/**
/**
* 当前任务的类型 JAVA PYTHON SHELL SQL SCRIPT
* 当前任务的类型 JAVA PYTHON SHELL SQL SCRIPT
...
@@ -49,5 +51,5 @@ public class PluginNode extends PluginBaseNode {
...
@@ -49,5 +51,5 @@ public class PluginNode extends PluginBaseNode {
*/
*/
private
PluginNodeConfig
config
;
private
PluginNodeConfig
config
;
private
static
final
long
serialVersionUID
=
2L
;
}
}
byit-myth-core/myth-core-common/src/main/java/com/byit/job/dto/plugin/PluginPackage.java
View file @
ea296dda
...
@@ -2,13 +2,15 @@ package com.byit.job.dto.plugin;
...
@@ -2,13 +2,15 @@ package com.byit.job.dto.plugin;
import
lombok.Data
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
/**
* @description: 插件段的发布包
* @description: 插件段的发布包
* @author: gml
* @author: gml
* @create: 2020-01-02 14:38
* @create: 2020-01-02 14:38
*/
*/
@Data
@Data
public
class
PluginPackage
{
public
class
PluginPackage
implements
Serializable
{
/**
/**
* 工作空间名称
* 工作空间名称
...
@@ -20,4 +22,5 @@ public class PluginPackage {
...
@@ -20,4 +22,5 @@ public class PluginPackage {
*/
*/
private
PluginFlow
flow
;
private
PluginFlow
flow
;
private
static
final
long
serialVersionUID
=
11L
;
}
}
byit-myth-executor/myth-exector-plugin/src/main/java/com/byit/utils/JobUtils.java
View file @
ea296dda
...
@@ -2,11 +2,11 @@ package com.byit.utils;
...
@@ -2,11 +2,11 @@ package com.byit.utils;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.byit.job.dto.PluginBeanJobInfo
;
import
com.byit.job.dto.plugin.PluginPackage
;
import
com.byit.job.dto.plugin.PluginPackage
;
import
com.byit.job.enums.plugin.PluginEnum
;
import
com.byit.job.enums.plugin.PluginEnum
;
import
com.byit.job.exceptions.plugin.PluginException
;
import
com.byit.job.exceptions.plugin.PluginException
;
import
com.byit.job.handler.interfaces.IJobHandler
;
import
com.byit.job.handler.interfaces.IJobHandler
;
import
com.byit.job.dto.PluginBeanJobInfo
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -15,6 +15,8 @@ import java.net.URLDecoder;
...
@@ -15,6 +15,8 @@ import java.net.URLDecoder;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
static
com
.
alibaba
.
fastjson
.
serializer
.
SerializerFeature
.
WriteClassName
;
/**
/**
* @program: byit-myth-job->JobFactory
* @program: byit-myth-job->JobFactory
* @description: 创建任务的工具类
* @description: 创建任务的工具类
...
@@ -67,7 +69,8 @@ public class JobUtils {
...
@@ -67,7 +69,8 @@ public class JobUtils {
//请求的路径
//请求的路径
String
requestUrl
=
REQUEST_PREFIX
+
"127.0.0.1"
+
":"
+
"8080"
+
REQUEST_FLOW_PUBLISH
;
String
requestUrl
=
REQUEST_PREFIX
+
"127.0.0.1"
+
":"
+
"8080"
+
REQUEST_FLOW_PUBLISH
;
//发送请求 添加任务
//发送请求 添加任务
String
addRequestResult
=
HttpUtil
.
post
(
requestUrl
,
"pluginPackageParam="
+
JSON
.
toJSONString
(
pluginPackage
));
String
addRequestResult
=
HttpUtil
.
post
(
requestUrl
,
"param="
+
JSON
.
toJSONString
(
pluginPackage
,
WriteClassName
));
// String addRequestResult = HttpUtil.post(requestUrl, JSON.toJSONString(pluginPackage, WriteClassName));
log
.
info
(
"--------------------添加任务完成,添加结果为:{}------------------------"
,
addRequestResult
);
log
.
info
(
"--------------------添加任务完成,添加结果为:{}------------------------"
,
addRequestResult
);
return
addRequestResult
;
return
addRequestResult
;
}
}
...
...
demo-client/byit-demo-client/src/main/java/com/byit/job/Test.java
View file @
ea296dda
...
@@ -29,7 +29,7 @@ public class Test {
...
@@ -29,7 +29,7 @@ public class Test {
PluginFlow
flow
=
new
PluginFlow
();
PluginFlow
flow
=
new
PluginFlow
();
flow
.
setName
(
name
);
flow
.
setName
(
name
);
flow
.
setRePublish
(
fals
e
);
flow
.
setRePublish
(
tru
e
);
flow
.
setPrincipal
(
"admin"
);
flow
.
setPrincipal
(
"admin"
);
PluginFlowConfig
flowConfig
=
new
PluginFlowConfig
();
PluginFlowConfig
flowConfig
=
new
PluginFlowConfig
();
...
@@ -42,6 +42,40 @@ public class Test {
...
@@ -42,6 +42,40 @@ public class Test {
PluginNode
start
=
getNode
(
"start"
,
"echo start"
,
"echo start"
,
null
);
PluginNode
start
=
getNode
(
"start"
,
"echo start"
,
"echo start"
,
null
);
PluginNode
center
=
getNode
(
"center"
,
"echo center"
,
"echo center"
,
"start"
);
PluginNode
center
=
getNode
(
"center"
,
"echo center"
,
"echo center"
,
"start"
);
PluginFlow
innerFlow
=
getInnerFlow
(
"inner"
,
"start"
);
PluginNode
end
=
getNode
(
"end"
,
"echo end"
,
"echo end"
,
"center,inner"
);
List
<
PluginBaseNode
>
nodeList
=
new
ArrayList
<>();
nodeList
.
add
(
start
);
nodeList
.
add
(
center
);
nodeList
.
add
(
end
);
nodeList
.
add
(
innerFlow
);
flow
.
setConfig
(
flowConfig
);
flow
.
setNodeList
(
nodeList
);
return
flow
;
}
public
static
PluginFlow
getInnerFlow
(
String
name
,
String
dependNames
){
PluginFlow
flow
=
new
PluginFlow
();
flow
.
setName
(
name
);
flow
.
setRePublish
(
true
);
flow
.
setPrincipal
(
"admin"
);
flow
.
setType
(
"flow"
);
PluginFlowConfig
flowConfig
=
new
PluginFlowConfig
();
flowConfig
.
setAlarmlAction
(
"1"
);
flowConfig
.
setExecType
(
"1"
);
flowConfig
.
setFlowCron
(
"0 0 2 * * ? *"
);
flowConfig
.
setPriority
(
"1"
);
flowConfig
.
setScheduleFollow
(
"1"
);
flowConfig
.
setAlarmEmail
(
"qwe@qq.com"
);
PluginNode
start
=
getNode
(
"start"
,
"echo start"
,
"echo start"
,
null
);
PluginNode
center
=
getNode
(
"center"
,
"echo center"
,
"echo center"
,
"start"
);
PluginNode
end
=
getNode
(
"end"
,
"echo end"
,
"echo end"
,
"center"
);
PluginNode
end
=
getNode
(
"end"
,
"echo end"
,
"echo end"
,
"center"
);
List
<
PluginBaseNode
>
nodeList
=
new
ArrayList
<>();
List
<
PluginBaseNode
>
nodeList
=
new
ArrayList
<>();
...
@@ -52,6 +86,9 @@ public class Test {
...
@@ -52,6 +86,9 @@ public class Test {
flow
.
setConfig
(
flowConfig
);
flow
.
setConfig
(
flowConfig
);
flow
.
setNodeList
(
nodeList
);
flow
.
setNodeList
(
nodeList
);
if
(
StringUtils
.
isNotEmpty
(
dependNames
))
{
flow
.
setDependNodeNameList
(
Arrays
.
asList
(
dependNames
));
}
return
flow
;
return
flow
;
}
}
...
@@ -69,7 +106,7 @@ public class Test {
...
@@ -69,7 +106,7 @@ public class Test {
nodeConfig
.
setPriority
(
"1"
);
nodeConfig
.
setPriority
(
"1"
);
node
.
setConfig
(
nodeConfig
);
node
.
setConfig
(
nodeConfig
);
if
(
StringUtils
.
isNotEmpty
(
dependNames
))
{
if
(
StringUtils
.
isNotEmpty
(
dependNames
))
{
node
.
setDependNodeNameList
(
Arrays
.
asList
(
dependNames
));
node
.
setDependNodeNameList
(
Arrays
.
asList
(
dependNames
.
split
(
","
)
));
}
}
return
node
;
return
node
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment