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
cf5acc9c
Commit
cf5acc9c
authored
Jan 13, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【删除失败节点】调整删除失败流程
【修复BUG】修复由单例模式引发的数据错乱
parent
86aaa505
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
70 additions
and
56 deletions
+70
-56
JobTaskRunLogServiceImpl.java
.../java/com/byit/service/impl/JobTaskRunLogServiceImpl.java
+3
-0
RunNodeServiceImpl.java
...c/main/java/com/byit/service/impl/RunNodeServiceImpl.java
+1
-0
TaskAndLogServerImpl.java
...main/java/com/byit/service/impl/TaskAndLogServerImpl.java
+10
-3
JavaBeanJobTask.java
...min-core/src/main/java/com/byit/task/JavaBeanJobTask.java
+9
-0
JobScheduleHelper.java
...core/src/main/java/com/byit/thread/JobScheduleHelper.java
+18
-2
LogCallbackThread.java
...core/src/main/java/com/byit/thread/LogCallbackThread.java
+3
-0
LogScanHelper.java
...min-core/src/main/java/com/byit/thread/LogScanHelper.java
+1
-1
RunRecordingScanHelper.java
...src/main/java/com/byit/thread/RunRecordingScanHelper.java
+1
-0
JobTaskRunLogMapper.xml
...in-core/src/main/resources/mapper/JobTaskRunLogMapper.xml
+1
-1
RunJobThread.java
...ector-plugin/src/main/java/com/byit/rpc/RunJobThread.java
+6
-5
TestAddFlow.java
...t-demo-client/src/main/java/com/byit/job/TestAddFlow.java
+4
-4
TestPy.java
...t/byit-demo-client/src/main/java/com/byit/job/TestPy.java
+9
-3
test.py
demo-client/byit-demo-client/src/main/resources/test.py
+0
-37
test.py
demo-client/byit-demo-client/test.py
+4
-0
No files found.
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/impl/JobTaskRunLogServiceImpl.java
View file @
cf5acc9c
...
@@ -4,6 +4,7 @@ import com.byit.mapper.JobTaskRunLogMapper;
...
@@ -4,6 +4,7 @@ import com.byit.mapper.JobTaskRunLogMapper;
import
com.byit.model.JobTaskRunLog
;
import
com.byit.model.JobTaskRunLog
;
import
com.byit.model.JobTaskRunLogWithBLOBs
;
import
com.byit.model.JobTaskRunLogWithBLOBs
;
import
com.byit.service.JobTaskRunLogService
;
import
com.byit.service.JobTaskRunLogService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
...
@@ -17,6 +18,7 @@ import java.util.List;
...
@@ -17,6 +18,7 @@ import java.util.List;
* @author: huangfu
* @author: huangfu
* @date: 2019/12/20 19:43
* @date: 2019/12/20 19:43
**/
**/
@Slf4j
@Service
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
JobTaskRunLogServiceImpl
implements
JobTaskRunLogService
{
public
class
JobTaskRunLogServiceImpl
implements
JobTaskRunLogService
{
...
@@ -56,6 +58,7 @@ public class JobTaskRunLogServiceImpl implements JobTaskRunLogService {
...
@@ -56,6 +58,7 @@ public class JobTaskRunLogServiceImpl implements JobTaskRunLogService {
@Override
@Override
public
int
saveJobTaskRunLog
(
JobTaskRunLogWithBLOBs
jobTaskRunLog
)
{
public
int
saveJobTaskRunLog
(
JobTaskRunLogWithBLOBs
jobTaskRunLog
)
{
log
.
info
(
"--------------saveJobTaskRunLog start【{}】------------------------"
,
jobTaskRunLog
);
return
jobTaskRunLogMapper
.
saveJobTaskRunLog
(
jobTaskRunLog
);
return
jobTaskRunLogMapper
.
saveJobTaskRunLog
(
jobTaskRunLog
);
}
}
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/impl/RunNodeServiceImpl.java
View file @
cf5acc9c
...
@@ -55,6 +55,7 @@ public class RunNodeServiceImpl implements RunNodeServer {
...
@@ -55,6 +55,7 @@ public class RunNodeServiceImpl implements RunNodeServer {
jobTask
.
setTriggerTime
(
flow
.
getTriggerNextTime
());
jobTask
.
setTriggerTime
(
flow
.
getTriggerNextTime
());
}
}
jobTask
.
setRunId
(
runId
);
jobTask
.
setRunId
(
runId
);
jobTask
.
setFlowName
(
flow
.
getFlowName
());
jobTasks
.
add
(
jobTask
);
jobTasks
.
add
(
jobTask
);
});
});
jobTaskService
.
saveJobTasks
(
jobTasks
);
jobTaskService
.
saveJobTasks
(
jobTasks
);
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/impl/TaskAndLogServerImpl.java
View file @
cf5acc9c
...
@@ -33,7 +33,7 @@ public class TaskAndLogServerImpl implements TaskAndLogServer {
...
@@ -33,7 +33,7 @@ public class TaskAndLogServerImpl implements TaskAndLogServer {
jobTaskService
.
removeMythJobTaskById
(
jobTask
.
getId
());
jobTaskService
.
removeMythJobTaskById
(
jobTask
.
getId
());
//添加任务日志
//添加任务日志
JobTaskRunLogWithBLOBs
jobTaskRunLog
=
new
JobTaskRunLogWithBLOBs
();
JobTaskRunLogWithBLOBs
jobTaskRunLog
=
new
JobTaskRunLogWithBLOBs
();
jobTaskRunLog
.
setR
eR
unId
(
jobTask
.
getRunId
());
jobTaskRunLog
.
setRunId
(
jobTask
.
getRunId
());
jobTaskRunLog
.
setNodeId
(
jobTask
.
getNodeId
());
jobTaskRunLog
.
setNodeId
(
jobTask
.
getNodeId
());
jobTaskRunLog
.
setNodeName
(
jobTask
.
getNodeName
());
jobTaskRunLog
.
setNodeName
(
jobTask
.
getNodeName
());
jobTaskRunLog
.
setJobType
(
jobTask
.
getJobType
());
jobTaskRunLog
.
setJobType
(
jobTask
.
getJobType
());
...
@@ -48,13 +48,20 @@ public class TaskAndLogServerImpl implements TaskAndLogServer {
...
@@ -48,13 +48,20 @@ public class TaskAndLogServerImpl implements TaskAndLogServer {
jobTaskRunLog
.
setRunMsg
(
"上级节点执行失败"
);
jobTaskRunLog
.
setRunMsg
(
"上级节点执行失败"
);
jobTaskRunLog
.
setRunParams
(
jobTask
.
getRunParam
());
jobTaskRunLog
.
setRunParams
(
jobTask
.
getRunParam
());
jobTaskRunLog
.
setRunCommand
(
jobTask
.
getRunCommand
());
jobTaskRunLog
.
setRunCommand
(
jobTask
.
getRunCommand
());
jobTaskRunLog
.
setRunType
(
jobTask
.
getJobType
()
);
jobTaskRunLog
.
setRunType
(
"2"
);
jobTaskRunLog
.
setTriggerCode
(
"2"
);
jobTaskRunLog
.
setTriggerCode
(
"2"
);
jobTaskRunLog
.
setTriggerMsg
(
"未执行调度"
);
jobTaskRunLog
.
setTriggerMsg
(
"未执行调度"
);
jobTaskRunLog
.
setTriggerTime
(
thisDate
);
jobTaskRunLog
.
setTriggerTime
(
thisDate
);
jobTaskRunLog
.
setStartTime
(
thisDate
);
jobTaskRunLog
.
setStartTime
(
thisDate
);
jobTaskRunLog
.
setEndTime
(
thisDate
);
jobTaskRunLog
.
setEndTime
(
thisDate
);
jobTaskRunLog
.
setAlertEnd
(
"1"
);
if
(
"end"
.
equals
(
jobTask
.
getNodeName
())){
//未完成告警
jobTaskRunLog
.
setAlertEnd
(
"0"
);
}
else
{
//已完成告警
jobTaskRunLog
.
setAlertEnd
(
"1"
);
}
//添加日志节点
//添加日志节点
jobTaskRunLogService
.
saveJobTaskRunLog
(
jobTaskRunLog
);
jobTaskRunLogService
.
saveJobTaskRunLog
(
jobTaskRunLog
);
}
}
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/task/JavaBeanJobTask.java
View file @
cf5acc9c
...
@@ -79,6 +79,15 @@ public class JavaBeanJobTask implements TimerTask {
...
@@ -79,6 +79,15 @@ public class JavaBeanJobTask implements TimerTask {
jobTaskRunLog
.
setTriggerTime
(
new
Date
());
jobTaskRunLog
.
setTriggerTime
(
new
Date
());
jobTaskRunLog
.
setTriggerCode
(
dispatchResponseDto
.
getCode
());
jobTaskRunLog
.
setTriggerCode
(
dispatchResponseDto
.
getCode
());
jobTaskRunLog
.
setTriggerMsg
(
dispatchResponseDto
.
getMsg
());
jobTaskRunLog
.
setTriggerMsg
(
dispatchResponseDto
.
getMsg
());
if
(!(
"1"
.
equals
(
dispatchResponseDto
.
getCode
()))){
Date
thisTime
=
new
Date
();
jobTaskRunLog
.
setStartTime
(
thisTime
);
jobTaskRunLog
.
setEndTime
(
thisTime
);
jobTaskRunLog
.
setRunCode
(
"2"
);
jobTaskRunLog
.
setAlertEnd
(
"1"
);
jobTaskRunLog
.
setRunMsg
(
dispatchResponseDto
.
getMsg
());
}
jobTaskRunLogService
.
updateJobTaskRunLogWithBLOBs
(
jobTaskRunLog
);
jobTaskRunLogService
.
updateJobTaskRunLogWithBLOBs
(
jobTaskRunLog
);
}
}
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/JobScheduleHelper.java
View file @
cf5acc9c
...
@@ -155,8 +155,13 @@ public class JobScheduleHelper{
...
@@ -155,8 +155,13 @@ public class JobScheduleHelper{
//记录状态码
//记录状态码
String
runCode
=
jobTaskRunLog
.
getRunCode
();
String
runCode
=
jobTaskRunLog
.
getRunCode
();
log
.
info
(
"-------------------【查询到有失败的节点,运行状态为:{}】-------------------"
,
runCode
);
log
.
info
(
"-------------------【查询到有失败的节点,运行状态为:{}】-------------------"
,
runCode
);
//删除这个数据 并且添加到日志
/**
taskAndLogServer
.
addRunLogAndRemoveTask
(
jobTask
,
runCode
);
* 判断父类节点是否全部都执行完毕了
*/
if
(
parentIsEnd
(
jobTaskRunLogList
)){
//删除这个数据 并且添加到日志
taskAndLogServer
.
addRunLogAndRemoveTask
(
jobTask
,
runCode
);
}
}
}
return
;
return
;
...
@@ -428,4 +433,15 @@ public class JobScheduleHelper{
...
@@ -428,4 +433,15 @@ public class JobScheduleHelper{
return
jobTaskRunLog
.
getLogId
();
return
jobTaskRunLog
.
getLogId
();
}
}
private
boolean
parentIsEnd
(
List
<
JobTaskRunLog
>
jobTaskRunLogList
){
boolean
flag
=
true
;
for
(
JobTaskRunLog
jobTaskRunLog
:
jobTaskRunLogList
)
{
if
(
"0"
.
equals
(
jobTaskRunLog
.
getRunCode
()))
{
flag
=
false
;
break
;
}
}
return
flag
;
}
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/LogCallbackThread.java
View file @
cf5acc9c
package
com
.
byit
.
thread
;
package
com
.
byit
.
thread
;
import
cn.hutool.core.date.DateUtil
;
import
com.byit.job.dto.JobRunResultDto
;
import
com.byit.job.dto.JobRunResultDto
;
import
com.byit.model.JobTaskRunLogWithBLOBs
;
import
com.byit.model.JobTaskRunLogWithBLOBs
;
import
com.byit.service.impl.JobTaskRunLogServiceImpl
;
import
com.byit.service.impl.JobTaskRunLogServiceImpl
;
...
@@ -28,7 +29,9 @@ public class LogCallbackThread implements Runnable {
...
@@ -28,7 +29,9 @@ public class LogCallbackThread implements Runnable {
JobTaskRunLogWithBLOBs
jobTaskRunLog
=
new
JobTaskRunLogWithBLOBs
();
JobTaskRunLogWithBLOBs
jobTaskRunLog
=
new
JobTaskRunLogWithBLOBs
();
jobTaskRunLog
.
setLogId
(
jobRunResultDto
.
getLogId
());
jobTaskRunLog
.
setLogId
(
jobRunResultDto
.
getLogId
());
jobTaskRunLog
.
setStartTime
(
jobRunResultDto
.
getStartTime
());
jobTaskRunLog
.
setStartTime
(
jobRunResultDto
.
getStartTime
());
System
.
out
.
println
(
DateUtil
.
format
(
jobRunResultDto
.
getStartTime
(),
"yyyy-MM-dd HH:mm:ss"
));
jobTaskRunLog
.
setEndTime
(
jobRunResultDto
.
getEndTime
());
jobTaskRunLog
.
setEndTime
(
jobRunResultDto
.
getEndTime
());
System
.
out
.
println
(
DateUtil
.
format
(
jobRunResultDto
.
getEndTime
(),
"yyyy-MM-dd HH:mm:ss"
));
jobTaskRunLog
.
setRunCode
(
jobRunResultDto
.
getReturnResult
().
getCode
());
jobTaskRunLog
.
setRunCode
(
jobRunResultDto
.
getReturnResult
().
getCode
());
jobTaskRunLog
.
setRunMsg
(
jobRunResultDto
.
getReturnResult
().
getMsg
());
jobTaskRunLog
.
setRunMsg
(
jobRunResultDto
.
getReturnResult
().
getMsg
());
jobTaskRunLog
.
setAlertEnd
(
"0"
);
jobTaskRunLog
.
setAlertEnd
(
"0"
);
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/LogScanHelper.java
View file @
cf5acc9c
...
@@ -180,7 +180,7 @@ public class LogScanHelper {
...
@@ -180,7 +180,7 @@ public class LogScanHelper {
String
runId
=
endNode
.
getRunId
(
);
String
runId
=
endNode
.
getRunId
(
);
Integer
flowId
=
endNode
.
getFlowId
(
);
Integer
flowId
=
endNode
.
getFlowId
(
);
//如果运行结果为null 那么就是调度都没成功 那么就取调度的值
//如果运行结果为null 那么就是调度都没成功 那么就取调度的值
String
code
=
StringUtils
.
isNotBlank
(
endNode
.
getRunCode
())?
endNode
.
getRunCode
()
:
endNode
.
getTrigger
Code
();
String
code
=
endNode
.
getRun
Code
();
runRecordingService
.
updateRunRecordingByFlowIdAndRunId
(
RunRecording
.
builder
().
runId
(
runId
).
flowId
(
flowId
).
flowRunResult
(
code
).
flowStatus
(
RunRecordingEnum
.
FLOW_STATUS_IS_END
.
getCode
()).
build
());
runRecordingService
.
updateRunRecordingByFlowIdAndRunId
(
RunRecording
.
builder
().
runId
(
runId
).
flowId
(
flowId
).
flowRunResult
(
code
).
flowStatus
(
RunRecordingEnum
.
FLOW_STATUS_IS_END
.
getCode
()).
build
());
endNode
.
setAlertEnd
(
"1"
);
endNode
.
setAlertEnd
(
"1"
);
jobTaskRunLogService
.
updateJobTaskRunLog
(
endNode
);
jobTaskRunLogService
.
updateJobTaskRunLog
(
endNode
);
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/RunRecordingScanHelper.java
View file @
cf5acc9c
...
@@ -232,6 +232,7 @@ public class RunRecordingScanHelper {
...
@@ -232,6 +232,7 @@ public class RunRecordingScanHelper {
if
(
CollectionUtil
.
isNotEmpty
(
jobTaskRunLogs
))
{
if
(
CollectionUtil
.
isNotEmpty
(
jobTaskRunLogs
))
{
jobTaskRunLogs
.
forEach
(
jobTaskRunLog
->
{
jobTaskRunLogs
.
forEach
(
jobTaskRunLog
->
{
long
timeConsuming
=
TimeUnit
.
MILLISECONDS
.
toMinutes
(
jobTaskRunLog
.
getEndTime
().
getTime
()
-
jobTaskRunLog
.
getStartTime
().
getTime
());
long
timeConsuming
=
TimeUnit
.
MILLISECONDS
.
toMinutes
(
jobTaskRunLog
.
getEndTime
().
getTime
()
-
jobTaskRunLog
.
getStartTime
().
getTime
());
log
.
info
(
"######################{}#####################3"
,
timeConsuming
);
stringBuilder
.
append
(
"<tr align='center'>"
)
stringBuilder
.
append
(
"<tr align='center'>"
)
.
append
(
String
.
format
(
"<td>%s</td>"
,
jobTaskRunLog
.
getNodeName
()))
.
append
(
String
.
format
(
"<td>%s</td>"
,
jobTaskRunLog
.
getNodeName
()))
.
append
(
String
.
format
(
"<td>%s</td>"
,
DateUtil
.
format
(
jobTaskRunLog
.
getStartTime
(),
DATE_FORMAT
)))
.
append
(
String
.
format
(
"<td>%s</td>"
,
DateUtil
.
format
(
jobTaskRunLog
.
getStartTime
(),
DATE_FORMAT
)))
...
...
byit-myth-core/myth-admin-core/src/main/resources/mapper/JobTaskRunLogMapper.xml
View file @
cf5acc9c
...
@@ -64,7 +64,7 @@
...
@@ -64,7 +64,7 @@
<select
id=
"findJobTaskRunLogEndOrFailureNode"
resultMap=
"BaseResultMap"
>
<select
id=
"findJobTaskRunLogEndOrFailureNode"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from job_task_run_log
select
<include
refid=
"Base_Column_List"
/>
from job_task_run_log
where
(node_name='END' or run_code = '2' or run_code = '4' or trigger_code = '2') and alert_end
= '0'
where
node_name='END' and alert_end = '0' and run_code !
= '0'
</select>
</select>
<select
id=
"findNotEndVirtualNode"
resultMap=
"BaseResultMap"
>
<select
id=
"findNotEndVirtualNode"
resultMap=
"BaseResultMap"
>
...
...
byit-myth-executor/myth-exector-plugin/src/main/java/com/byit/rpc/RunJobThread.java
View file @
cf5acc9c
...
@@ -45,18 +45,19 @@ public class RunJobThread implements Runnable {
...
@@ -45,18 +45,19 @@ public class RunJobThread implements Runnable {
log
.
info
(
"---------服务器端:{},花费时间:{}-------------"
,
jobRunResultDto
,
jobRunResultDto
.
getStartTime
().
getTime
()-
jobRunResultDto
.
getEndTime
().
getTime
());
log
.
info
(
"---------服务器端:{},花费时间:{}-------------"
,
jobRunResultDto
,
jobRunResultDto
.
getStartTime
().
getTime
()-
jobRunResultDto
.
getEndTime
().
getTime
());
}
}
private
ReturnResult
<
String
>
runJob
(
String
jobHandlerName
,
String
param
){
private
ReturnResult
runJob
(
String
jobHandlerName
,
String
param
){
ReturnResult
<
String
>
returnResult
=
ReturnResult
.
SUCCESS
;
Class
<?
extends
IJobHandler
>
jobClass
=
JobUtils
.
jobCache
.
get
(
jobHandlerName
);
Class
<?
extends
IJobHandler
>
jobClass
=
JobUtils
.
jobCache
.
get
(
jobHandlerName
);
try
{
try
{
IJobHandler
iJobHandler
=
jobClass
.
newInstance
(
);
IJobHandler
iJobHandler
=
jobClass
.
newInstance
();
return
Result
=
iJobHandler
.
execute
(
param
);
return
iJobHandler
.
execute
(
param
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
e
.
printStackTrace
(
);
ReturnResult
returnResult
=
new
ReturnResult
();
returnResult
.
setMsg
(
e
.
getMessage
());
returnResult
.
setMsg
(
e
.
getMessage
());
returnResult
.
setCode
(
JobResultEnum
.
FAIL
.
getRes
());
returnResult
.
setCode
(
JobResultEnum
.
FAIL
.
getRes
());
return
returnResult
;
}
}
return
returnResult
;
}
}
}
}
demo-client/byit-demo-client/src/main/java/com/byit/job/TestAddFlow.java
View file @
cf5acc9c
...
@@ -33,8 +33,8 @@ public class TestAddFlow {
...
@@ -33,8 +33,8 @@ public class TestAddFlow {
.
build
();
.
build
();
pluginFlow
.
setName
(
"
测试时间执行的工作流
"
);
pluginFlow
.
setName
(
"
自动化测试原子弹
"
);
pluginFlow
.
setDesc
(
"
这是一个测试的任务流
"
);
pluginFlow
.
setDesc
(
"
自动化测试原子弹
"
);
pluginFlow
.
setConfig
(
build
);
pluginFlow
.
setConfig
(
build
);
pluginFlow
.
setPrincipal
(
"皇甫科星"
);
pluginFlow
.
setPrincipal
(
"皇甫科星"
);
pluginFlow
.
setRePublish
(
false
);
pluginFlow
.
setRePublish
(
false
);
...
@@ -73,7 +73,7 @@ public class TestAddFlow {
...
@@ -73,7 +73,7 @@ public class TestAddFlow {
pluginNode2
.
setAuthor
(
"皇甫"
);
pluginNode2
.
setAuthor
(
"皇甫"
);
pluginNode2
.
setJobType
(
"JAVA"
);
pluginNode2
.
setJobType
(
"JAVA"
);
pluginNode2
.
setHandlerName
(
"addJob"
);
pluginNode2
.
setHandlerName
(
"addJob"
);
pluginNode2
.
setRunParam
(
"1"
);
pluginNode2
.
setRunParam
(
"
add
1"
);
pluginNodeConfig2
.
setFailedRetryCount
(
2
);
pluginNodeConfig2
.
setFailedRetryCount
(
2
);
pluginNodeConfig2
.
setFailedRetryInterval
(
TimeUnit
.
MINUTES
.
toSeconds
(
2
));
pluginNodeConfig2
.
setFailedRetryInterval
(
TimeUnit
.
MINUTES
.
toSeconds
(
2
));
pluginNodeConfig2
.
setNodeCron
(
"0 0/7 * * * ? *"
);
pluginNodeConfig2
.
setNodeCron
(
"0 0/7 * * * ? *"
);
...
@@ -111,7 +111,7 @@ public class TestAddFlow {
...
@@ -111,7 +111,7 @@ public class TestAddFlow {
pluginNode4
.
setAuthor
(
"皇甫"
);
pluginNode4
.
setAuthor
(
"皇甫"
);
pluginNode4
.
setJobType
(
"JAVA"
);
pluginNode4
.
setJobType
(
"JAVA"
);
pluginNode4
.
setHandlerName
(
"addJob"
);
pluginNode4
.
setHandlerName
(
"addJob"
);
pluginNode4
.
setRunParam
(
"add
Job3
"
);
pluginNode4
.
setRunParam
(
"add
3success
"
);
pluginNodeConfig4
.
setFailedRetryCount
(
2
);
pluginNodeConfig4
.
setFailedRetryCount
(
2
);
pluginNodeConfig4
.
setFailedRetryInterval
(
TimeUnit
.
MINUTES
.
toSeconds
(
2
));
pluginNodeConfig4
.
setFailedRetryInterval
(
TimeUnit
.
MINUTES
.
toSeconds
(
2
));
pluginNodeConfig4
.
setNodeCron
(
"0 0/7 * * * ? *"
);
pluginNodeConfig4
.
setNodeCron
(
"0 0/7 * * * ? *"
);
...
...
demo-client/byit-demo-client/src/main/java/com/byit/job/TestPy.java
View file @
cf5acc9c
...
@@ -2,6 +2,7 @@ package com.byit.job;
...
@@ -2,6 +2,7 @@ package com.byit.job;
import
org.apache.commons.exec.CommandLine
;
import
org.apache.commons.exec.CommandLine
;
import
org.apache.commons.exec.DefaultExecutor
;
import
org.apache.commons.exec.DefaultExecutor
;
import
org.apache.commons.exec.ExecuteWatchdog
;
import
org.apache.commons.exec.PumpStreamHandler
;
import
org.apache.commons.exec.PumpStreamHandler
;
import
java.io.*
;
import
java.io.*
;
...
@@ -10,18 +11,23 @@ import java.nio.charset.StandardCharsets;
...
@@ -10,18 +11,23 @@ import java.nio.charset.StandardCharsets;
public
class
TestPy
{
public
class
TestPy
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
public
static
void
main
(
String
[]
args
)
throws
IOException
,
InterruptedException
{
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
PumpStreamHandler
pumpStreamHandler
=
new
PumpStreamHandler
(
outputStream
,
outputStream
,
null
);
PumpStreamHandler
pumpStreamHandler
=
new
PumpStreamHandler
(
outputStream
,
outputStream
,
null
);
ExecuteWatchdog
watchdog
=
new
ExecuteWatchdog
(
Integer
.
MAX_VALUE
);
DefaultExecutor
defaultExecutor
=
new
DefaultExecutor
();
DefaultExecutor
defaultExecutor
=
new
DefaultExecutor
();
defaultExecutor
.
setWatchdog
(
watchdog
);
defaultExecutor
.
setExitValues
(
null
);
defaultExecutor
.
setExitValues
(
null
);
defaultExecutor
.
setStreamHandler
(
pumpStreamHandler
);
defaultExecutor
.
setStreamHandler
(
pumpStreamHandler
);
CommandLine
commandline
=
new
CommandLine
(
"python"
);
CommandLine
commandline
=
new
CommandLine
(
"python"
);
commandline
.
addArgument
(
"D:\\2020project\\byit-myth-job\\demo-client\\byit-demo-client\\
src\\main\\resources\\
test.py"
);
commandline
.
addArgument
(
"D:\\2020project\\byit-myth-job\\demo-client\\byit-demo-client\\test.py"
);
int
execute
=
defaultExecutor
.
execute
(
commandline
);
int
execute
=
defaultExecutor
.
execute
(
commandline
);
byte
[]
bytes
=
outputStream
.
toByteArray
();
byte
[]
bytes
=
outputStream
.
toByteArray
();
Thread
.
sleep
(
3000
);
watchdog
.
destroyProcess
();
System
.
out
.
println
(
execute
);
System
.
out
.
println
(
execute
);
System
.
out
.
println
(
new
String
(
bytes
,
0
,
bytes
.
length
,
StandardCharsets
.
UTF_8
));
System
.
out
.
println
(
new
String
(
bytes
,
0
,
bytes
.
length
,
StandardCharsets
.
UTF_8
));
}
}
}
}
demo-client/byit-demo-client/src/main/resources/test.py
deleted
100644 → 0
View file @
86aaa505
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
"--------------------------------------------"
)
print
(
100
/
10
)
print
(
5
/
0
)
\ No newline at end of file
demo-client/byit-demo-client/test.py
0 → 100644
View file @
cf5acc9c
import
time
while
True
:
print
(
"--------------------------------------------"
)
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