Skip to content

Commit

Permalink
solve too many files, close logClientService (#3971)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzollo authored Oct 22, 2020
1 parent 48261c5 commit ccc8ba1
Showing 1 changed file with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,31 +307,37 @@ public int deleteAllSubWorkProcessByParentId(int processInstanceId){
*/
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();
}
}
}

Expand Down

0 comments on commit ccc8ba1

Please sign in to comment.