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
c42a09c2
Commit
c42a09c2
authored
Feb 21, 2020
by
guo_minglei@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将运行日志放到fastdfs上
parent
dfdd469e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
MythJobProcess.java
...com/byit/executor/jobExecutor/process/MythJobProcess.java
+15
-6
No files found.
byit-myth-core/myth-executor-core/src/main/java/com/byit/executor/jobExecutor/process/MythJobProcess.java
View file @
c42a09c2
package
com
.
byit
.
executor
.
jobExecutor
.
process
;
package
com
.
byit
.
executor
.
jobExecutor
.
process
;
import
com.byit.executor.conf.FileSystemContext
;
import
com.byit.executor.util.JobContentUtil
;
import
com.byit.executor.util.JobContentUtil
;
import
com.byit.executor.util.LogGobbler
;
import
com.byit.executor.util.LogGobbler
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Joiner
;
...
@@ -11,6 +12,7 @@ import java.io.IOException;
...
@@ -11,6 +12,7 @@ import java.io.IOException;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
...
@@ -49,22 +51,26 @@ public class MythJobProcess implements Runnable{
...
@@ -49,22 +51,26 @@ public class MythJobProcess implements Runnable{
//本次任务对应的日志id
//本次任务对应的日志id
private
Integer
logId
;
private
Integer
logId
;
//执行日志内容
//执行日志内容
private
String
logContent
;
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
,
FileSystemContext
fileSystemContext
)
{
this
.
cmd
=
cmd
;
this
.
cmd
=
cmd
;
this
.
env
=
env
;
this
.
env
=
env
;
this
.
workingDir
=
workingDir
;
this
.
workingDir
=
workingDir
;
this
.
processId
=
-
1
;
this
.
processId
=
-
1
;
this
.
startupLatch
=
new
CountDownLatch
(
1
);
this
.
startupLatch
=
new
CountDownLatch
(
1
);
this
.
completeLatch
=
new
CountDownLatch
(
1
);
this
.
completeLatch
=
new
CountDownLatch
(
1
);
this
.
logId
=
logId
;
this
.
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
String
executeAsUserBinary
,
final
String
workingDir
,
final
String
executeAsUserBinary
,
final
String
effectiveUser
,
Integer
logId
)
{
final
String
effectiveUser
,
Integer
logId
,
FileSystemContext
fileSystemContext
)
{
this
(
cmd
,
env
,
workingDir
,
logId
);
this
(
cmd
,
env
,
workingDir
,
logId
,
fileSystemContext
);
this
.
isExecuteAsUser
=
true
;
this
.
isExecuteAsUser
=
true
;
this
.
executeAsUserBinary
=
executeAsUserBinary
;
this
.
executeAsUserBinary
=
executeAsUserBinary
;
this
.
effectiveUser
=
effectiveUser
;
this
.
effectiveUser
=
effectiveUser
;
...
@@ -141,8 +147,11 @@ public class MythJobProcess implements Runnable{
...
@@ -141,8 +147,11 @@ public class MythJobProcess implements Runnable{
if
(
this
.
process
.
isAlive
()){
if
(
this
.
process
.
isAlive
()){
this
.
process
.
destroy
();
this
.
process
.
destroy
();
}
}
logContent
=
outputGobbler
.
getRecentLog
()
+
"\n"
+
errorGobbler
.
getRecentLog
();
String
logContent
=
outputGobbler
.
getRecentLog
()
+
"\n"
+
errorGobbler
.
getRecentLog
();
//TODO 将日志写到fastdfs上
//TODO 将日志写到fastdfs上
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>(
10
);
map
.
put
(
"filename"
,
logId
+
".log"
);
logFilePath
=
fileSystemContext
.
uploadFile
(
logContent
.
getBytes
(),
"log"
,
map
);
}
}
}
}
...
@@ -299,6 +308,6 @@ public class MythJobProcess implements Runnable{
...
@@ -299,6 +308,6 @@ public class MythJobProcess implements Runnable{
}
}
public
String
getLogContent
(){
public
String
getLogContent
(){
return
log
Content
;
return
log
FilePath
;
}
}
}
}
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