Commit c2f10e5a by guo_minglei@163.com

将日志运行线程改为有返回值的实现方式

parent 92551bc7
...@@ -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;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment