Browse Source

solve too many files, close logClientService (#3971)

pull/3/MERGE
dailidong 4 years ago committed by GitHub
parent
commit
ccc8ba1167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 46
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

46
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

@ -307,31 +307,37 @@ public class ProcessService {
*/
public void removeTaskLogFile(Integer processInstanceId){
LogClientService logClient = new LogClientService();
LogClientService logClient = null;
List<TaskInstance> taskInstanceList = findValidTaskListByProcessId(processInstanceId);
try {
logClient = new LogClientService();
List<TaskInstance> taskInstanceList = findValidTaskListByProcessId(processInstanceId);
if (CollectionUtils.isEmpty(taskInstanceList)){
return;
}
for (TaskInstance taskInstance : taskInstanceList){
String taskLogPath = taskInstance.getLogPath();
if (StringUtils.isEmpty(taskInstance.getHost())){
continue;
}
int port = Constants.RPC_PORT;
String ip = "";
try {
ip = Host.of(taskInstance.getHost()).getIp();
}catch (Exception e){
// compatible old version
ip = taskInstance.getHost();
if (CollectionUtils.isEmpty(taskInstanceList)) {
return;
}
for (TaskInstance taskInstance : taskInstanceList) {
String taskLogPath = taskInstance.getLogPath();
if (StringUtils.isEmpty(taskInstance.getHost())) {
continue;
}
int port = Constants.RPC_PORT;
String ip = "";
try {
ip = Host.of(taskInstance.getHost()).getIp();
} catch (Exception e) {
// compatible old version
ip = taskInstance.getHost();
}
// remove task log from loggerserver
logClient.removeTaskLog(ip,port,taskLogPath);
// remove task log from loggerserver
logClient.removeTaskLog(ip, port, taskLogPath);
}
}finally {
if (logClient != null) {
logClient.close();
}
}
}

Loading…
Cancel
Save