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
11510469
Commit
11510469
authored
May 18, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
执行机错误传递
parent
2028369e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
39 deletions
+51
-39
CommandAndScriptProcessingMachine.java
...com/byit/node/impl/CommandAndScriptProcessingMachine.java
+26
-20
LogDataProcessingMachine.java
...ain/java/com/byit/node/impl/LogDataProcessingMachine.java
+1
-0
RunScriptProcessingMachine.java
...n/java/com/byit/node/impl/RunScriptProcessingMachine.java
+24
-19
No files found.
byit-myth-executor/myth-executor-server/src/main/java/com/byit/node/impl/CommandAndScriptProcessingMachine.java
View file @
11510469
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import
com.byit.dto.executor.ScriptDto
;
import
com.byit.dto.executor.ScriptParamAndPlaceholderDto
;
import
com.byit.enums.PlaceholderEnum
;
import
com.byit.exceptions.ExecutorException
;
import
com.byit.filesystem.FileSystem
;
import
com.byit.job.utils.DateUtil
;
import
com.byit.job.utils.PlaceholderUtils
;
...
...
@@ -41,30 +42,35 @@ public class CommandAndScriptProcessingMachine implements ProcessingMachine {
@Override
public
void
executor
(
ScriptDto
scriptDto
,
ProcessingNodeChain
processingNodeChain
)
{
log
.
debug
(
"-----执行到命令和脚本的处理节点,开始初始化命令和脚本------------"
);
String
command
=
scriptDto
.
getCommand
();
log
.
debug
(
"-----初始命令为{}------------"
,
command
);
String
param
=
scriptDto
.
getParam
();
if
(
StringUtils
.
isNotBlank
(
param
))
{
ScriptParamAndPlaceholderDto
paramAndPlaceholderDto
=
JSON
.
parseObject
(
param
,
ScriptParamAndPlaceholderDto
.
class
);
try
{
log
.
debug
(
"-----执行到命令和脚本的处理节点,开始初始化命令和脚本------------"
);
String
command
=
scriptDto
.
getCommand
();
log
.
debug
(
"-----初始命令为{}------------"
,
command
);
String
param
=
scriptDto
.
getParam
();
if
(
StringUtils
.
isNotBlank
(
param
))
{
ScriptParamAndPlaceholderDto
paramAndPlaceholderDto
=
JSON
.
parseObject
(
param
,
ScriptParamAndPlaceholderDto
.
class
);
//判断是否需要拉取文件服务器的文件,包含biz_file的条件下会对这个字段进行替换
if
(
command
.
contains
(
PlaceholderEnum
.
BIZ_SCRIPT_FILE
.
getName
()))
{
String
scriptPath
=
byteArrayToFile
(
scriptDto
.
getRemotePath
(),
paramAndPlaceholderDto
);
log
.
debug
(
"-----远程地址的文件被拉取到:[{}]------------"
,
scriptPath
);
//初始化命令信息
command
=
PlaceholderUtils
.
initCommand
(
command
,
scriptPath
);
log
.
debug
(
"-----执行命令初始化完成,命令为:[{}]------------"
,
command
);
//判断是否需要拉取文件服务器的文件,包含biz_file的条件下会对这个字段进行替换
if
(
command
.
contains
(
PlaceholderEnum
.
BIZ_SCRIPT_FILE
.
getName
()))
{
String
scriptPath
=
byteArrayToFile
(
scriptDto
.
getRemotePath
(),
paramAndPlaceholderDto
);
log
.
debug
(
"-----远程地址的文件被拉取到:[{}]------------"
,
scriptPath
);
//初始化命令信息
command
=
PlaceholderUtils
.
initCommand
(
command
,
scriptPath
);
log
.
debug
(
"-----执行命令初始化完成,命令为:[{}]------------"
,
command
);
scriptDto
.
setCommand
(
command
);
}
//执行命令参数的替换
command
=
PlaceholderUtils
.
commandReplace
(
command
,
paramAndPlaceholderDto
.
getParam
());
log
.
debug
(
"-----命令参数替换完成,命令为:[{}]------------"
,
command
);
scriptDto
.
setCommand
(
command
);
}
//执行命令参数的替换
command
=
PlaceholderUtils
.
commandReplace
(
command
,
paramAndPlaceholderDto
.
getParam
());
log
.
debug
(
"-----命令参数替换完成,命令为:[{}]------------"
,
command
);
scriptDto
.
setCommand
(
command
);
//将脚本的携带的参数 拼接在命令后方 python test.py -sex 男 -name 张三 -age 14
log
.
info
(
"---------命令及脚本参数处理完成,此节点处理数据为:[{}]-----------"
,
scriptDto
);
processingNodeChain
.
doProcessing
(
scriptDto
,
processingNodeChain
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ExecutorException
(
e
);
}
//将脚本的携带的参数 拼接在命令后方 python test.py -sex 男 -name 张三 -age 14
log
.
info
(
"---------命令及脚本参数处理完成,此节点处理数据为:[{}]-----------"
,
scriptDto
);
processingNodeChain
.
doProcessing
(
scriptDto
,
processingNodeChain
);
}
/**
...
...
byit-myth-executor/myth-executor-server/src/main/java/com/byit/node/impl/LogDataProcessingMachine.java
View file @
11510469
...
...
@@ -59,6 +59,7 @@ public class LogDataProcessingMachine implements ProcessingMachine {
logPath
=
fileSystem
.
uploadFile
(
logDataByte
,
LOG_SUFFIX
,
fileMateData
);
}
scriptDto
.
setLogRemotePath
(
logPath
);
processingNodeChain
.
doProcessing
(
scriptDto
,
processingNodeChain
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ExecutorException
(
e
);
...
...
byit-myth-executor/myth-executor-server/src/main/java/com/byit/node/impl/RunScriptProcessingMachine.java
View file @
11510469
package
com
.
byit
.
node
.
impl
;
import
com.byit.dto.executor.ScriptDto
;
import
com.byit.exceptions.ExecutorException
;
import
com.byit.node.ProcessingNodeChain
;
import
com.byit.node.machine.ProcessingMachine
;
import
com.byit.process.MythJobProcess
;
...
...
@@ -32,25 +33,29 @@ public class RunScriptProcessingMachine implements ProcessingMachine {
@Override
public
void
executor
(
ScriptDto
scriptDto
,
ProcessingNodeChain
processingNodeChain
)
{
boolean
isRunNode
=
scriptDto
.
getRunId
().
contains
(
"REAL-EXEC-"
);
List
<
String
>
cmdList
=
Arrays
.
asList
(
scriptDto
.
getCommand
().
split
(
" "
));
MythJobProcess
mythJobProcess
;
if
(
isRunNode
)
{
mythJobProcess
=
new
MythJobProcess
(
cmdList
,
null
,
null
,
scriptDto
.
getLogId
(),
stringRedisTemplate
);
}
else
{
mythJobProcess
=
new
MythJobProcess
(
cmdList
,
null
,
null
,
scriptDto
.
getLogId
(),
null
);
try
{
boolean
isRunNode
=
scriptDto
.
getRunId
().
contains
(
"REAL-EXEC-"
);
List
<
String
>
cmdList
=
Arrays
.
asList
(
scriptDto
.
getCommand
().
split
(
" "
));
MythJobProcess
mythJobProcess
;
if
(
isRunNode
)
{
mythJobProcess
=
new
MythJobProcess
(
cmdList
,
null
,
null
,
scriptDto
.
getLogId
(),
stringRedisTemplate
);
}
else
{
mythJobProcess
=
new
MythJobProcess
(
cmdList
,
null
,
null
,
scriptDto
.
getLogId
(),
null
);
}
//保存日志
String
logData
=
mythJobProcess
.
call
();
//成功 是0 失败是其他的 杀死是-100
int
exitCode
=
mythJobProcess
.
getExitCode
();
if
(
exitCode
==
NODE_KILL_CODE
){
logData
=
KILL_MESSAGE
;
}
scriptDto
.
setRunLogData
(
logData
);
scriptDto
.
setExitCode
(
exitCode
);
processingNodeChain
.
doProcessing
(
scriptDto
,
processingNodeChain
);
}
catch
(
Exception
e
)
{
throw
new
ExecutorException
(
e
);
}
//保存日志
String
logData
=
mythJobProcess
.
call
();
//成功 是0 失败是其他的 杀死是-100
int
exitCode
=
mythJobProcess
.
getExitCode
();
if
(
exitCode
==
NODE_KILL_CODE
){
logData
=
KILL_MESSAGE
;
}
scriptDto
.
setRunLogData
(
logData
);
scriptDto
.
setExitCode
(
exitCode
);
processingNodeChain
.
doProcessing
(
scriptDto
,
processingNodeChain
);
}
}
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