From b1b8e1de95c274285291b1853dda9f81e142cb51 Mon Sep 17 00:00:00 2001 From: jjn Date: Fri, 8 Jan 2021 22:20:35 +0800 Subject: [PATCH] docs: Add translations for models in PowerJob-common. --- README.md | 2 +- .../powerjob/common/model/GitRepoInfo.java | 2 +- .../powerjob/common/model/InstanceDetail.java | 36 +++++- .../powerjob/common/model/PEWorkflowDAG.java | 22 +++- .../powerjob/common/model/SystemMetrics.java | 82 ++++++++----- .../request/http/SaveJobInfoRequest.java | 110 +++++++++++++----- 6 files changed, 189 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index f0115858..7b8a13ee 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Application password: 123 | Distributed strategy | Unsupported | Static sharding | MapReduce dynamic sharding | **MapReduce dynamic sharding** | | Online task management | Unsupported | Supported | Supported | **Supported** | | Online logging | Unsupported | Supported | Unsupported | **Supported** | -| Scheduling methods and performance | Based on database lock, there is a performance bottleneck | Based on database lock, there is a performance bottleneck | Unknown | **Lock-free design, powerful performance without upper limit** | +| Scheduling methods and performance | Based on database lock, there is a performance bottleneck | Based on database lock, there is a performance bottleneck | Unknown | **Lock-free design, high performance without upper limit** | | Alarm monitoring | Unsupported | Email | SMS | **Email, WebHook, DingTalk. An interface is provided for customization.** | | System dependence | Any relational database (MySQL, Oracle ...) supported by JDBC | MySQL | RMB (Public Beta version for free, hey, helping to promote) | **Any relational database (MySQL, Oracle ...) supported by Spring Data Jpa** | | workflow | Unsupported | Unsupported | Supported | **Supported** | diff --git a/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/GitRepoInfo.java b/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/GitRepoInfo.java index 75a8c964..0aaa5013 100644 --- a/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/GitRepoInfo.java +++ b/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/GitRepoInfo.java @@ -3,7 +3,7 @@ package com.github.kfcfans.powerjob.common.model; import lombok.Data; /** - * The class for Git Repository. + * The class for Git Repository info. * * @author tjq * @since 2020/5/17 diff --git a/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/InstanceDetail.java b/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/InstanceDetail.java index e690c3ab..90f12886 100644 --- a/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/InstanceDetail.java +++ b/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/InstanceDetail.java @@ -16,30 +16,60 @@ import java.util.List; @NoArgsConstructor public class InstanceDetail implements OmsSerializable { - // 任务预计执行时间 + /** + * Expected trigger time. + */ private Long expectedTriggerTime; - // 任务整体开始时间 + /** + * Actual trigger time of an instance. + */ private Long actualTriggerTime; // 任务整体结束时间(可能不存在) + /** + * Finish time of an instance, which may be null. + */ private Long finishedTime; - // 任务状态 + /** + * Status of the task instance. + */ private Integer status; // 任务执行结果(可能不存在) + /** + * Execution result, which may be null. + */ private String result; // TaskTracker地址 + /** + * Task tracker address. + */ private String taskTrackerAddress; // 启动参数 + /** + * Param string that is passed to an instance when it is initialized. + */ private String instanceParams; // MR或BD任务专用 + /** + * Task detail, used by MapReduce or Broadcast tasks. + */ private TaskDetail taskDetail; // 秒级任务专用 + /** + * + */ private List subInstanceDetails; // 重试次数 + /** + * + */ private Long runningTimes; // 扩展字段,中间件升级不易,最好不要再改 common 包了...否则 server worker 版本不兼容 + /** + * Extend + */ private String extra; // 秒级任务的 extra -> List diff --git a/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/PEWorkflowDAG.java b/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/PEWorkflowDAG.java index 3fe258ca..f49bcacc 100644 --- a/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/PEWorkflowDAG.java +++ b/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/PEWorkflowDAG.java @@ -13,8 +13,7 @@ import java.io.Serializable; import java.util.List; /** - * Point & Edge DAG 表示法 - * 点 + 线,易于表达和传播 + * Points & edges for DAG, making it easier to describe or transfer. * * @author tjq * @since 2020/5/26 @@ -23,11 +22,18 @@ import java.util.List; @NoArgsConstructor public class PEWorkflowDAG implements Serializable { - // DAG 图(点线表示法) + /** + * Nodes of DAG diagram. + */ private List nodes; + /** + * Edges of DAG diagram. + */ private List edges; - // 点 + /** + * Point. + */ @Data @NoArgsConstructor @AllArgsConstructor @@ -35,7 +41,9 @@ public class PEWorkflowDAG implements Serializable { private Long jobId; private String jobName; - // 运行时参数,图定义不需要 + /** + * Instance running param, which is not required by DAG. + */ @JsonSerialize(using= ToStringSerializer.class) private Long instanceId; private Integer status; @@ -47,7 +55,9 @@ public class PEWorkflowDAG implements Serializable { } } - // 边 jobId -> jobId + /** + * Edge formed by two job ids. + */ @Data @NoArgsConstructor @AllArgsConstructor diff --git a/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/SystemMetrics.java b/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/SystemMetrics.java index 1d5945ec..7d053bbe 100644 --- a/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/SystemMetrics.java +++ b/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/model/SystemMetrics.java @@ -4,7 +4,7 @@ import com.github.kfcfans.powerjob.common.OmsSerializable; import lombok.Data; /** - * 系统指标 + * Class for system metrics . * * @author tjq * @since 2020/3/25 @@ -12,49 +12,77 @@ import lombok.Data; @Data public class SystemMetrics implements OmsSerializable, Comparable { - // CPU核心数量 + /** + * CPU processor num. + */ private int cpuProcessors; - // CPU负载(负载 和 使用率 是两个完全不同的概念,Java 无法获取 CPU 使用率,只能获取负载) + /** + * Percent of CPU load. + */ private double cpuLoad; - // 内存(单位 GB) + /** + * Memory that is used by JVM, in GB. + */ private double jvmUsedMemory; + /** + * Max memory that JVM can use, in GB. + */ private double jvmMaxMemory; - // 内存占用(0.X,非百分比) + /** + * Ratio of memory that JVM uses to total memory, 0.X, + * the value is between 0 and 1. + */ private double jvmMemoryUsage; - // 磁盘(单位 GB) + /** + * Total used disk space, in GB. + */ private double diskUsed; + /** + * Total disk space, in GB. + */ private double diskTotal; - // 磁盘占用(0.X,非百分比) + /** + * Used disk ratio. + */ private double diskUsage; - // 缓存分数 + /** + * Score of cache. + */ private int score; + /** + * Override compareTo. + * + * @param that the metrics that is to be compared with current. + * @return {@code int} + */ @Override public int compareTo(SystemMetrics that) { - // 降序排列 + // Sort by metrics in descending order. return that.calculateScore() - this.calculateScore(); } /** - * 计算得分情况,内存 & CPU (磁盘不参与计算) - * @return 得分情况 + * Calculate score, based on CPU and memory info. + * + * @return score */ public int calculateScore() { - if (score > 0) { - return score; - } + if (score > 0) { + return score; + } - // 对于 TaskTracker 来说,内存是任务顺利完成的关键,因此内存 2 块钱 1GB - double memScore = (jvmMaxMemory - jvmUsedMemory) * 2; - // CPU 剩余负载,1 块钱 1 斤 - double cpuScore = cpuProcessors - cpuLoad; - // Indian Windows 无法获取 CpuLoad,为 -1,固定为 1 - if (cpuScore > cpuProcessors) { - cpuScore = 1; + // Memory is vital to TaskTracker, so we set the multiplier factor as 2. + double memScore = (jvmMaxMemory - jvmUsedMemory) * 2; + // Calculate the remaining load of CPU. Multiplier is set as 1. + double cpuScore = cpuProcessors - cpuLoad; + // Windows can not fetch CPU load, set cpuScore as 1. + if (cpuScore > cpuProcessors) { + cpuScore = 1; } score = (int) (memScore + cpuScore); @@ -62,11 +90,12 @@ public class SystemMetrics implements OmsSerializable, Comparable } /** - * 该机器是否可用 - * @param minCPUCores 判断标准之最低可用CPU核心数量 + * Judge if the machine is available. + * + * @param minCPUCores Minimum available CPU cores. * @param minMemorySpace 判断标准之最低可用内存 - * @param minDiskSpace 判断标准之最低可用磁盘空间 - * @return 是否可用 + * @param minDiskSpace Minimum disk space 判断标准之最低可用磁盘空间 + * @return {@code boolean} whether the machine is available. */ public boolean available(double minCPUCores, double minMemorySpace, double minDiskSpace) { @@ -77,7 +106,8 @@ public class SystemMetrics implements OmsSerializable, Comparable return false; } - // cpuLoad 为负数代表无法获取,不判断。等于 0 为最理想情况,CPU 空载,不需要判断 + // Negative number means being unable to fetch CPU info, return true. + // 0 indicates the CPU is free, which is the optimal condition. if (cpuLoad <= 0 || minCPUCores <= 0) { return true; } diff --git a/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/request/http/SaveJobInfoRequest.java b/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/request/http/SaveJobInfoRequest.java index ae7a24e2..2bc8435f 100644 --- a/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/request/http/SaveJobInfoRequest.java +++ b/powerjob-common/src/main/java/com/github/kfcfans/powerjob/common/request/http/SaveJobInfoRequest.java @@ -9,7 +9,7 @@ import lombok.Data; import java.util.List; /** - * 创建/修改 JobInfo 请求 + * Save or modify {@link com.github.kfcfans.powerjob.common.response.JobInfoDTO} * * @author tjq * @since 2020/3/30 @@ -17,68 +17,122 @@ import java.util.List; @Data public class SaveJobInfoRequest { - // 任务ID(jobId),null -> 插入,否则为更新 + /** + * id of the job. set null to save or non-null to update the job. + */ private Long id; - /* ************************** 任务基本信息 ************************** */ - // 任务名称 + /* ************************** Base info of related job. ************************** */ + + /** + * Name of the job. + */ private String jobName; - // 任务描述 + /** + * Description of the job. + */ private String jobDescription; - // 任务所属的应用ID(Client无需填写该参数,自动填充) + /** + * Related id of the application. There is not need to set this property + * in PowerJob-client, as it would be set automatically. + */ private Long appId; - // 任务自带的参数 + /** + * Params that these jobs carry with when they are created. + */ private String jobParams; - /* ************************** 定时参数 ************************** */ - // 时间表达式类型(CRON/API/FIX_RATE/FIX_DELAY) + /* ************************** Timing param. ************************** */ + /** + * Time expression type. + */ private TimeExpressionType timeExpressionType; - // 时间表达式,CRON/NULL/LONG/LONG + /** + * Time expression. + */ private String timeExpression; - /* ************************** 执行方式 ************************** */ - // 执行类型,单机/广播/MR + /* ************************** Execution type. ************************** */ + /** + * Execution type, {@code standalone}, {@code broadcast} or {@code Map/MapReduce} + */ private ExecuteType executeType; - // 执行器类型,Java/Shell + /** + * Processor type, {@code Java}, {@code Python} or {@code Shell}. + */ private ProcessorType processorType; - // 执行器信息 + /** + * Processor info. + */ private String processorInfo; - /* ************************** 运行时配置 ************************** */ - // 最大同时运行任务数,0 代表不限 + /* ************************** Running instance setting. ************************** */ + /** + * Maximum instance setting num. {@code 0} means there is no restriction. + */ private Integer maxInstanceNum = 0; - // 并发度,同时执行的线程数量 + /** + * Concurrency setting. Number of threads that run simultaneously. + */ private Integer concurrency = 5; - // 任务整体超时时间 + /** + * Max instance running time setting. {@code 0L} means there is no restriction. + */ private Long instanceTimeLimit = 0L; - /* ************************** 重试配置 ************************** */ + /* ************************** Retrial setting. ************************** */ + /** + * Instance retry number setting. + */ private Integer instanceRetryNum = 0; + /** + * Task retry number setting. + */ private Integer taskRetryNum = 0; - /* ************************** 繁忙机器配置 ************************** */ - // 最低CPU核心数量,0代表不限 + /* ************************** Busy Machine setting. ************************** */ + /** + * Minimum CPU required. {@code 0} means there is no restriction. + */ private double minCpuCores = 0; - // 最低内存空间,单位 GB,0代表不限 + /** + * Minimum memory required, in GB. + */ private double minMemorySpace = 0; - // 最低磁盘空间,单位 GB,0代表不限 + /** + * Minimum disk space, in GB. {@code 0} means there is no restriction. + */ private double minDiskSpace = 0; - // 1 正常运行,2 停止(不再调度) + /** + * {@code 1} indicates that the worker node is running well, + * {@code 2} indicates that the worker node has been inactive + * and future tasks will not be assigned to the node. + */ private boolean enable = true; - /* ************************** 集群配置 ************************** */ - // 指定机器运行,空代表不限,非空则只会使用其中的机器运行(多值逗号分割) + /* ************************** PowerJob-worker cluster property ************************** */ + /** + * Designated PowerJob-worker nodes. Blank value indicates that there is + * no limit. Non-blank value means to run the corresponding machine(s) only. + */ private String designatedWorkers; - // 最大机器数量 + /** + * Max count of PowerJob-worker nodes. + */ private Integer maxWorkerCount = 0; - // 报警用户ID列表 + /** + * The id list of the users that need to be notified. + */ private List notifyUserIds; + /** + * Check non-null properties. + */ public void valid() { CommonUtils.requireNonNull(jobName, "jobName can't be empty"); CommonUtils.requireNonNull(appId, "appId can't be empty");