Browse Source

Merge remote-tracking branch 'remotes/upstream/refactor-architecture' into dev

pull/2/head
qiaozhanwei 5 years ago
parent
commit
822b9b4e7a
  1. 19
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/LoggerService.java
  2. 13
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java
  3. 6
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogClientService.java

19
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/LoggerService.java

@ -64,11 +64,17 @@ public class LoggerService {
Result result = new Result(Status.SUCCESS.getCode(), Status.SUCCESS.getMsg()); Result result = new Result(Status.SUCCESS.getCode(), Status.SUCCESS.getMsg());
logger.info("log host : {} , logPath : {} , logServer port : {}",host,taskInstance.getLogPath(),Constants.RPC_PORT); logger.info("log host : {} , logPath : {} , logServer port : {}",host,taskInstance.getLogPath(),Constants.RPC_PORT);
LogClientService logClient = null;
LogClientService logClient = new LogClientService(host, Constants.RPC_PORT); try {
logClient = new LogClientService(host, Constants.RPC_PORT);
String log = logClient.rollViewLog(taskInstance.getLogPath(),skipLineNum,limit); String log = logClient.rollViewLog(taskInstance.getLogPath(),skipLineNum,limit);
result.setData(log); result.setData(log);
logger.info(log); logger.info(log);
} finally {
if(logClient != null){
logClient.close();
}
}
return result; return result;
} }
@ -86,7 +92,14 @@ public class LoggerService {
} }
String host = taskInstance.getHost(); String host = taskInstance.getHost();
LogClientService logClient = new LogClientService(host, Constants.RPC_PORT); LogClientService logClient = null;
try {
logClient = new LogClientService(host, Constants.RPC_PORT);
return logClient.getLogBytes(taskInstance.getLogPath()); return logClient.getLogBytes(taskInstance.getLogPath());
} finally {
if(logClient != null){
logClient.close();
}
}
} }
} }

13
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java

@ -375,9 +375,16 @@ public class ProcessUtils {
public static void killYarnJob(TaskInstance taskInstance) { public static void killYarnJob(TaskInstance taskInstance) {
try { try {
Thread.sleep(Constants.SLEEP_TIME_MILLIS); Thread.sleep(Constants.SLEEP_TIME_MILLIS);
LogClientService logClient = new LogClientService(taskInstance.getHost(), Constants.RPC_PORT); LogClientService logClient = null;
String log = null;
String log = logClient.viewLog(taskInstance.getLogPath()); try {
logClient = new LogClientService(taskInstance.getHost(), Constants.RPC_PORT);
log = logClient.viewLog(taskInstance.getLogPath());
} finally {
if(logClient != null){
logClient.close();
}
}
if (StringUtils.isNotEmpty(log)) { if (StringUtils.isNotEmpty(log)) {
List<String> appIds = LoggerUtils.getAppIds(log, logger); List<String> appIds = LoggerUtils.getAppIds(log, logger);
String workerDir = taskInstance.getExecutePath(); String workerDir = taskInstance.getExecutePath();

6
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogClientService.java

@ -64,11 +64,11 @@ public class LogClientService implements NettyRequestProcessor {
} }
/** /**
* shutdown * close
*/ */
public void shutdown() { public void close() {
this.client.close(); this.client.close();
logger.info("logger client shutdown"); logger.info("logger client closed");
} }
/** /**

Loading…
Cancel
Save