mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
[dev] add version info in WorkerHeartbeat
This commit is contained in:
parent
dcd96fbe84
commit
03add72684
@ -27,6 +27,10 @@ public class WorkerHeartbeat implements OmsSerializable {
|
||||
private long heartbeatTime;
|
||||
// 当前加载的容器(容器名称 -> 容器版本)
|
||||
private List<DeployedContainerInfo> containerInfos;
|
||||
// worker 版本信息
|
||||
private String version;
|
||||
// 扩展字段
|
||||
private String extra;
|
||||
|
||||
private SystemMetrics systemMetrics;
|
||||
}
|
||||
|
@ -1,11 +1,7 @@
|
||||
package com.github.kfcfans.powerjob.server.web.controller;
|
||||
|
||||
import com.github.kfcfans.powerjob.common.ExecuteType;
|
||||
import com.github.kfcfans.powerjob.common.ProcessorType;
|
||||
import com.github.kfcfans.powerjob.common.TimeExpressionType;
|
||||
import com.github.kfcfans.powerjob.common.request.http.SaveJobInfoRequest;
|
||||
import com.github.kfcfans.powerjob.common.response.ResultDTO;
|
||||
import com.github.kfcfans.powerjob.server.common.SJ;
|
||||
import com.github.kfcfans.powerjob.server.common.constans.SwitchableStatus;
|
||||
import com.github.kfcfans.powerjob.server.persistence.PageResult;
|
||||
import com.github.kfcfans.powerjob.server.persistence.core.model.JobInfoDO;
|
||||
@ -15,7 +11,6 @@ import com.github.kfcfans.powerjob.server.web.request.QueryJobInfoRequest;
|
||||
import com.github.kfcfans.powerjob.server.web.response.JobInfoVO;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@ -90,7 +85,7 @@ public class JobController {
|
||||
if (jobInfoOpt.isPresent()) {
|
||||
result.setTotalItems(1);
|
||||
result.setTotalPages(1);
|
||||
result.setData(Lists.newArrayList(convert(jobInfoOpt.get())));
|
||||
result.setData(Lists.newArrayList(JobInfoVO.from(jobInfoOpt.get())));
|
||||
}else {
|
||||
result.setTotalPages(0);
|
||||
result.setTotalItems(0);
|
||||
@ -108,34 +103,11 @@ public class JobController {
|
||||
|
||||
|
||||
private static PageResult<JobInfoVO> convertPage(Page<JobInfoDO> jobInfoPage) {
|
||||
List<JobInfoVO> jobInfoVOList = jobInfoPage.getContent().stream().map(JobController::convert).collect(Collectors.toList());
|
||||
List<JobInfoVO> jobInfoVOList = jobInfoPage.getContent().stream().map(JobInfoVO::from).collect(Collectors.toList());
|
||||
|
||||
PageResult<JobInfoVO> pageResult = new PageResult<>(jobInfoPage);
|
||||
pageResult.setData(jobInfoVOList);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
private static JobInfoVO convert(JobInfoDO jobInfoDO) {
|
||||
JobInfoVO jobInfoVO = new JobInfoVO();
|
||||
BeanUtils.copyProperties(jobInfoDO, jobInfoVO);
|
||||
|
||||
TimeExpressionType timeExpressionType = TimeExpressionType.of(jobInfoDO.getTimeExpressionType());
|
||||
ExecuteType executeType = ExecuteType.of(jobInfoDO.getExecuteType());
|
||||
ProcessorType processorType = ProcessorType.of(jobInfoDO.getProcessorType());
|
||||
|
||||
jobInfoVO.setTimeExpressionType(timeExpressionType.name());
|
||||
jobInfoVO.setExecuteType(executeType.name());
|
||||
jobInfoVO.setProcessorType(processorType.name());
|
||||
jobInfoVO.setEnable(jobInfoDO.getStatus() == SwitchableStatus.ENABLE.getV());
|
||||
|
||||
if (!StringUtils.isEmpty(jobInfoDO.getNotifyUserIds())) {
|
||||
jobInfoVO.setNotifyUserIds(SJ.commaSplitter.splitToList(jobInfoDO.getNotifyUserIds()));
|
||||
}else {
|
||||
jobInfoVO.setNotifyUserIds(Lists.newLinkedList());
|
||||
}
|
||||
|
||||
return jobInfoVO;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||
* 任务实例的运行详细信息(对外展示对象)
|
||||
* 注意:日期的格式化全部需要在 server 完成,不能在浏览器完成,否则会有时区问题(当 server 与 browser 时区不一致时显示会有问题)
|
||||
*
|
||||
* @author 朱八
|
||||
* @author tjq
|
||||
* @since 2020/7/18
|
||||
*/
|
||||
@Data
|
||||
|
@ -1,6 +1,16 @@
|
||||
package com.github.kfcfans.powerjob.server.web.response;
|
||||
|
||||
import com.github.kfcfans.powerjob.common.ExecuteType;
|
||||
import com.github.kfcfans.powerjob.common.ProcessorType;
|
||||
import com.github.kfcfans.powerjob.common.TimeExpressionType;
|
||||
import com.github.kfcfans.powerjob.common.utils.CommonUtils;
|
||||
import com.github.kfcfans.powerjob.server.common.SJ;
|
||||
import com.github.kfcfans.powerjob.server.common.constans.SwitchableStatus;
|
||||
import com.github.kfcfans.powerjob.server.persistence.core.model.JobInfoDO;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -56,6 +66,8 @@ public class JobInfoVO {
|
||||
private boolean enable;
|
||||
// 下一次调度时间
|
||||
private Long nextTriggerTime;
|
||||
// 下一次调度时间(文字版)
|
||||
private String nextTriggerTimeStr;
|
||||
|
||||
/* ************************** 繁忙机器配置 ************************** */
|
||||
// 最低CPU核心数量,0代表不限
|
||||
@ -76,4 +88,27 @@ public class JobInfoVO {
|
||||
|
||||
// 报警用户ID列表
|
||||
private List<String> notifyUserIds;
|
||||
|
||||
public static JobInfoVO from(JobInfoDO jobInfoDO) {
|
||||
JobInfoVO jobInfoVO = new JobInfoVO();
|
||||
BeanUtils.copyProperties(jobInfoDO, jobInfoVO);
|
||||
|
||||
TimeExpressionType timeExpressionType = TimeExpressionType.of(jobInfoDO.getTimeExpressionType());
|
||||
ExecuteType executeType = ExecuteType.of(jobInfoDO.getExecuteType());
|
||||
ProcessorType processorType = ProcessorType.of(jobInfoDO.getProcessorType());
|
||||
|
||||
jobInfoVO.setTimeExpressionType(timeExpressionType.name());
|
||||
jobInfoVO.setExecuteType(executeType.name());
|
||||
jobInfoVO.setProcessorType(processorType.name());
|
||||
jobInfoVO.setEnable(jobInfoDO.getStatus() == SwitchableStatus.ENABLE.getV());
|
||||
|
||||
if (!StringUtils.isEmpty(jobInfoDO.getNotifyUserIds())) {
|
||||
jobInfoVO.setNotifyUserIds(SJ.commaSplitter.splitToList(jobInfoDO.getNotifyUserIds()));
|
||||
}else {
|
||||
jobInfoVO.setNotifyUserIds(Lists.newLinkedList());
|
||||
}
|
||||
jobInfoVO.setNextTriggerTimeStr(CommonUtils.formatTime(jobInfoDO.getNextTriggerTime()));
|
||||
|
||||
return jobInfoVO;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.github.kfcfans.powerjob.common.RemoteConstant;
|
||||
import com.github.kfcfans.powerjob.common.model.SystemMetrics;
|
||||
import com.github.kfcfans.powerjob.common.request.WorkerHeartbeat;
|
||||
import com.github.kfcfans.powerjob.worker.OhMyWorker;
|
||||
import com.github.kfcfans.powerjob.worker.common.OmsWorkerVersion;
|
||||
import com.github.kfcfans.powerjob.worker.common.utils.AkkaUtils;
|
||||
import com.github.kfcfans.powerjob.worker.common.utils.SystemInfoUtils;
|
||||
import com.github.kfcfans.powerjob.worker.container.OmsContainerFactory;
|
||||
@ -39,6 +40,7 @@ public class WorkerHealthReporter implements Runnable {
|
||||
heartbeat.setAppName(OhMyWorker.getConfig().getAppName());
|
||||
heartbeat.setAppId(OhMyWorker.getAppId());
|
||||
heartbeat.setHeartbeatTime(System.currentTimeMillis());
|
||||
heartbeat.setVersion(OmsWorkerVersion.getVersion());
|
||||
|
||||
// 获取当前加载的容器列表
|
||||
heartbeat.setContainerInfos(OmsContainerFactory.getDeployedContainerInfos());
|
||||
|
Loading…
x
Reference in New Issue
Block a user