WangHan
2024-09-12 d5855a4926926698b740bc6c7ba489de47adb68b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
package tech.powerjob.common.request.http;
 
import tech.powerjob.common.enums.DispatchStrategy;
import tech.powerjob.common.enums.ExecuteType;
import tech.powerjob.common.enums.ProcessorType;
import tech.powerjob.common.enums.TimeExpressionType;
import tech.powerjob.common.model.AlarmConfig;
import tech.powerjob.common.model.JobAdvancedRuntimeConfig;
import tech.powerjob.common.model.LogConfig;
import tech.powerjob.common.model.LifeCycle;
import tech.powerjob.common.utils.CommonUtils;
import lombok.Data;
import tech.powerjob.common.response.JobInfoDTO;
 
import java.util.List;
 
/**
 * Save or modify {@link JobInfoDTO}
 *
 * @author tjq
 * @since 2020/3/30
 */
@Data
public class SaveJobInfoRequest {
 
    /**
     * id of the job. set null to create 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;
    /**
     * 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;
 
    /* ************************** Timing param. ************************** */
    /**
     * Time expression type.
     */
    private TimeExpressionType timeExpressionType;
    /**
     * Time expression.
     */
    private String timeExpression;
 
 
    /* ************************** Execution type. ************************** */
    /**
     * Execution type, {@code standalone}, {@code broadcast} or {@code Map/MapReduce}
     */
    private ExecuteType executeType;
    /**
     * Processor type, {@code Java}, {@code Python} or {@code Shell}.
     */
    private ProcessorType processorType;
    /**
     * Processor info.
     */
    private String processorInfo;
 
 
    /* ************************** 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;
 
    /* ************************** Busy Machine setting. ************************** */
    /**
     * Minimum CPU required. {@code 0} means there is no restriction.
     */
    private double minCpuCores = 0;
    /**
     * Minimum memory required, in GB.
     */
    private double minMemorySpace = 0;
    /**
     * Minimum disk space, in GB. {@code 0} means there is no restriction.
     */
    private double minDiskSpace = 0;
 
    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.
     * example: 192.168.1.1:27777,192.168.1.2:27777
     */
    private String designatedWorkers;
    /**
     * Max count of PowerJob-worker nodes.
     */
    private Integer maxWorkerCount = 0;
 
    /**
     * The id list of the users that need to be notified.
     */
    private List<Long> notifyUserIds;
 
    private String extra;
 
    private DispatchStrategy dispatchStrategy;
 
    /**
     * 某种派发策略背后的具体配置,值取决于 dispatchStrategy
     */
    private String dispatchStrategyConfig;
 
    private LifeCycle lifeCycle;
    /**
     * alarm config
     */
    private AlarmConfig alarmConfig;
 
    /**
     * 任务归类,开放给接入方自由定制
     */
    private String tag;
 
    /**
     * 日志配置,包括日志级别、日志方式等配置信息
     */
    private LogConfig logConfig;
 
    /**
     * 高级运行时配置
     */
    private JobAdvancedRuntimeConfig advancedRuntimeConfig;
 
    /**
     * Check non-null properties.
     */
    public void valid() {
        CommonUtils.requireNonNull(jobName, "jobName can't be empty");
        CommonUtils.requireNonNull(appId, "appId can't be empty");
        CommonUtils.requireNonNull(processorInfo, "processorInfo can't be empty");
        CommonUtils.requireNonNull(executeType, "executeType can't be empty");
        CommonUtils.requireNonNull(processorType, "processorType can't be empty");
        CommonUtils.requireNonNull(timeExpressionType, "timeExpressionType can't be empty");
    }
 
    public DispatchStrategy getDispatchStrategy() {
        if (dispatchStrategy == null) {
            return DispatchStrategy.HEALTH_FIRST;
        }
        return dispatchStrategy;
    }
}