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
a99c4b7e
Commit
a99c4b7e
authored
Dec 14, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除所有的公共参数替换,发布工作流的时候保存工作流的内嵌层级
parent
d5ac8f22
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
122 additions
and
63 deletions
+122
-63
ApiFlowOperatingServiceImpl.java
...va/com/byit/service/impl/ApiFlowOperatingServiceImpl.java
+0
-0
ApiFlowServiceImpl.java
...c/main/java/com/byit/service/impl/ApiFlowServiceImpl.java
+18
-24
RedisKeyNameEnum.java
...n-core/src/main/java/com/byit/enums/RedisKeyNameEnum.java
+23
-0
RunRecording.java
...admin-core/src/main/java/com/byit/model/RunRecording.java
+3
-3
RunNodeServiceImpl.java
...c/main/java/com/byit/service/impl/RunNodeServiceImpl.java
+23
-23
RunRecordingAndJobTaskServiceImpl.java
...ce/mapservice/impl/RunRecordingAndJobTaskServiceImpl.java
+5
-3
InstanceRunTheLifeCycleCallback.java
...va/com/byit/strategy/InstanceRunTheLifeCycleCallback.java
+4
-3
RpcCallbackInstanceRunTheLifeCycleCallback.java
...tegy/impl/RpcCallbackInstanceRunTheLifeCycleCallback.java
+0
-0
RunRecordingRunRedisRemoveTheLifeCycleCallback.java
.../impl/RunRecordingRunRedisRemoveTheLifeCycleCallback.java
+38
-0
RunRecordingMapper.xml
...min-core/src/main/resources/mapper/RunRecordingMapper.xml
+2
-2
CallbackDto.java
...o-core/src/main/java/com/byit/dto/common/CallbackDto.java
+1
-0
FlowExtendedConfiguration.java
...n/java/com/byit/dto/plugin/FlowExtendedConfiguration.java
+5
-0
PluginFlowConfig.java
...e/src/main/java/com/byit/dto/plugin/PluginFlowConfig.java
+0
-5
No files found.
byit-myth-admin/src/main/java/com/byit/service/impl/ApiFlowOperatingServiceImpl.java
View file @
a99c4b7e
This diff is collapsed.
Click to expand it.
byit-myth-admin/src/main/java/com/byit/service/impl/ApiFlowServiceImpl.java
View file @
a99c4b7e
...
@@ -14,7 +14,6 @@ import com.byit.dto.specials.RepairFlow;
...
@@ -14,7 +14,6 @@ import com.byit.dto.specials.RepairFlow;
import
com.byit.dto.specials.RepairTimeParam
;
import
com.byit.dto.specials.RepairTimeParam
;
import
com.byit.enums.*
;
import
com.byit.enums.*
;
import
com.byit.enums.plugin.PluginNodeTypeEnum
;
import
com.byit.enums.plugin.PluginNodeTypeEnum
;
import
com.byit.enums.task.RunResultEnum
;
import
com.byit.job.utils.CronExpression
;
import
com.byit.job.utils.CronExpression
;
import
com.byit.job.utils.CurrentUserUtils
;
import
com.byit.job.utils.CurrentUserUtils
;
import
com.byit.job.utils.PlaceholderUtils
;
import
com.byit.job.utils.PlaceholderUtils
;
...
@@ -132,7 +131,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -132,7 +131,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
Workspace
workspace
=
validate
(
pluginPackage
);
Workspace
workspace
=
validate
(
pluginPackage
);
//保存工作流
//保存工作流
log
.
debug
(
"保存工作流和节点信息"
);
log
.
debug
(
"保存工作流和节点信息"
);
Flow
flow
=
saveFlow
(
pluginPackage
.
getFlow
(),
workspace
.
getWorkspaceId
(),
false
);
Flow
flow
=
saveFlow
(
pluginPackage
.
getFlow
(),
workspace
.
getWorkspaceId
(),
false
,
""
);
//生成工作流版本
//生成工作流版本
log
.
debug
(
"生成版本"
);
log
.
debug
(
"生成版本"
);
FlowVersion
flowVersion
=
saveFlowVersion
(
flow
);
FlowVersion
flowVersion
=
saveFlowVersion
(
flow
);
...
@@ -149,10 +148,10 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -149,10 +148,10 @@ public class ApiFlowServiceImpl implements ApiFlowService {
* @param isInnner
* @param isInnner
* @param workspaceId
* @param workspaceId
*/
*/
private
Flow
saveFlow
(
PluginFlow
pluginFlow
,
Integer
workspaceId
,
boolean
isInnner
)
throws
Exception
{
private
Flow
saveFlow
(
PluginFlow
pluginFlow
,
Integer
workspaceId
,
boolean
isInnner
,
String
upFlowName
)
throws
Exception
{
//拼装工作流名称
upFlowName
=
String
.
format
(
"%s:%s"
,
upFlowName
,
pluginFlow
.
getName
());
Flow
flow
=
new
Flow
();
Flow
flow
=
new
Flow
();
flow
.
setExtendedConfiguration
(
JSON
.
toJSONString
(
pluginFlow
.
getConfig
().
getExtendedConfiguration
()));
flow
.
setFlowName
(
pluginFlow
.
getName
());
flow
.
setFlowName
(
pluginFlow
.
getName
());
flow
.
setIsInner
(
isInnner
?
"0"
:
"1"
);
flow
.
setIsInner
(
isInnner
?
"0"
:
"1"
);
flow
.
setFlowNodeCount
(
pluginFlow
.
getNodeList
().
size
());
flow
.
setFlowNodeCount
(
pluginFlow
.
getNodeList
().
size
());
...
@@ -167,8 +166,6 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -167,8 +166,6 @@ public class ApiFlowServiceImpl implements ApiFlowService {
flow
.
setAlarmlAction
(
pluginFlow
.
getConfig
().
getAlarmlAction
());
flow
.
setAlarmlAction
(
pluginFlow
.
getConfig
().
getAlarmlAction
());
flow
.
setAlarmEmail
(
pluginFlow
.
getConfig
().
getAlarmEmail
());
flow
.
setAlarmEmail
(
pluginFlow
.
getConfig
().
getAlarmEmail
());
flow
.
setScanMark
(
"1"
);
flow
.
setScanMark
(
"1"
);
Map
<
String
,
String
>
publicParamMap
=
pluginFlow
.
getConfig
().
getPublicParam
();
flow
.
setFlowDesc
(
JSON
.
toJSONString
(
publicParamMap
));
//设置可执行次数
//设置可执行次数
//若没设置或者设置为-1,则响应设置剩余的执行次数
//若没设置或者设置为-1,则响应设置剩余的执行次数
if
(
null
!=
pluginFlow
.
getConfig
().
getRepeatCount
()
&&
!
"-1"
.
equals
(
pluginFlow
.
getConfig
().
getRepeatCount
()))
{
if
(
null
!=
pluginFlow
.
getConfig
().
getRepeatCount
()
&&
!
"-1"
.
equals
(
pluginFlow
.
getConfig
().
getRepeatCount
()))
{
...
@@ -197,7 +194,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -197,7 +194,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
flow
.
setVersionName
(
versionName
);
flow
.
setVersionName
(
versionName
);
}
}
flowMapper
.
updateByIdSelective
(
flow
);
flowMapper
.
updateByIdSelective
(
flow
);
updateNodeByFlow
(
pluginFlow
.
getNodeList
(),
flow
,
publicParamMap
);
updateNodeByFlow
(
pluginFlow
.
getNodeList
(),
flow
,
upFlowName
);
}
else
{
}
else
{
String
versionName
=
pluginFlow
.
getVersionName
();
String
versionName
=
pluginFlow
.
getVersionName
();
...
@@ -208,9 +205,11 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -208,9 +205,11 @@ public class ApiFlowServiceImpl implements ApiFlowService {
}
}
Integer
flowId
=
flowMapper
.
insertSelective
(
flow
);
Integer
flowId
=
flowMapper
.
insertSelective
(
flow
);
saveNode
(
pluginFlow
.
getNodeList
(),
flow
,
publicParamMap
);
saveNode
(
pluginFlow
.
getNodeList
(),
flow
,
upFlowName
);
}
}
FlowExtendedConfiguration
extendedConfiguration
=
pluginFlow
.
getConfig
().
getExtendedConfiguration
();
extendedConfiguration
.
setFlowEmbedLogo
(
upFlowName
);
flow
.
setExtendedConfiguration
(
JSON
.
toJSONString
(
extendedConfiguration
));
return
flow
;
return
flow
;
}
}
...
@@ -220,7 +219,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -220,7 +219,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
* @param pluginNodeList
* @param pluginNodeList
* @param flow
* @param flow
*/
*/
private
void
updateNodeByFlow
(
List
<
PluginBaseNode
>
pluginNodeList
,
Flow
flow
,
Map
<
String
,
String
>
publicParamMap
)
throws
Exception
{
private
void
updateNodeByFlow
(
List
<
PluginBaseNode
>
pluginNodeList
,
Flow
flow
,
String
upFlowName
)
throws
Exception
{
//将工作流下的所有节点设为不在工作流调度上
//将工作流下的所有节点设为不在工作流调度上
log
.
debug
(
"将工作流【{}】所有的节点移下调度,并删除相关的依赖关系"
,
flow
.
getFlowName
());
log
.
debug
(
"将工作流【{}】所有的节点移下调度,并删除相关的依赖关系"
,
flow
.
getFlowName
());
...
@@ -250,7 +249,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -250,7 +249,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
//保存节点信息
//保存节点信息
for
(
PluginBaseNode
pluginNode
:
pluginNodeList
)
{
for
(
PluginBaseNode
pluginNode
:
pluginNodeList
)
{
Node
node
=
new
Node
();
Node
node
=
new
Node
();
buildNode
(
pluginNode
,
flow
,
node
,
publicParamMap
);
buildNode
(
pluginNode
,
flow
,
node
,
upFlowName
);
Integer
nodeId
=
nodeMapper
.
insertSelective
(
node
);
Integer
nodeId
=
nodeMapper
.
insertSelective
(
node
);
nameIdRel
.
put
(
node
.
getNodeName
(),
node
.
getNodeId
());
nameIdRel
.
put
(
node
.
getNodeName
(),
node
.
getNodeId
());
...
@@ -265,12 +264,12 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -265,12 +264,12 @@ public class ApiFlowServiceImpl implements ApiFlowService {
* @param nodeList
* @param nodeList
* @param flow
* @param flow
*/
*/
private
void
saveNode
(
List
<
PluginBaseNode
>
nodeList
,
Flow
flow
,
Map
<
String
,
String
>
publicParamMap
)
throws
Exception
{
private
void
saveNode
(
List
<
PluginBaseNode
>
nodeList
,
Flow
flow
,
String
upFlowName
)
throws
Exception
{
HashMap
<
String
,
Integer
>
nameIdRel
=
new
HashMap
<>();
HashMap
<
String
,
Integer
>
nameIdRel
=
new
HashMap
<>();
//保存节点信息
//保存节点信息
for
(
PluginBaseNode
pluginNode
:
nodeList
)
{
for
(
PluginBaseNode
pluginNode
:
nodeList
)
{
Node
node
=
new
Node
();
Node
node
=
new
Node
();
buildNode
(
pluginNode
,
flow
,
node
,
publicParamMap
);
buildNode
(
pluginNode
,
flow
,
node
,
upFlowName
);
node
.
setNodeId
(
null
);
node
.
setNodeId
(
null
);
Integer
nodeId
=
nodeMapper
.
insertSelective
(
node
);
Integer
nodeId
=
nodeMapper
.
insertSelective
(
node
);
nameIdRel
.
put
(
node
.
getNodeName
(),
node
.
getNodeId
());
nameIdRel
.
put
(
node
.
getNodeName
(),
node
.
getNodeId
());
...
@@ -286,7 +285,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -286,7 +285,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
* @param node
* @param node
* @throws Exception
* @throws Exception
*/
*/
private
void
buildNode
(
PluginBaseNode
pluginNode
,
Flow
flow
,
Node
node
,
Map
<
String
,
String
>
publicParamMap
)
throws
Exception
{
private
void
buildNode
(
PluginBaseNode
pluginNode
,
Flow
flow
,
Node
node
,
String
upFlowName
)
throws
Exception
{
node
.
setVersionName
(
flow
.
getVersionName
());
node
.
setVersionName
(
flow
.
getVersionName
());
node
.
setFlowId
(
flow
.
getFlowId
());
node
.
setFlowId
(
flow
.
getFlowId
());
...
@@ -299,7 +298,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -299,7 +298,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
PluginFlow
pluginFlow
=
(
PluginFlow
)
pluginNode
;
PluginFlow
pluginFlow
=
(
PluginFlow
)
pluginNode
;
pluginFlow
.
getConfig
().
setFlowCron
(
flow
.
getFlowCron
());
pluginFlow
.
getConfig
().
setFlowCron
(
flow
.
getFlowCron
());
//如果是内嵌工作流先保存工作流信息
//如果是内嵌工作流先保存工作流信息
Flow
innerFlow
=
saveFlow
(
pluginFlow
,
flow
.
getWorkspaceId
(),
true
);
Flow
innerFlow
=
saveFlow
(
pluginFlow
,
flow
.
getWorkspaceId
(),
true
,
upFlowName
);
node
.
setIsVirtual
(
NodePropertyEnum
.
IS_VIRTUAL
.
getCode
());
node
.
setIsVirtual
(
NodePropertyEnum
.
IS_VIRTUAL
.
getCode
());
node
.
setMapFlowId
(
innerFlow
.
getFlowId
());
node
.
setMapFlowId
(
innerFlow
.
getFlowId
());
node
.
setVersionName
(
pluginFlow
.
getVersionName
());
node
.
setVersionName
(
pluginFlow
.
getVersionName
());
...
@@ -342,11 +341,6 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -342,11 +341,6 @@ public class ApiFlowServiceImpl implements ApiFlowService {
node
.
setSuperSuccessRun
(
"0"
);
node
.
setSuperSuccessRun
(
"0"
);
}
}
node
.
setIsVirtual
(
NodePropertyEnum
.
ISNOT_VIRTUAL
.
getCode
());
node
.
setIsVirtual
(
NodePropertyEnum
.
ISNOT_VIRTUAL
.
getCode
());
RunParamWrapped
runParamWrapped
=
new
RunParamWrapped
();
runParamWrapped
.
setPrivateParam
(
node
.
getRunParam
());
runParamWrapped
.
setPublicParamMap
(
publicParamMap
);
node
.
setRunParam
(
JSON
.
toJSONString
(
runParamWrapped
));
}
}
}
}
...
@@ -809,7 +803,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -809,7 +803,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
}
}
}
}
return
runRecordingMapper
.
findByStartAndEndTime
(
loadScheduleCondition
,
flowIds
);
return
runRecordingMapper
.
findByStartAndEndTime
(
loadScheduleCondition
,
flowIds
);
}
}
...
@@ -1669,7 +1663,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -1669,7 +1663,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
StringBuffer
runids
=
new
StringBuffer
();
StringBuffer
runids
=
new
StringBuffer
();
//暂停工作流调度
//暂停工作流调度
recordingList
.
forEach
(
runRecording
->
{
recordingList
.
forEach
(
runRecording
->
{
if
(
RunRecordingEnum
.
FLOW_STATUS_IS_END
.
getCode
().
equals
(
runRecording
.
getFlowStatus
()))
{
if
(
RunRecordingEnum
.
FLOW_STATUS_IS_END
.
getCode
().
equals
(
runRecording
.
getFlowStatus
()))
{
throw
new
RuntimeException
(
String
.
format
(
"实例%s是完结状态"
,
runRecording
.
getFlowName
()));
throw
new
RuntimeException
(
String
.
format
(
"实例%s是完结状态"
,
runRecording
.
getFlowName
()));
}
}
//runRecordingMapper.stopByRunIdAndFlowId(runRecording.getRunId(), runRecording.getFlowId());
//runRecordingMapper.stopByRunIdAndFlowId(runRecording.getRunId(), runRecording.getFlowId());
...
@@ -1694,7 +1688,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -1694,7 +1688,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
List
<
RunRecording
>
runRecordList
=
runRecordingMapper
.
findStopRunCordByRunId
(
runId
);
List
<
RunRecording
>
runRecordList
=
runRecordingMapper
.
findStopRunCordByRunId
(
runId
);
//ValidationUtil.isTrueValidation(CollectionUtil.isEmpty(runRecordList), "该工作流不是暂停状态!");
//ValidationUtil.isTrueValidation(CollectionUtil.isEmpty(runRecordList), "该工作流不是暂停状态!");
if
(
CollectionUtil
.
isEmpty
(
runRecordList
))
{
if
(
CollectionUtil
.
isEmpty
(
runRecordList
))
{
log
.
warn
(
"---------运行记录{},不存在暂停记录中!---"
,
runId
);
log
.
warn
(
"---------运行记录{},不存在暂停记录中!---"
,
runId
);
return
;
return
;
}
}
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/enums/RedisKeyNameEnum.java
0 → 100644
View file @
a99c4b7e
package
com
.
byit
.
enums
;
/**
* @author huangfu
*/
public
enum
RedisKeyNameEnum
{
/**
* 调度中心公共参数
*/
REDIS_PUBLIC_PARAM_KEY
(
"myth:param:public:%s"
),
;
private
final
String
keyName
;
RedisKeyNameEnum
(
String
keyName
)
{
this
.
keyName
=
keyName
;
}
public
String
getKeyName
()
{
return
keyName
;
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/model/RunRecording.java
View file @
a99c4b7e
...
@@ -88,7 +88,7 @@ public class RunRecording implements Serializable {
...
@@ -88,7 +88,7 @@ public class RunRecording implements Serializable {
/**
/**
* 本次任务的执行时间
* 本次任务的执行时间
*/
*/
@ApiModelProperty
(
"
本次任务的执行
时间"
)
@ApiModelProperty
(
"
计划本次任务开始的
时间"
)
private
Long
triggerTime
;
private
Long
triggerTime
;
/**
/**
...
@@ -106,13 +106,13 @@ public class RunRecording implements Serializable {
...
@@ -106,13 +106,13 @@ public class RunRecording implements Serializable {
/**
/**
* 开始时间
* 开始时间
*/
*/
@ApiModelProperty
(
"开始时间"
)
@ApiModelProperty
(
"
实际
开始时间"
)
private
Date
startTime
;
private
Date
startTime
;
/**
/**
* 结束时间
* 结束时间
*/
*/
@ApiModelProperty
(
"结束时间"
)
@ApiModelProperty
(
"
实际
结束时间"
)
private
Date
endTime
;
private
Date
endTime
;
/**
/**
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/impl/RunNodeServiceImpl.java
View file @
a99c4b7e
package
com
.
byit
.
service
.
impl
;
package
com
.
byit
.
service
.
impl
;
import
com.byit.dto.RunRecordingWrapped
;
import
com.byit.enums.NodeNameEnum
;
import
com.byit.enums.NodeNameEnum
;
import
com.byit.enums.RunRecordingEnum
;
import
com.byit.enums.RunRecordingEnum
;
import
com.byit.enums.ScheduleTypeEnum
;
import
com.byit.enums.ScheduleTypeEnum
;
...
@@ -32,7 +31,7 @@ import java.util.*;
...
@@ -32,7 +31,7 @@ import java.util.*;
* @author huangfu
* @author huangfu
*/
*/
@Service
@Service
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Slf4j
@Slf4j
public
class
RunNodeServiceImpl
implements
RunNodeServer
,
ApplicationEventPublisherAware
{
public
class
RunNodeServiceImpl
implements
RunNodeServer
,
ApplicationEventPublisherAware
{
private
final
RunRecordingService
runRecordingService
;
private
final
RunRecordingService
runRecordingService
;
...
@@ -56,16 +55,17 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
...
@@ -56,16 +55,17 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
/**
/**
* 保存到运行记录一份 将节点保存到job_task表
* 保存到运行记录一份 将节点保存到job_task表
*
* @param flow 工作流
* @param flow 工作流
* @param nodes 节点
* @param nodes 节点
*/
*/
@Override
@Override
public
void
saveRunRec
(
Flow
flow
,
List
<
Node
>
nodes
)
{
public
void
saveRunRec
(
Flow
flow
,
List
<
Node
>
nodes
)
{
log
.
info
(
"---------saveRunRecAndTask start------【保存工作流:{}和节点:{}】-----------------------"
,
flow
,
nodes
);
log
.
info
(
"---------saveRunRecAndTask start------【保存工作流:{}和节点:{}】-----------------------"
,
flow
,
nodes
);
String
runId
=
IDGenerationStrategy
.
runIdGenerationStrategy
(
serverPort
);
String
runId
=
IDGenerationStrategy
.
runIdGenerationStrategy
(
serverPort
);
log
.
info
(
"-------------【开始保存运行记录runId为:{}】------------------"
,
runId
);
log
.
info
(
"-------------【开始保存运行记录runId为:{}】------------------"
,
runId
);
RunRecording
build
=
new
RunRecording
();
RunRecording
build
=
new
RunRecording
();
BeanUtils
.
copyProperties
(
flow
,
build
);
BeanUtils
.
copyProperties
(
flow
,
build
);
build
.
setRunId
(
runId
);
build
.
setRunId
(
runId
);
//TODO 这个不解释 不知道干嘛的 后续需要修改
//TODO 这个不解释 不知道干嘛的 后续需要修改
build
.
setDispatchIp
(
"0.0.0.0"
);
build
.
setDispatchIp
(
"0.0.0.0"
);
...
@@ -73,19 +73,17 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
...
@@ -73,19 +73,17 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
build
.
setTriggerTime
(
flow
.
getTriggerNextTime
());
build
.
setTriggerTime
(
flow
.
getTriggerNextTime
());
boolean
isScheduleFollow
=
"1"
.
equals
(
flow
.
getScheduleFollow
());
boolean
isScheduleFollow
=
"1"
.
equals
(
flow
.
getScheduleFollow
());
log
.
info
(
"-------------【开始保存节点信息,任务是否为跟随工作流,{}】---------------"
,
isScheduleFollow
);
log
.
info
(
"-------------【开始保存节点信息,任务是否为跟随工作流,{}】---------------"
,
isScheduleFollow
);
List
<
JobTask
>
jobTasks
=
new
ArrayList
<>(
32
);
List
<
JobTask
>
jobTasks
=
new
ArrayList
<>(
32
);
for
(
Node
node
:
nodes
)
{
for
(
Node
node
:
nodes
)
{
JobTask
jobTask
=
new
JobTask
();
JobTask
jobTask
=
new
JobTask
();
jobTask
.
setScheduleType
(
1
);
jobTask
.
setScheduleType
(
1
);
jobTask
.
setTriggerStatus
(
"1"
);
jobTask
.
setTriggerStatus
(
"1"
);
BeanUtils
.
copyProperties
(
node
,
jobTask
);
BeanUtils
.
copyProperties
(
node
,
jobTask
);
if
(
isScheduleFollow
)
{
if
(
isScheduleFollow
)
{
jobTask
.
setTriggerTime
(
flow
.
getTriggerNextTime
());
jobTask
.
setTriggerTime
(
flow
.
getTriggerNextTime
());
}
else
{
}
else
{
jobTask
.
setTriggerTime
(
node
.
getTriggerNextTime
());
jobTask
.
setTriggerTime
(
node
.
getTriggerNextTime
());
try
{
try
{
node
.
setTriggerNextTime
(
new
CronExpression
(
node
.
getNodeCron
()).
getNextValidTimeAfter
(
new
Date
(
node
.
getTriggerNextTime
())).
getTime
());
node
.
setTriggerNextTime
(
new
CronExpression
(
node
.
getNodeCron
()).
getNextValidTimeAfter
(
new
Date
(
node
.
getTriggerNextTime
())).
getTime
());
...
@@ -98,7 +96,7 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
...
@@ -98,7 +96,7 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
jobTask
.
setFlowName
(
flow
.
getFlowName
());
jobTask
.
setFlowName
(
flow
.
getFlowName
());
jobTask
.
setScheduleType
(
ScheduleTypeEnum
.
NORMAL
.
getCode
());
jobTask
.
setScheduleType
(
ScheduleTypeEnum
.
NORMAL
.
getCode
());
//如果不是开始节点
//如果不是开始节点
if
(!
NodeNameEnum
.
START_NODE
.
getNodeName
().
equals
(
jobTask
.
getNodeName
()))
{
if
(!
NodeNameEnum
.
START_NODE
.
getNodeName
().
equals
(
jobTask
.
getNodeName
()))
{
List
<
Integer
>
dependIdByNodeId
=
nodeDependencyService
.
findDependIdByNodeId
(
jobTask
.
getNodeId
());
List
<
Integer
>
dependIdByNodeId
=
nodeDependencyService
.
findDependIdByNodeId
(
jobTask
.
getNodeId
());
String
parentIds
=
StringUtils
.
join
(
dependIdByNodeId
,
","
);
String
parentIds
=
StringUtils
.
join
(
dependIdByNodeId
,
","
);
jobTask
.
setNodeDepend
(
parentIds
);
jobTask
.
setNodeDepend
(
parentIds
);
...
@@ -112,12 +110,13 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
...
@@ -112,12 +110,13 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
//回调生命周期
//回调生命周期
try
{
try
{
for
(
Map
.
Entry
<
String
,
InstanceRunTheLifeCycleCallback
>
entry
:
entries
)
{
for
(
Map
.
Entry
<
String
,
InstanceRunTheLifeCycleCallback
>
entry
:
entries
)
{
log
.
info
(
"-------------【开始回调周期{}前置】---------------"
,
entry
.
getKey
());
log
.
info
(
"-------------【开始回调周期{}前置】---------------"
,
entry
.
getKey
());
RunRecording
Wrapped
runRecordingWrapped
=
entry
.
getValue
().
postProcessAfterInitialization
(
build
,
jobTasks
);
RunRecording
runRecording
=
entry
.
getValue
().
postProcessAfterInitialization
(
build
);
build
=
runRecordingWrapped
.
getRunRecording
();
if
(
runRecording
!=
null
)
{
jobTasks
=
runRecordingWrapped
.
getNodeList
()
;
build
=
runRecording
;
}
}
}
catch
(
Exception
e
)
{
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
build
.
setFlowStatus
(
RunRecordingEnum
.
FLOW_STATUS_IS_END
.
getCode
());
build
.
setFlowStatus
(
RunRecordingEnum
.
FLOW_STATUS_IS_END
.
getCode
());
build
.
setFlowRunResult
(
RunResultEnum
.
RUN_ERROR
.
getCode
());
build
.
setFlowRunResult
(
RunResultEnum
.
RUN_ERROR
.
getCode
());
...
@@ -130,7 +129,7 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
...
@@ -130,7 +129,7 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
jobTaskService
.
saveJobTasks
(
jobTasks
);
jobTaskService
.
saveJobTasks
(
jobTasks
);
log
.
info
(
"-------------【开始修改工作流{}的下次运行时间,以及各种状态】---------------"
,
flow
);
log
.
info
(
"-------------【开始修改工作流{}的下次运行时间,以及各种状态】---------------"
,
flow
);
try
{
try
{
Long
triggerNextTime
=
flow
.
getTriggerNextTime
();
Long
triggerNextTime
=
flow
.
getTriggerNextTime
();
flow
.
setTriggerNextTime
(
new
CronExpression
(
flow
.
getFlowCron
()).
getNextValidTimeAfter
(
new
Date
(
triggerNextTime
)).
getTime
());
flow
.
setTriggerNextTime
(
new
CronExpression
(
flow
.
getFlowCron
()).
getNextValidTimeAfter
(
new
Date
(
triggerNextTime
)).
getTime
());
...
@@ -140,26 +139,27 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
...
@@ -140,26 +139,27 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
updateFlow
(
flow
);
updateFlow
(
flow
);
applicationEventPublisher
.
publishEvent
(
new
FlowScanEndEvent
(
this
,
build
));
applicationEventPublisher
.
publishEvent
(
new
FlowScanEndEvent
(
this
,
build
));
log
.
info
(
"-------saveRunRecAndTaskAndUpdate end-----------【运行结束】-----------------"
);
log
.
info
(
"-------saveRunRecAndTaskAndUpdate end-----------【运行结束】-----------------"
);
}
}
/**
/**
* 修改工作流的信息
* 修改工作流的信息
*
* @param flow 工作流
* @param flow 工作流
*/
*/
private
void
updateFlow
(
Flow
flow
){
private
void
updateFlow
(
Flow
flow
)
{
if
(
flow
.
getRemainingCount
()
>
0
)
{
if
(
flow
.
getRemainingCount
()
>
0
)
{
flow
.
setRemainingCount
(
flow
.
getRemainingCount
()
-
1
);
flow
.
setRemainingCount
(
flow
.
getRemainingCount
()
-
1
);
}
}
flowService
.
updateByIdSelective
(
flow
);
flowService
.
updateByIdSelective
(
flow
);
}
}
/**
/**
* 设置时间发布器
* 设置时间发布器
*
* @param applicationEventPublisher
* @param applicationEventPublisher
*/
*/
@Override
@Override
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/mapservice/impl/RunRecordingAndJobTaskServiceImpl.java
View file @
a99c4b7e
...
@@ -274,9 +274,11 @@ public class RunRecordingAndJobTaskServiceImpl implements RunRecordingAndJobTask
...
@@ -274,9 +274,11 @@ public class RunRecordingAndJobTaskServiceImpl implements RunRecordingAndJobTask
//回调生命周期
//回调生命周期
for
(
Map
.
Entry
<
String
,
InstanceRunTheLifeCycleCallback
>
entry
:
entries
)
{
for
(
Map
.
Entry
<
String
,
InstanceRunTheLifeCycleCallback
>
entry
:
entries
)
{
log
.
info
(
"-------------【开始回调周期{}前置】---------------"
,
entry
.
getKey
());
log
.
info
(
"-------------【开始回调周期{}前置】---------------"
,
entry
.
getKey
());
RunRecordingWrapped
runRecordingWrapped
=
entry
.
getValue
().
postProcessAfterInitialization
(
runRecording
,
jobTasks
);
RunRecording
runRecordingLi
=
entry
.
getValue
().
postProcessAfterInitialization
(
runRecording
);
runRecording
=
runRecordingWrapped
.
getRunRecording
();
if
(
runRecordingLi
!=
null
)
{
jobTasks
=
runRecordingWrapped
.
getNodeList
();
runRecording
=
runRecordingLi
;
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/strategy/InstanceRunTheLifeCycleCallback.java
View file @
a99c4b7e
...
@@ -17,14 +17,15 @@ public interface InstanceRunTheLifeCycleCallback {
...
@@ -17,14 +17,15 @@ public interface InstanceRunTheLifeCycleCallback {
/**
/**
* 实例执行前
* 实例执行前
* @param runRecording 运行实例
* @param runRecording 运行实例
* @param jobTaskList 节点
* @return 两者的包装对象
* @return 两者的包装对象
*/
*/
RunRecordingWrapped
postProcessAfterInitialization
(
RunRecording
runRecording
,
List
<
JobTask
>
jobTaskList
);
default
RunRecording
postProcessAfterInitialization
(
RunRecording
runRecording
){
return
runRecording
;
}
/**
/**
* 后置处理器
* 后置处理器
* @param runRecording 实例
* @param runRecording 实例
*/
*/
void
postProcessBeforeInitialization
(
RunRecording
runRecording
);
default
void
postProcessBeforeInitialization
(
RunRecording
runRecording
){}
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/strategy/impl/RpcCallbackInstanceRunTheLifeCycleCallback.java
View file @
a99c4b7e
This diff is collapsed.
Click to expand it.
byit-myth-core/myth-admin-core/src/main/java/com/byit/strategy/impl/RunRecordingRunRedisRemoveTheLifeCycleCallback.java
0 → 100644
View file @
a99c4b7e
package
com
.
byit
.
strategy
.
impl
;
import
com.byit.enums.RedisKeyNameEnum
;
import
com.byit.model.RunRecording
;
import
com.byit.strategy.InstanceRunTheLifeCycleCallback
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
/**
* 关于公共参数的redis数据删除
*
* @author huangfu
* @date 2020年12月14日11:55:37
*/
@Component
@Slf4j
public
class
RunRecordingRunRedisRemoveTheLifeCycleCallback
implements
InstanceRunTheLifeCycleCallback
{
private
final
StringRedisTemplate
stringRedisTemplate
;
public
RunRecordingRunRedisRemoveTheLifeCycleCallback
(
StringRedisTemplate
stringRedisTemplate
)
{
this
.
stringRedisTemplate
=
stringRedisTemplate
;
}
/**
* 后置处理器 清除实例执行中产生的各种redis信息
*
* @param runRecording 实例
*/
@Override
public
void
postProcessBeforeInitialization
(
RunRecording
runRecording
)
{
//删除本次实例的公共参数
String
runId
=
runRecording
.
getRunId
();
String
publicRedisName
=
String
.
format
(
RedisKeyNameEnum
.
REDIS_PUBLIC_PARAM_KEY
.
getKeyName
(),
runId
);
stringRedisTemplate
.
delete
(
publicRedisName
);
}
}
byit-myth-core/myth-admin-core/src/main/resources/mapper/RunRecordingMapper.xml
View file @
a99c4b7e
...
@@ -229,8 +229,8 @@
...
@@ -229,8 +229,8 @@
select
select
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from run_recording
from run_recording
where
UNIX_TIMESTAMP(start_time) * 1000
>
= #{loadScheduleCondition.startTime}
where
trigger_time
>
= #{loadScheduleCondition.startTime}
and
UNIX_TIMESTAMP(start_time) * 1000
<
= #{loadScheduleCondition.endTime}
and
trigger_time
<
= #{loadScheduleCondition.endTime}
and schedule_type != 4
and schedule_type != 4
<if
test=
"flowIds != null"
>
<if
test=
"flowIds != null"
>
and flow_id in (
and flow_id in (
...
...
byit-myth-core/myth-dto-core/src/main/java/com/byit/dto/common/CallbackDto.java
View file @
a99c4b7e
...
@@ -19,4 +19,5 @@ public class CallbackDto implements Serializable {
...
@@ -19,4 +19,5 @@ public class CallbackDto implements Serializable {
private
String
versionName
;
private
String
versionName
;
private
String
runId
;
private
String
runId
;
private
String
data
;
private
String
data
;
private
Boolean
runRecordingStatus
=
false
;
}
}
byit-myth-core/myth-dto-core/src/main/java/com/byit/dto/plugin/FlowExtendedConfiguration.java
View file @
a99c4b7e
...
@@ -23,4 +23,9 @@ public class FlowExtendedConfiguration {
...
@@ -23,4 +23,9 @@ public class FlowExtendedConfiguration {
* 公共参数
* 公共参数
*/
*/
public
String
publicParam
;
public
String
publicParam
;
/**
* 节点嵌入标记 a:b:c
*/
private
String
flowEmbedLogo
;
}
}
byit-myth-core/myth-dto-core/src/main/java/com/byit/dto/plugin/PluginFlowConfig.java
View file @
a99c4b7e
...
@@ -20,11 +20,6 @@ import java.util.Map;
...
@@ -20,11 +20,6 @@ import java.util.Map;
public
class
PluginFlowConfig
{
public
class
PluginFlowConfig
{
/**
/**
* 公共参数
*/
private
Map
<
String
,
String
>
publicParam
;
/**
* 当前工作流版本的告警的时机(0 不告警, 1 完成时告警, 2 失败时告警, 3 成功时告警)
* 当前工作流版本的告警的时机(0 不告警, 1 完成时告警, 2 失败时告警, 3 成功时告警)
*/
*/
private
String
alarmlAction
;
private
String
alarmlAction
;
...
...
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