mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
fix: instanceInfo cannot display details on non-scheduled server nodes
This commit is contained in:
parent
f3dd56bf54
commit
debc2e0abb
@ -260,10 +260,12 @@ public class InstanceService {
|
|||||||
/**
|
/**
|
||||||
* 获取任务实例的详细运行详细
|
* 获取任务实例的详细运行详细
|
||||||
*
|
*
|
||||||
|
* @param appId 用于远程 server 路由,勿删!
|
||||||
* @param instanceId 任务实例ID
|
* @param instanceId 任务实例ID
|
||||||
* @return 详细运行状态
|
* @return 详细运行状态
|
||||||
*/
|
*/
|
||||||
public InstanceDetail getInstanceDetail(Long instanceId) {
|
@DesignateServer
|
||||||
|
public InstanceDetail getInstanceDetail(Long appId, Long instanceId) {
|
||||||
|
|
||||||
InstanceInfoDO instanceInfoDO = fetchInstanceInfo(instanceId);
|
InstanceInfoDO instanceInfoDO = fetchInstanceInfo(instanceId);
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import tech.powerjob.server.common.utils.OmsFileUtils;
|
|||||||
import tech.powerjob.server.persistence.PageResult;
|
import tech.powerjob.server.persistence.PageResult;
|
||||||
import tech.powerjob.server.persistence.StringPage;
|
import tech.powerjob.server.persistence.StringPage;
|
||||||
import tech.powerjob.server.persistence.remote.model.InstanceInfoDO;
|
import tech.powerjob.server.persistence.remote.model.InstanceInfoDO;
|
||||||
import tech.powerjob.server.persistence.remote.repository.AppInfoRepository;
|
|
||||||
import tech.powerjob.server.persistence.remote.repository.InstanceInfoRepository;
|
import tech.powerjob.server.persistence.remote.repository.InstanceInfoRepository;
|
||||||
import tech.powerjob.server.core.service.CacheService;
|
import tech.powerjob.server.core.service.CacheService;
|
||||||
import tech.powerjob.server.core.instance.InstanceLogService;
|
import tech.powerjob.server.core.instance.InstanceLogService;
|
||||||
@ -69,8 +68,14 @@ public class InstanceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/detail")
|
@GetMapping("/detail")
|
||||||
public ResultDTO<InstanceDetailVO> getInstanceDetail(Long instanceId) {
|
public ResultDTO<InstanceDetailVO> getInstanceDetail(Long appId, Long instanceId) {
|
||||||
return ResultDTO.success(InstanceDetailVO.from(instanceService.getInstanceDetail(instanceId)));
|
|
||||||
|
// 兼容老版本前端不存在 appId 的场景
|
||||||
|
if (appId == null) {
|
||||||
|
appId = instanceService.getInstanceInfo(instanceId).getAppId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultDTO.success(InstanceDetailVO.from(instanceService.getInstanceDetail(appId, instanceId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/log")
|
@GetMapping("/log")
|
||||||
|
@ -2,6 +2,7 @@ package tech.powerjob.samples.processors;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.*;
|
||||||
import tech.powerjob.common.serialize.JsonUtils;
|
import tech.powerjob.common.serialize.JsonUtils;
|
||||||
import tech.powerjob.worker.core.processor.ProcessResult;
|
import tech.powerjob.worker.core.processor.ProcessResult;
|
||||||
import tech.powerjob.worker.core.processor.TaskContext;
|
import tech.powerjob.worker.core.processor.TaskContext;
|
||||||
@ -9,10 +10,6 @@ import tech.powerjob.worker.core.processor.TaskResult;
|
|||||||
import tech.powerjob.worker.core.processor.sdk.MapReduceProcessor;
|
import tech.powerjob.worker.core.processor.sdk.MapReduceProcessor;
|
||||||
import tech.powerjob.worker.log.OmsLogger;
|
import tech.powerjob.worker.log.OmsLogger;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.ToString;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -85,10 +82,18 @@ public class MapReduceProcessorDemo implements MapReduceProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@Setter
|
||||||
@ToString
|
@ToString
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public static class TestSubTask {
|
public static class TestSubTask {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注意:代表子任务参数的类:一定要有无参构造方法!一定要有无参构造方法!一定要有无参构造方法!
|
||||||
|
* 最好把 GET / SET 方法也加上,减少序列化问题的概率
|
||||||
|
*/
|
||||||
|
public TestSubTask() {
|
||||||
|
}
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private int age;
|
private int age;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user