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
01afe49a
Commit
01afe49a
authored
Feb 22, 2020
by
guo_minglei@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
执行机添加杀死节点执行线程的接口
工作流管理工具添加杀死节点的方法
parent
1bac7131
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
16 deletions
+86
-16
FlowContent.java
...h-admin-core/src/main/java/com/byit/util/FlowContent.java
+53
-6
MythJobProcess.java
...com/byit/executor/jobExecutor/process/MythJobProcess.java
+0
-1
pom.xml
byit-myth-executor/myth-executor-server/pom.xml
+5
-9
ExecutorServiceApplication.java
...er/src/main/java/com/byit/ExecutorServiceApplication.java
+1
-0
ProcessManagerController.java
...in/java/com/byit/controller/ProcessManagerController.java
+27
-0
No files found.
byit-myth-core/myth-admin-core/src/main/java/com/byit/util/FlowContent.java
View file @
01afe49a
package
com
.
byit
.
util
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.byit.job.vo.ResponseResult
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @Description 工作流上下文内容
...
...
@@ -14,7 +18,7 @@ public class FlowContent {
//工作流名称+运行的runid
private
String
flowkey
;
//任务的运行日志id和具体的运行日志的机器的访问url
private
HashMap
<
String
,
String
>
jobExectUrl
=
new
HashMap
<>(
30
);
private
HashMap
<
Integer
,
String
>
jobExectUrl
=
new
HashMap
<>(
30
);
//总节点数目
private
Integer
allJobNum
;
//已经触发调度的节点数目
...
...
@@ -35,21 +39,41 @@ public class FlowContent {
}
public
synchronized
Boolean
killFlow
(){
return
false
;
Boolean
result
=
true
;
for
(
Integer
logId
:
jobExectUrl
.
keySet
()){
String
exectUrl
=
jobExectUrl
.
get
(
logId
);
if
(!
killJob
(
logId
,
exectUrl
)){
result
=
false
;
}
}
return
result
;
}
public
synchronized
Boolean
killJob
(
String
logId
){
public
synchronized
Boolean
killJob
(
Integer
logId
){
String
exectUrl
=
jobExectUrl
.
get
(
logId
);
if
(
null
!=
exectUrl
&&
!
""
.
equals
(
exectUrl
)){
log
.
info
(
"{} -- {} 调用杀死命令"
,
flowkey
,
logId
);
//具体访问的URL
return
killJob
(
logId
,
exectUrl
);
}
log
.
error
(
"{}下未查到{}的运行日志"
,
flowkey
,
logId
);
return
false
;
}
public
synchronized
void
putJob
(
String
logId
,
String
exectUrl
){
private
synchronized
Boolean
killJob
(
Integer
logId
,
String
exectUrl
){
//具体访问的URL
String
killUrl
=
exectUrl
+
"/processManager/killJob"
;
Map
<
String
,
Integer
>
requestMap
=
new
HashMap
<>(
2
);
requestMap
.
put
(
"logId"
,
logId
);
String
killResult
=
HttpUtil
.
post
(
killUrl
,
JSON
.
toJSONString
(
requestMap
));
log
.
info
(
"请求结果{}"
,
killResult
);
ResponseResult
responseResult
=
JSON
.
parseObject
(
killResult
,
ResponseResult
.
class
);
if
(
"SUCCESS"
.
equals
(
responseResult
.
getResult
())){
return
true
;
}
return
false
;
}
public
synchronized
void
putJob
(
Integer
logId
,
String
exectUrl
){
jobExectUrl
.
put
(
logId
,
exectUrl
);
//已经触发的节点数目加1
if
(
targetJobNum
==
null
||
targetJobNum
<
0
)
{
...
...
@@ -78,4 +102,27 @@ public class FlowContent {
log
.
error
(
"{}下未查到{}的运行日志"
,
flowkey
,
logId
);
}
//获取工作流下所有节点数目
public
Integer
getAllJobNum
(){
return
allJobNum
;
}
//获取已经触发的工作流下节点数目
public
Integer
getTargetJobNum
(){
return
targetJobNum
;
}
/**
* 获取对应的日志id的执行地址
* @param logId
* @return
*/
public
synchronized
String
getExectUrl
(
Integer
logId
){
String
exectUrl
=
jobExectUrl
.
get
(
logId
);
if
(
null
!=
null
&&
!
""
.
equals
(
exectUrl
)){
return
exectUrl
;
}
return
null
;
}
}
byit-myth-core/myth-executor-core/src/main/java/com/byit/executor/jobExecutor/process/MythJobProcess.java
View file @
01afe49a
package
com
.
byit
.
executor
.
jobExecutor
.
process
;
import
com.byit.executor.conf.FileSystemContext
;
import
com.byit.executor.util.JobContentUtil
;
import
com.byit.executor.util.LogGobbler
;
import
com.google.common.base.Joiner
;
...
...
byit-myth-executor/myth-executor-server/pom.xml
View file @
01afe49a
...
...
@@ -28,17 +28,12 @@
<groupId>
myth-job
</groupId>
<artifactId>
byit-myth-rpc
</artifactId>
</dependency>
<!-- <!– slf4j –>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<groupId>
com.byit
</groupId>
<artifactId>
byit-validation-starter
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>-->
</dependencies>
</project>
\ No newline at end of file
byit-myth-executor/myth-executor-server/src/main/java/com/byit/ExecutorServiceApplication.java
View file @
01afe49a
...
...
@@ -15,3 +15,4 @@ public class ExecutorServiceApplication {
SpringApplication
.
run
(
ExecutorServiceApplication
.
class
,
args
);
}
}
byit-myth-executor/myth-executor-server/src/main/java/com/byit/controller/ProcessManagerController.java
0 → 100644
View file @
01afe49a
package
com
.
byit
.
controller
;
import
com.byit.executor.jobExecutor.process.MythJobProcess
;
import
com.byit.executor.util.JobContentUtil
;
import
com.byit.utils.ValidationUtil
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @Description
* @Author guo_m
* @Date 2020-02-22
*/
@RestController
(
"processManager"
)
public
class
ProcessManagerController
{
@PostMapping
(
"killJob"
)
@ResponseBody
public
String
killJob
(
Integer
logId
){
ValidationUtil
.
dataNotNull
(
logId
,
"日志id不允许为空!"
);
MythJobProcess
mythJobProcess
=
JobContentUtil
.
getJobThread
(
logId
);
ValidationUtil
.
dataNotNull
(
mythJobProcess
,
logId
+
"已经运行结束或还未调用!"
);
mythJobProcess
.
hardKill
();
return
"SUCESS"
;
}
}
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