Co-authored-by: honghuo.zw <honghuo.zw@alibaba-inc.com>
This commit is contained in:
zwZjut 2022-01-13 11:11:20 +08:00 committed by GitHub
parent 584ad1cd17
commit 889274562e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.server.master.runner.task;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.LoggerUtils;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.remote.command.TaskKillRequestCommand;
@ -33,11 +34,14 @@ import org.apache.dolphinscheduler.service.queue.TaskPriority;
import org.apache.dolphinscheduler.service.queue.TaskPriorityQueue;
import org.apache.dolphinscheduler.service.queue.TaskPriorityQueueImpl;
import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext;
import org.apache.dolphinscheduler.spi.task.TaskConstants;
import org.apache.commons.lang.StringUtils;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
@ -45,6 +49,8 @@ import org.springframework.beans.factory.annotation.Autowired;
*/
public class CommonTaskProcessor extends BaseTaskProcessor {
private static final Logger logger = LoggerFactory.getLogger(CommonTaskProcessor.class);
@Autowired
private TaskPriorityQueue taskUpdateQueue;
@ -62,6 +68,16 @@ public class CommonTaskProcessor extends BaseTaskProcessor {
return dispatchTask(taskInstance, processInstance);
}
@Override
public void setTaskExecutionLogger() {
threadLoggerInfoName = LoggerUtils.buildTaskId(LoggerUtils.TASK_LOGGER_INFO_PREFIX,
processInstance.getProcessDefinitionCode(),
processInstance.getProcessDefinitionVersion(),
taskInstance.getProcessInstanceId(),
taskInstance.getId());
Thread.currentThread().setName(String.format(TaskConstants.MASTER_COMMON_TASK_LOGGER_THREAD_NAME_FORMAT, threadLoggerInfoName));
}
@Override
public ExecutionStatus taskState() {
return this.taskInstance.getState();

View File

@ -133,6 +133,9 @@ public class TaskConstants {
*/
public static final String TASK_LOGGER_THREAD_NAME_FORMAT = TASK_LOGGER_THREAD_NAME + "-%s";
public static final String MASTER_COMMON_TASK_LOGGER_THREAD_NAME = "CommonTask";
public static final String MASTER_COMMON_TASK_LOGGER_THREAD_NAME_FORMAT = MASTER_COMMON_TASK_LOGGER_THREAD_NAME + "-%s";
/**
* task log logger name
*/