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
e43c2848
Commit
e43c2848
authored
Feb 05, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加暂停功能
parent
72b86798
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
12 deletions
+73
-12
ApiFlowController.java
...h-admin/src/main/java/com/byit/api/ApiFlowController.java
+11
-4
FlowPropertyEnum.java
...n-core/src/main/java/com/byit/enums/FlowPropertyEnum.java
+1
-0
JobScheduleHelper.java
...core/src/main/java/com/byit/thread/JobScheduleHelper.java
+10
-1
RunRecordingScanHelper.java
...src/main/java/com/byit/thread/RunRecordingScanHelper.java
+0
-4
JobUtils.java
...exector-plugin/src/main/java/com/byit/utils/JobUtils.java
+38
-3
StopFlowTest.java
...-demo-client/src/main/java/com/byit/job/StopFlowTest.java
+13
-0
No files found.
byit-myth-admin/src/main/java/com/byit/api/ApiFlowController.java
View file @
e43c2848
package
com
.
byit
.
api
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.byit.service.ApiFlowService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -52,16 +54,21 @@ public class ApiFlowController {
}
@PostMapping
(
"killSchedule"
)
@ApiOperation
(
"杀死本次调度"
)
public
String
killSchedule
(
String
flowName
,
String
workspaceName
){
public
String
killSchedule
(
String
param
){
JSONObject
jsonObject
=
JSON
.
parseObject
(
param
);
String
flowName
=
jsonObject
.
getString
(
"flowName"
);
String
workspaceName
=
jsonObject
.
getString
(
"workspaceName"
);
apiFlowService
.
killSchedule
(
flowName
,
workspaceName
);
return
"SUCCESS"
;
}
@PostMapping
(
"stopSchedule"
)
@ApiOperation
(
"暂停本次调度"
)
public
String
stopSchedule
(
String
flowName
,
String
workspaceName
){
String
runId
=
apiFlowService
.
stopSchedule
(
flowName
,
workspaceName
);
return
runId
;
public
String
stopSchedule
(
String
param
){
JSONObject
jsonObject
=
JSON
.
parseObject
(
param
);
String
flowName
=
jsonObject
.
getString
(
"flowName"
);
String
workspaceName
=
jsonObject
.
getString
(
"workspaceName"
);
return
apiFlowService
.
stopSchedule
(
flowName
,
workspaceName
);
}
@PostMapping
(
"reStartSchedule"
)
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/enums/FlowPropertyEnum.java
View file @
e43c2848
...
...
@@ -21,6 +21,7 @@ public enum FlowPropertyEnum {
FAIL_ALARML
(
"3"
,
"失败时告警"
),
IS_CURRENTVERSION
(
"0"
,
"版本表是当前版本的工作流"
),
ISNOT_CURRENTVERSION
(
"1"
,
"版本表不是当前版本的工作流"
),
FLOW_RUN_ING
(
"2"
,
"工作流运行中"
),
;
private
String
code
;
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/JobScheduleHelper.java
View file @
e43c2848
package
com
.
byit
.
thread
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.byit.enums.FlowPropertyEnum
;
import
com.byit.enums.JobTriggerStatusEnums
;
import
com.byit.job.WorkRoulette
;
import
com.byit.model.*
;
...
...
@@ -43,6 +44,7 @@ public class JobScheduleHelper{
private
final
NodeDependencyService
nodeDependencyService
;
private
final
JobTaskRunLogService
jobTaskRunLogService
;
private
final
TaskAndLogServer
taskAndLogServer
;
private
final
RunRecordingService
runRecordingService
;
/**
...
...
@@ -72,13 +74,14 @@ public class JobScheduleHelper{
private
volatile
boolean
scheduleThreadToStop
=
false
;
@Autowired
public
JobScheduleHelper
(
RunRecordingAndJobTaskService
runRecordingAndJobTaskService
,
JobTaskScheduleService
jobTaskScheduleService
,
JobTaskService
jobTaskService
,
NodeDependencyService
nodeDependencyService
,
JobTaskRunLogService
jobTaskRunLogService
,
TaskAndLogServer
taskAndLogServer
)
{
public
JobScheduleHelper
(
RunRecordingAndJobTaskService
runRecordingAndJobTaskService
,
JobTaskScheduleService
jobTaskScheduleService
,
JobTaskService
jobTaskService
,
NodeDependencyService
nodeDependencyService
,
JobTaskRunLogService
jobTaskRunLogService
,
TaskAndLogServer
taskAndLogServer
,
RunRecordingService
runRecordingService
)
{
this
.
runRecordingAndJobTaskService
=
runRecordingAndJobTaskService
;
this
.
jobTaskScheduleService
=
jobTaskScheduleService
;
this
.
jobTaskService
=
jobTaskService
;
this
.
nodeDependencyService
=
nodeDependencyService
;
this
.
jobTaskRunLogService
=
jobTaskRunLogService
;
this
.
taskAndLogServer
=
taskAndLogServer
;
this
.
runRecordingService
=
runRecordingService
;
}
/**
...
...
@@ -150,6 +153,12 @@ public class JobScheduleHelper{
JobTaskSchedule
jobTaskSchedule
=
new
JobTaskSchedule
();
BeanUtils
.
copyProperties
(
jobTask
,
jobTaskSchedule
);
jobTaskSchedules
.
add
(
jobTaskSchedule
);
//更改运行记录为运行中
String
runId
=
jobTask
.
getRunId
();
Integer
flowId
=
jobTask
.
getFlowId
();
RunRecording
runRecordingByFlowIdAndRunId
=
runRecordingService
.
findRunRecordingByFlowIdAndRunId
(
flowId
,
runId
);
runRecordingByFlowIdAndRunId
.
setFlowStatus
(
FlowPropertyEnum
.
FLOW_RUN_ING
.
getCode
());
runRecordingService
.
updateRunRecordingById
(
runRecordingByFlowIdAndRunId
);
}
else
{
//查询该节点的依赖节点
List
<
Integer
>
dependIdByNodeId
=
nodeDependencyService
.
findDependIdByNodeId
(
jobTask
.
getNodeId
());
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/RunRecordingScanHelper.java
View file @
e43c2848
...
...
@@ -200,10 +200,6 @@ public class RunRecordingScanHelper {
private
void
saveEmailAlarms
(
RunRecording
runRecording
)
{
//这一步是根据flowId和RunId查询对应的节点信息
/**
* 但是现在疑惑的是 为什么根据工作流id和运行标识就能查询出虚节点的信息呢?
* 理想情况下 主分支工作流上的flowid和runID应该与虚节点一致
*/
List
<
JobTaskRunLogWithBLOBs
>
jobTaskRunLogByFlowIdAndRunId
=
jobTaskRunLogService
.
findJobTaskRunLogWithBLOBsByFlowIdAndRunId
(
runRecording
.
getFlowId
(),
runRecording
.
getRunId
());
String
flowName
=
runRecording
.
getFlowName
();
String
senContentHtml
=
runMsgHtml
(
jobTaskRunLogByFlowIdAndRunId
,
flowName
);
...
...
byit-myth-executor/myth-exector-plugin/src/main/java/com/byit/utils/JobUtils.java
View file @
e43c2848
...
...
@@ -12,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -31,9 +32,15 @@ public class JobUtils {
* 发布工作流
*/
private
static
final
String
REQUEST_FLOW_PUBLISH
=
"/api/flow/publish"
;
//创建工作空间
/**
* 创建工作空间
*/
private
static
final
String
REQUEST_WORKSPACE_ADD
=
"/api/workspace/add"
;
/**
* 暂停工作流
*/
private
static
final
String
REQUEST_FLOW_STOP
=
"/api/flow/stopSchedule"
;
/**
* 当前项目运行环境 jar file
*/
private
static
final
String
OPERATING_ENVIRONMENT_JAR
=
"jar"
;
...
...
@@ -64,7 +71,11 @@ public class JobUtils {
return
addRequestResult
;
}
/**
* 发布一个工作流
* @param pluginPackage
* @return
*/
public
static
String
publish
(
PluginPackage
pluginPackage
){
log
.
info
(
"---------------开始发布工作流,flowName:{}---------------------"
,
pluginPackage
.
getFlow
().
getName
());
...
...
@@ -72,11 +83,35 @@ public class JobUtils {
String
requestUrl
=
REQUEST_PREFIX
+
"127.0.0.1"
+
":"
+
"8080"
+
REQUEST_FLOW_PUBLISH
;
//发送请求 添加任务
String
addRequestResult
=
HttpUtil
.
post
(
requestUrl
,
"param="
+
JSON
.
toJSONString
(
pluginPackage
,
WriteClassName
));
// String addRequestResult = HttpUtil.post(requestUrl, JSON.toJSONString(pluginPackage, WriteClassName));
//String addRequestResult = HttpUtil.post(requestUrl, JSON.toJSONString(pluginPackage, WriteClassName))
log
.
info
(
"--------------------添加任务完成,添加结果为:{}------------------------"
,
addRequestResult
);
return
addRequestResult
;
}
/**
* 暂停工作流
* @param flowName
* @param workspaceName
* @return
*/
public
static
String
stopFlow
(
String
flowName
,
String
workspaceName
){
//请求的路径
String
requestUrl
=
REQUEST_PREFIX
+
"127.0.0.1"
+
":"
+
"8080"
+
REQUEST_FLOW_STOP
;
Map
<
String
,
String
>
map
=
new
HashMap
<>(
5
);
map
.
put
(
"flowName"
,
flowName
);
map
.
put
(
"workspaceName"
,
workspaceName
);
//发送请求 添加任务
String
addRequestResult
=
HttpUtil
.
post
(
requestUrl
,
"param="
+
JSON
.
toJSONString
(
map
,
WriteClassName
));
//String addRequestResult = HttpUtil.post(requestUrl, JSON.toJSONString(pluginPackage, WriteClassName))
log
.
info
(
"--------------------暂停成功,结果为:{}------------------------"
,
addRequestResult
);
return
addRequestResult
;
}
/**
* 创建工作空间
* @param workspaceName
* @return
*/
public
static
String
addWorkspace
(
String
workspaceName
){
log
.
info
(
"---------------开始创建工作空间,workspaceName:{}---------------------"
,
workspaceName
);
...
...
demo-client/byit-demo-client/src/main/java/com/byit/job/StopFlowTest.java
0 → 100644
View file @
e43c2848
package
com
.
byit
.
job
;
import
com.byit.utils.JobUtils
;
/**
* 暂停工作流的测试
* @author Administrator
*/
public
class
StopFlowTest
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
JobUtils
.
stopFlow
(
"自动化测试原子弹"
,
"test"
));
}
}
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