[Bug #6306][Worker] task log path generated error. (#6338)

This commit is contained in:
Kirs 2021-09-24 19:55:11 +08:00 committed by GitHub
parent 9be7f7931d
commit be158328fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import org.apache.dolphinscheduler.common.utils.CommonUtils;
import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.HadoopUtils; import org.apache.dolphinscheduler.common.utils.HadoopUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.LoggerUtils;
import org.apache.dolphinscheduler.common.utils.OSUtils; import org.apache.dolphinscheduler.common.utils.OSUtils;
import org.apache.dolphinscheduler.common.utils.RetryerUtils; import org.apache.dolphinscheduler.common.utils.RetryerUtils;
import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance;
@ -185,6 +186,12 @@ public class TaskExecuteThread implements Runnable, Delayed {
throw new PluginNotFoundException(String.format("%s Task Plugin Not Found,Please Check Config File.", taskExecutionContext.getTaskType())); throw new PluginNotFoundException(String.format("%s Task Plugin Not Found,Please Check Config File.", taskExecutionContext.getTaskType()));
} }
TaskRequest taskRequest = JSONUtils.parseObject(JSONUtils.toJsonString(taskExecutionContext), TaskRequest.class); TaskRequest taskRequest = JSONUtils.parseObject(JSONUtils.toJsonString(taskExecutionContext), TaskRequest.class);
String taskLogName = LoggerUtils.buildTaskId(LoggerUtils.TASK_LOGGER_INFO_PREFIX,
taskExecutionContext.getProcessDefineCode(),
taskExecutionContext.getProcessDefineVersion(),
taskExecutionContext.getProcessInstanceId(),
taskExecutionContext.getTaskInstanceId());
taskRequest.setTaskLogName(taskLogName);
task = taskChannel.createTask(taskRequest); task = taskChannel.createTask(taskRequest);
// task init // task init

View File

@ -178,7 +178,18 @@ public class TaskRequest {
*/ */
private int delayTime; private int delayTime;
/**
* Task Logger name should be like: Task-{processDefinitionId}-{processInstanceId}-{taskInstanceId}
*/
private String taskLogName;
public String getTaskLogName() {
return taskLogName;
}
public void setTaskLogName(String taskLogName) {
this.taskLogName = taskLogName;
}
/** /**
* resources full name and tenant code * resources full name and tenant code

View File

@ -41,7 +41,7 @@ public abstract class AbstractTaskExecutor extends AbstractTask {
*/ */
protected AbstractTaskExecutor(TaskRequest taskRequest) { protected AbstractTaskExecutor(TaskRequest taskRequest) {
super(taskRequest); super(taskRequest);
logger = LoggerFactory.getLogger(taskRequest.getLogPath()); logger = LoggerFactory.getLogger(taskRequest.getTaskLogName());
} }
/** /**