mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
[dev] suit front-end's globalization and add userContext for TaskContext
This commit is contained in:
parent
bd97cc8af5
commit
984274c2f4
@ -21,7 +21,7 @@ public class InstanceDetail implements OmsSerializable {
|
||||
// 任务整体结束时间(可能不存在)
|
||||
private Long finishedTime;
|
||||
// 任务状态(中文)
|
||||
private String status;
|
||||
private Integer status;
|
||||
// 任务执行结果(可能不存在)
|
||||
private String result;
|
||||
// TaskTracker地址
|
||||
|
@ -167,7 +167,7 @@ public class InstanceService {
|
||||
InstanceStatus instanceStatus = InstanceStatus.of(instanceInfoDO.getStatus());
|
||||
|
||||
InstanceDetail detail = new InstanceDetail();
|
||||
detail.setStatus(instanceStatus.getDes());
|
||||
detail.setStatus(instanceStatus.getV());
|
||||
|
||||
// 只要不是运行状态,只需要返回简要信息
|
||||
if (instanceStatus != RUNNING) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
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.server.persistence.core.model.InstanceInfoDO;
|
||||
import lombok.Data;
|
||||
@ -36,7 +35,6 @@ public class InstanceInfoVO {
|
||||
private int status;
|
||||
|
||||
/* ********** 不一致区域 ********** */
|
||||
private String statusStr;
|
||||
// 实际触发时间(需要格式化为人看得懂的时间)
|
||||
private String actualTriggerTime;
|
||||
// 结束时间(同理,需要格式化)
|
||||
@ -46,8 +44,6 @@ public class InstanceInfoVO {
|
||||
InstanceInfoVO instanceInfoVO = new InstanceInfoVO();
|
||||
BeanUtils.copyProperties(instanceInfoDo, instanceInfoVO);
|
||||
|
||||
// 状态转化为中文
|
||||
instanceInfoVO.setStatusStr(InstanceStatus.of(instanceInfoDo.getStatus()).getDes());
|
||||
// 额外设置任务名称,提高可读性
|
||||
instanceInfoVO.setJobName(jobName);
|
||||
|
||||
|
@ -2,7 +2,6 @@ package com.github.kfcfans.oms.server.web.response;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.server.persistence.core.model.WorkflowInstanceInfoDO;
|
||||
import lombok.Data;
|
||||
@ -27,7 +26,6 @@ public class WorkflowInstanceInfoVO {
|
||||
|
||||
// workflow 状态(WorkflowInstanceStatus)
|
||||
private Integer status;
|
||||
private String statusStr;
|
||||
|
||||
private PEWorkflowDAG pEWorkflowDAG;
|
||||
private String result;
|
||||
@ -42,7 +40,6 @@ public class WorkflowInstanceInfoVO {
|
||||
BeanUtils.copyProperties(wfInstanceDO, vo);
|
||||
|
||||
vo.setWorkflowName(workflowName);
|
||||
vo.setStatusStr(WorkflowInstanceStatus.of(wfInstanceDO.getStatus()).getDes());
|
||||
vo.setPEWorkflowDAG(JSONObject.parseObject(wfInstanceDO.getDag(), PEWorkflowDAG.class));
|
||||
|
||||
// JS精度丢失问题
|
||||
|
@ -35,7 +35,11 @@ public class OhMyConfig {
|
||||
* {@link com.github.kfcfans.oms.worker.core.processor.ProcessResult}#msg 的最大长度
|
||||
*/
|
||||
private int maxResultLength = 8096;
|
||||
|
||||
/**
|
||||
* 用户自定义上下文对象,该值会被透传到 TaskContext#userContext 属性
|
||||
* 使用场景:容器脚本Java处理器需要使用oms-worker宿主应用的Spring Bean,可在此处传入 ApplicationContext,在Processor中获取 bean
|
||||
*/
|
||||
private Object userContext;
|
||||
/**
|
||||
* 启动测试模式,true情况下,不再尝试连接 server 并验证appName
|
||||
* true -> 用于本地写单元测试调试; false -> 默认值,标准模式
|
||||
|
@ -65,6 +65,7 @@ public class ProcessorRunnable implements Runnable {
|
||||
if (task.getTaskContent() != null && task.getTaskContent().length > 0) {
|
||||
taskContext.setSubTask(SerializerUtils.deSerialized(task.getTaskContent()));
|
||||
}
|
||||
taskContext.setUserContext(OhMyWorker.getConfig().getUserContext());
|
||||
ThreadLocalStore.setTask(task);
|
||||
|
||||
reportStatus(TaskStatus.WORKER_PROCESSING, null);
|
||||
|
@ -57,6 +57,10 @@ public class TaskContext {
|
||||
* 在线日志记录
|
||||
*/
|
||||
private OmsLogger omsLogger;
|
||||
/**
|
||||
* 用户自定义上下文
|
||||
*/
|
||||
private Object userContext;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -64,7 +64,7 @@ public class CommonTaskTracker extends TaskTracker {
|
||||
InstanceDetail detail = new InstanceDetail();
|
||||
// 填充基础信息
|
||||
detail.setActualTriggerTime(createTime);
|
||||
detail.setStatus(InstanceStatus.RUNNING.getDes());
|
||||
detail.setStatus(InstanceStatus.RUNNING.getV());
|
||||
detail.setTaskTrackerAddress(OhMyWorker.getWorkerAddress());
|
||||
|
||||
// 填充详细信息
|
||||
|
@ -105,7 +105,7 @@ public class FrequentTaskTracker extends TaskTracker {
|
||||
InstanceDetail detail = new InstanceDetail();
|
||||
// 填充基础信息
|
||||
detail.setActualTriggerTime(createTime);
|
||||
detail.setStatus(InstanceStatus.RUNNING.getDes());
|
||||
detail.setStatus(InstanceStatus.RUNNING.getV());
|
||||
detail.setTaskTrackerAddress(OhMyWorker.getWorkerAddress());
|
||||
|
||||
List<InstanceDetail.SubInstanceDetail> history = Lists.newLinkedList();
|
||||
|
Loading…
x
Reference in New Issue
Block a user