[dev] suit front-end's globalization and add userContext for TaskContext

This commit is contained in:
tjq 2020-06-11 20:10:09 +08:00
parent bd97cc8af5
commit 984274c2f4
9 changed files with 14 additions and 12 deletions

View File

@ -21,7 +21,7 @@ public class InstanceDetail implements OmsSerializable {
// 任务整体结束时间可能不存在 // 任务整体结束时间可能不存在
private Long finishedTime; private Long finishedTime;
// 任务状态中文 // 任务状态中文
private String status; private Integer status;
// 任务执行结果可能不存在 // 任务执行结果可能不存在
private String result; private String result;
// TaskTracker地址 // TaskTracker地址

View File

@ -167,7 +167,7 @@ public class InstanceService {
InstanceStatus instanceStatus = InstanceStatus.of(instanceInfoDO.getStatus()); InstanceStatus instanceStatus = InstanceStatus.of(instanceInfoDO.getStatus());
InstanceDetail detail = new InstanceDetail(); InstanceDetail detail = new InstanceDetail();
detail.setStatus(instanceStatus.getDes()); detail.setStatus(instanceStatus.getV());
// 只要不是运行状态只需要返回简要信息 // 只要不是运行状态只需要返回简要信息
if (instanceStatus != RUNNING) { if (instanceStatus != RUNNING) {

View File

@ -1,6 +1,5 @@
package com.github.kfcfans.oms.server.web.response; package com.github.kfcfans.oms.server.web.response;
import com.github.kfcfans.oms.common.InstanceStatus;
import com.github.kfcfans.oms.common.OmsConstant; import com.github.kfcfans.oms.common.OmsConstant;
import com.github.kfcfans.oms.server.persistence.core.model.InstanceInfoDO; import com.github.kfcfans.oms.server.persistence.core.model.InstanceInfoDO;
import lombok.Data; import lombok.Data;
@ -36,7 +35,6 @@ public class InstanceInfoVO {
private int status; private int status;
/* ********** 不一致区域 ********** */ /* ********** 不一致区域 ********** */
private String statusStr;
// 实际触发时间需要格式化为人看得懂的时间 // 实际触发时间需要格式化为人看得懂的时间
private String actualTriggerTime; private String actualTriggerTime;
// 结束时间同理需要格式化 // 结束时间同理需要格式化
@ -46,8 +44,6 @@ public class InstanceInfoVO {
InstanceInfoVO instanceInfoVO = new InstanceInfoVO(); InstanceInfoVO instanceInfoVO = new InstanceInfoVO();
BeanUtils.copyProperties(instanceInfoDo, instanceInfoVO); BeanUtils.copyProperties(instanceInfoDo, instanceInfoVO);
// 状态转化为中文
instanceInfoVO.setStatusStr(InstanceStatus.of(instanceInfoDo.getStatus()).getDes());
// 额外设置任务名称提高可读性 // 额外设置任务名称提高可读性
instanceInfoVO.setJobName(jobName); instanceInfoVO.setJobName(jobName);

View File

@ -2,7 +2,6 @@ package com.github.kfcfans.oms.server.web.response;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.kfcfans.oms.common.OmsConstant; import com.github.kfcfans.oms.common.OmsConstant;
import com.github.kfcfans.oms.common.WorkflowInstanceStatus;
import com.github.kfcfans.oms.common.model.PEWorkflowDAG; import com.github.kfcfans.oms.common.model.PEWorkflowDAG;
import com.github.kfcfans.oms.server.persistence.core.model.WorkflowInstanceInfoDO; import com.github.kfcfans.oms.server.persistence.core.model.WorkflowInstanceInfoDO;
import lombok.Data; import lombok.Data;
@ -27,7 +26,6 @@ public class WorkflowInstanceInfoVO {
// workflow 状态WorkflowInstanceStatus // workflow 状态WorkflowInstanceStatus
private Integer status; private Integer status;
private String statusStr;
private PEWorkflowDAG pEWorkflowDAG; private PEWorkflowDAG pEWorkflowDAG;
private String result; private String result;
@ -42,7 +40,6 @@ public class WorkflowInstanceInfoVO {
BeanUtils.copyProperties(wfInstanceDO, vo); BeanUtils.copyProperties(wfInstanceDO, vo);
vo.setWorkflowName(workflowName); vo.setWorkflowName(workflowName);
vo.setStatusStr(WorkflowInstanceStatus.of(wfInstanceDO.getStatus()).getDes());
vo.setPEWorkflowDAG(JSONObject.parseObject(wfInstanceDO.getDag(), PEWorkflowDAG.class)); vo.setPEWorkflowDAG(JSONObject.parseObject(wfInstanceDO.getDag(), PEWorkflowDAG.class));
// JS精度丢失问题 // JS精度丢失问题

View File

@ -35,7 +35,11 @@ public class OhMyConfig {
* {@link com.github.kfcfans.oms.worker.core.processor.ProcessResult}#msg 的最大长度 * {@link com.github.kfcfans.oms.worker.core.processor.ProcessResult}#msg 的最大长度
*/ */
private int maxResultLength = 8096; private int maxResultLength = 8096;
/**
* 用户自定义上下文对象该值会被透传到 TaskContext#userContext 属性
* 使用场景容器脚本Java处理器需要使用oms-worker宿主应用的Spring Bean可在此处传入 ApplicationContext在Processor中获取 bean
*/
private Object userContext;
/** /**
* 启动测试模式true情况下不再尝试连接 server 并验证appName * 启动测试模式true情况下不再尝试连接 server 并验证appName
* true -> 用于本地写单元测试调试 false -> 默认值标准模式 * true -> 用于本地写单元测试调试 false -> 默认值标准模式

View File

@ -65,6 +65,7 @@ public class ProcessorRunnable implements Runnable {
if (task.getTaskContent() != null && task.getTaskContent().length > 0) { if (task.getTaskContent() != null && task.getTaskContent().length > 0) {
taskContext.setSubTask(SerializerUtils.deSerialized(task.getTaskContent())); taskContext.setSubTask(SerializerUtils.deSerialized(task.getTaskContent()));
} }
taskContext.setUserContext(OhMyWorker.getConfig().getUserContext());
ThreadLocalStore.setTask(task); ThreadLocalStore.setTask(task);
reportStatus(TaskStatus.WORKER_PROCESSING, null); reportStatus(TaskStatus.WORKER_PROCESSING, null);

View File

@ -57,6 +57,10 @@ public class TaskContext {
* 在线日志记录 * 在线日志记录
*/ */
private OmsLogger omsLogger; private OmsLogger omsLogger;
/**
* 用户自定义上下文
*/
private Object userContext;
/** /**

View File

@ -64,7 +64,7 @@ public class CommonTaskTracker extends TaskTracker {
InstanceDetail detail = new InstanceDetail(); InstanceDetail detail = new InstanceDetail();
// 填充基础信息 // 填充基础信息
detail.setActualTriggerTime(createTime); detail.setActualTriggerTime(createTime);
detail.setStatus(InstanceStatus.RUNNING.getDes()); detail.setStatus(InstanceStatus.RUNNING.getV());
detail.setTaskTrackerAddress(OhMyWorker.getWorkerAddress()); detail.setTaskTrackerAddress(OhMyWorker.getWorkerAddress());
// 填充详细信息 // 填充详细信息

View File

@ -105,7 +105,7 @@ public class FrequentTaskTracker extends TaskTracker {
InstanceDetail detail = new InstanceDetail(); InstanceDetail detail = new InstanceDetail();
// 填充基础信息 // 填充基础信息
detail.setActualTriggerTime(createTime); detail.setActualTriggerTime(createTime);
detail.setStatus(InstanceStatus.RUNNING.getDes()); detail.setStatus(InstanceStatus.RUNNING.getV());
detail.setTaskTrackerAddress(OhMyWorker.getWorkerAddress()); detail.setTaskTrackerAddress(OhMyWorker.getWorkerAddress());
List<InstanceDetail.SubInstanceDetail> history = Lists.newLinkedList(); List<InstanceDetail.SubInstanceDetail> history = Lists.newLinkedList();