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
c2f10e5a
Commit
c2f10e5a
authored
Feb 22, 2020
by
guo_minglei@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将日志运行线程改为有返回值的实现方式
parent
92551bc7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
12 deletions
+4
-12
MythJobProcess.java
...com/byit/executor/jobExecutor/process/MythJobProcess.java
+4
-12
No files found.
byit-myth-core/myth-executor-core/src/main/java/com/byit/executor/jobExecutor/process/MythJobProcess.java
View file @
c2f10e5a
...
@@ -15,6 +15,7 @@ import java.nio.charset.StandardCharsets;
...
@@ -15,6 +15,7 @@ import java.nio.charset.StandardCharsets;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -24,7 +25,7 @@ import java.util.concurrent.TimeUnit;
...
@@ -24,7 +25,7 @@ import java.util.concurrent.TimeUnit;
* @create: 2020-01-13 17:56
* @create: 2020-01-13 17:56
*/
*/
@Slf4j
@Slf4j
public
class
MythJobProcess
implements
Runnable
{
public
class
MythJobProcess
implements
Callable
<
String
>
{
//杀死命令
//杀死命令
public
static
String
KILL_COMMAND
=
"kill"
;
public
static
String
KILL_COMMAND
=
"kill"
;
//工作目录
//工作目录
...
@@ -49,10 +50,6 @@ public class MythJobProcess implements Runnable{
...
@@ -49,10 +50,6 @@ public class MythJobProcess implements Runnable{
private
String
effectiveUser
=
null
;
private
String
effectiveUser
=
null
;
//本次任务对应的日志id
//本次任务对应的日志id
private
Integer
logId
;
private
Integer
logId
;
//执行日志内容
private
String
logFilePath
;
//上传日志工具类
private
FileSystemContext
fileSystemContext
;
public
MythJobProcess
(
final
List
<
String
>
cmd
,
final
Map
<
String
,
String
>
env
,
public
MythJobProcess
(
final
List
<
String
>
cmd
,
final
Map
<
String
,
String
>
env
,
final
String
workingDir
,
final
Integer
logId
)
{
final
String
workingDir
,
final
Integer
logId
)
{
...
@@ -79,7 +76,7 @@ public class MythJobProcess implements Runnable{
...
@@ -79,7 +76,7 @@ public class MythJobProcess implements Runnable{
*/
*/
@SneakyThrows
@SneakyThrows
@Override
@Override
public
void
run
()
{
public
String
call
()
{
//判断是否执行过
//判断是否执行过
if
(
this
.
isStarted
()
||
this
.
isComplete
())
{
if
(
this
.
isStarted
()
||
this
.
isComplete
())
{
throw
new
IllegalStateException
(
"该过程只能使用一次"
);
throw
new
IllegalStateException
(
"该过程只能使用一次"
);
...
@@ -145,8 +142,7 @@ public class MythJobProcess implements Runnable{
...
@@ -145,8 +142,7 @@ public class MythJobProcess implements Runnable{
if
(
this
.
process
.
isAlive
()){
if
(
this
.
process
.
isAlive
()){
this
.
process
.
destroy
();
this
.
process
.
destroy
();
}
}
logFilePath
=
outputGobbler
.
getRecentLog
()
+
"\n"
+
errorGobbler
.
getRecentLog
();
return
outputGobbler
.
getRecentLog
()
+
"\n"
+
errorGobbler
.
getRecentLog
();
//TODO 将日志写到fastdfs上
}
}
}
}
...
@@ -301,8 +297,4 @@ public class MythJobProcess implements Runnable{
...
@@ -301,8 +297,4 @@ public class MythJobProcess implements Runnable{
public
String
getEffectiveUser
()
{
public
String
getEffectiveUser
()
{
return
this
.
effectiveUser
;
return
this
.
effectiveUser
;
}
}
public
String
getLogContent
(){
return
logFilePath
;
}
}
}
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