@@ -41,18 +41,20 @@ public class OhMyClient {
41
41
42
42
/**
43
43
* Init OhMyClient with domain, appName and password.
44
- * @param domain 比如 www. powerjob-server.com(内网域名,自行完成 DNS & Proxy)
44
+ * @param domain like powerjob-server.apple-inc. com (Intranet Domain)
45
45
* @param appName name of the application
46
+ * @param password password of the application
46
47
*/
47
48
public OhMyClient (String domain , String appName , String password ) {
48
49
this (Lists .newArrayList (domain ), appName , password );
49
50
}
50
51
51
52
52
53
/**
53
- * nit OhMyClient with server address, appName and password.
54
- * @param addressList IP:Port address list
54
+ * Init OhMyClient with server address, appName and password.
55
+ * @param addressList IP:Port address list, like 192.168.1.1:7700
55
56
* @param appName name of the application
57
+ * @param password password of the application
56
58
*/
57
59
public OhMyClient (List <String > addressList , String appName , String password ) {
58
60
@@ -79,7 +81,7 @@ public OhMyClient(List<String> addressList, String appName, String password) {
79
81
}
80
82
81
83
if (StringUtils .isEmpty (currentAddress )) {
82
- throw new PowerJobException ("no server available" );
84
+ throw new PowerJobException ("no server available for OhMyClient " );
83
85
}
84
86
log .info ("[OhMyClient] {}'s OhMyClient bootstrap successfully, using server: {}" , appName , currentAddress );
85
87
}
@@ -101,12 +103,12 @@ private static String getUrl(String path, String address) {
101
103
/* ************* Job 区 ************* */
102
104
103
105
/**
104
- * 保存任务(包括创建与修改)
105
- * @param request 任务详细参数
106
- * @return 创建的任务ID
107
- * @throws PowerJobException 异常
106
+ * Save one Job
107
+ * When an ID exists in SaveJobInfoRequest, it is an update operation. Otherwise, it is a crate operation.
108
+ * @param request Job meta info
109
+ * @return jobId
108
110
*/
109
- public ResultDTO <Long > saveJob (SaveJobInfoRequest request ) throws PowerJobException {
111
+ public ResultDTO <Long > saveJob (SaveJobInfoRequest request ) {
110
112
111
113
request .setAppId (appId );
112
114
MediaType jsonType = MediaType .parse ("application/json; charset=utf-8" );
@@ -116,12 +118,11 @@ public ResultDTO<Long> saveJob(SaveJobInfoRequest request) throws PowerJobExcept
116
118
}
117
119
118
120
/**
119
- * 根据 jobId 查询任务信息
120
- * @param jobId 任务ID
121
- * @return 任务详细信息
122
- * @throws PowerJobException 异常
121
+ * Query JobInfo by jobId
122
+ * @param jobId jobId
123
+ * @return Job meta info
123
124
*/
124
- public ResultDTO <JobInfoDTO > fetchJob (Long jobId ) throws PowerJobException {
125
+ public ResultDTO <JobInfoDTO > fetchJob (Long jobId ) {
125
126
RequestBody body = new FormBody .Builder ()
126
127
.add ("jobId" , jobId .toString ())
127
128
.add ("appId" , appId .toString ())
@@ -131,12 +132,11 @@ public ResultDTO<JobInfoDTO> fetchJob(Long jobId) throws PowerJobException {
131
132
}
132
133
133
134
/**
134
- * 禁用某个任务
135
- * @param jobId 任务ID
136
- * @return 标准返回对象
137
- * @throws PowerJobException 异常
135
+ * Disable one Job by jobId
136
+ * @param jobId jobId
137
+ * @return Standard return object
138
138
*/
139
- public ResultDTO <Void > disableJob (Long jobId ) throws PowerJobException {
139
+ public ResultDTO <Void > disableJob (Long jobId ) {
140
140
RequestBody body = new FormBody .Builder ()
141
141
.add ("jobId" , jobId .toString ())
142
142
.add ("appId" , appId .toString ())
@@ -146,12 +146,11 @@ public ResultDTO<Void> disableJob(Long jobId) throws PowerJobException {
146
146
}
147
147
148
148
/**
149
- * 启用某个任务
150
- * @param jobId 任务ID
151
- * @return 标准返回对象
152
- * @throws PowerJobException 异常
149
+ * Enable one job by jobId
150
+ * @param jobId jobId
151
+ * @return Standard return object
153
152
*/
154
- public ResultDTO <Void > enableJob (Long jobId ) throws PowerJobException {
153
+ public ResultDTO <Void > enableJob (Long jobId ) {
155
154
RequestBody body = new FormBody .Builder ()
156
155
.add ("jobId" , jobId .toString ())
157
156
.add ("appId" , appId .toString ())
@@ -161,12 +160,11 @@ public ResultDTO<Void> enableJob(Long jobId) throws PowerJobException {
161
160
}
162
161
163
162
/**
164
- * 删除某个任务
165
- * @param jobId 任务ID
166
- * @return 标准返回对象
167
- * @throws PowerJobException 异常
163
+ * Delete one job by jobId
164
+ * @param jobId jobId
165
+ * @return Standard return object
168
166
*/
169
- public ResultDTO <Void > deleteJob (Long jobId ) throws PowerJobException {
167
+ public ResultDTO <Void > deleteJob (Long jobId ) {
170
168
RequestBody body = new FormBody .Builder ()
171
169
.add ("jobId" , jobId .toString ())
172
170
.add ("appId" , appId .toString ())
@@ -176,14 +174,13 @@ public ResultDTO<Void> deleteJob(Long jobId) throws PowerJobException {
176
174
}
177
175
178
176
/**
179
- * 运行某个任务
180
- * @param jobId 任务ID
181
- * @param instanceParams 任务实例的参数
182
- * @param delayMS 延迟时间,单位毫秒
183
- * @return 任务实例ID(instanceId)
184
- * @throws PowerJobException 异常
177
+ * Run a job once
178
+ * @param jobId ID of the job to be run
179
+ * @param instanceParams Runtime parameters of the job (TaskContext#instanceParams)
180
+ * @param delayMS Delay time(Milliseconds)
181
+ * @return instanceId
185
182
*/
186
- public ResultDTO <Long > runJob (Long jobId , String instanceParams , long delayMS ) throws PowerJobException {
183
+ public ResultDTO <Long > runJob (Long jobId , String instanceParams , long delayMS ) {
187
184
FormBody .Builder builder = new FormBody .Builder ()
188
185
.add ("jobId" , jobId .toString ())
189
186
.add ("appId" , appId .toString ())
@@ -201,12 +198,11 @@ public ResultDTO<Long> runJob(Long jobId) throws PowerJobException {
201
198
202
199
/* ************* Instance API list ************* */
203
200
/**
204
- * 停止应用实例
205
- * @param instanceId 应用实例ID
206
- * @return true 停止成功,false 停止失败
207
- * @throws PowerJobException 异常
201
+ * Stop one job instance
202
+ * @param instanceId instanceId
203
+ * @return Standard return object
208
204
*/
209
- public ResultDTO <Void > stopInstance (Long instanceId ) throws PowerJobException {
205
+ public ResultDTO <Void > stopInstance (Long instanceId ) {
210
206
RequestBody body = new FormBody .Builder ()
211
207
.add ("instanceId" , instanceId .toString ())
212
208
.add ("appId" , appId .toString ())
@@ -216,13 +212,12 @@ public ResultDTO<Void> stopInstance(Long instanceId) throws PowerJobException {
216
212
}
217
213
218
214
/**
219
- * 取消任务实例
220
- * 接口使用条件:调用接口时间与待取消任务的预计执行时间有一定时间间隔,否则不保证可靠性!
221
- * @param instanceId 任务实例ID
222
- * @return true 代表取消成功,false 取消失败
223
- * @throws PowerJobException 异常
215
+ * Cancel a job instance that is not yet running
216
+ * Notice:There is a time interval between the call interface time and the expected execution time of the job instance to be cancelled, otherwise reliability is not guaranteed
217
+ * @param instanceId instanceId
218
+ * @return Standard return object
224
219
*/
225
- public ResultDTO <Void > cancelInstance (Long instanceId ) throws PowerJobException {
220
+ public ResultDTO <Void > cancelInstance (Long instanceId ) {
226
221
RequestBody body = new FormBody .Builder ()
227
222
.add ("instanceId" , instanceId .toString ())
228
223
.add ("appId" , appId .toString ())
@@ -232,13 +227,12 @@ public ResultDTO<Void> cancelInstance(Long instanceId) throws PowerJobException
232
227
}
233
228
234
229
/**
235
- * 重试任务实例
236
- * 只有完成状态(成功、失败、手动停止、被取消)的任务才能被重试,且暂不支持工作流内任务实例的重试
237
- * @param instanceId 任务实例ID
238
- * @return true 代表取消成功,false 取消失败
239
- * @throws PowerJobException 异常
230
+ * Retry failed job instance
231
+ * Notice: Only job instance with completion status (success, failure, manually stopped, cancelled) can be retried, and retries of job instances within workflows are not supported yet.
232
+ * @param instanceId instanceId
233
+ * @return Standard return object
240
234
*/
241
- public ResultDTO <Void > retryInstance (Long instanceId ) throws PowerJobException {
235
+ public ResultDTO <Void > retryInstance (Long instanceId ) {
242
236
RequestBody body = new FormBody .Builder ()
243
237
.add ("instanceId" , instanceId .toString ())
244
238
.add ("appId" , appId .toString ())
@@ -248,12 +242,11 @@ public ResultDTO<Void> retryInstance(Long instanceId) throws PowerJobException {
248
242
}
249
243
250
244
/**
251
- * 查询任务实例状态
252
- * @param instanceId 应用实例ID
253
- * @return {@link InstanceStatus} 的枚举值
254
- * @throws PowerJobException 异常
245
+ * Query status about a job instance
246
+ * @param instanceId instanceId
247
+ * @return {@link InstanceStatus}
255
248
*/
256
- public ResultDTO <Integer > fetchInstanceStatus (Long instanceId ) throws PowerJobException {
249
+ public ResultDTO <Integer > fetchInstanceStatus (Long instanceId ) {
257
250
RequestBody body = new FormBody .Builder ()
258
251
.add ("instanceId" , instanceId .toString ())
259
252
.build ();
@@ -262,12 +255,11 @@ public ResultDTO<Integer> fetchInstanceStatus(Long instanceId) throws PowerJobEx
262
255
}
263
256
264
257
/**
265
- * 查询任务实例的信息
266
- * @param instanceId 任务实例ID
267
- * @return 任务实例信息
268
- * @throws PowerJobException 潜在的异常
258
+ * Query detail about a job instance
259
+ * @param instanceId instanceId
260
+ * @return instance detail
269
261
*/
270
- public ResultDTO <InstanceInfoDTO > fetchInstanceInfo (Long instanceId ) throws PowerJobException {
262
+ public ResultDTO <InstanceInfoDTO > fetchInstanceInfo (Long instanceId ) {
271
263
RequestBody body = new FormBody .Builder ()
272
264
.add ("instanceId" , instanceId .toString ())
273
265
.build ();
@@ -277,12 +269,12 @@ public ResultDTO<InstanceInfoDTO> fetchInstanceInfo(Long instanceId) throws Powe
277
269
278
270
/* ************* Workflow API list ************* */
279
271
/**
280
- * 保存工作流(包括创建和修改)
281
- * @param request 创建/修改 Workflow 请求
282
- * @return 工作流ID
283
- * @throws PowerJobException 异常
272
+ * Save one workflow
273
+ * When an ID exists in SaveWorkflowRequest, it is an update operation. Otherwise, it is a crate operation.
274
+ * @param request Workflow meta info
275
+ * @return workflowId
284
276
*/
285
- public ResultDTO <Long > saveWorkflow (SaveWorkflowRequest request ) throws PowerJobException {
277
+ public ResultDTO <Long > saveWorkflow (SaveWorkflowRequest request ) {
286
278
request .setAppId (appId );
287
279
MediaType jsonType = MediaType .parse (OmsConstant .JSON_MEDIA_TYPE );
288
280
// 中坑记录:用 FastJSON 序列化会导致 Server 接收时 pEWorkflowDAG 为 null,无语.jpg
@@ -292,12 +284,11 @@ public ResultDTO<Long> saveWorkflow(SaveWorkflowRequest request) throws PowerJob
292
284
}
293
285
294
286
/**
295
- * 根据 workflowId 查询工作流信息
287
+ * Query Workflow by workflowId
296
288
* @param workflowId workflowId
297
- * @return 工作流信息
298
- * @throws PowerJobException 异常
289
+ * @return Workflow meta info
299
290
*/
300
- public ResultDTO <WorkflowInfoDTO > fetchWorkflow (Long workflowId ) throws PowerJobException {
291
+ public ResultDTO <WorkflowInfoDTO > fetchWorkflow (Long workflowId ) {
301
292
RequestBody body = new FormBody .Builder ()
302
293
.add ("workflowId" , workflowId .toString ())
303
294
.add ("appId" , appId .toString ())
@@ -307,12 +298,11 @@ public ResultDTO<WorkflowInfoDTO> fetchWorkflow(Long workflowId) throws PowerJob
307
298
}
308
299
309
300
/**
310
- * 禁用某个工作流
311
- * @param workflowId 工作流ID
312
- * @return 标准返回对象
313
- * @throws PowerJobException 异常
301
+ * Disable Workflow by workflowId
302
+ * @param workflowId workflowId
303
+ * @return Standard return object
314
304
*/
315
- public ResultDTO <Void > disableWorkflow (Long workflowId ) throws PowerJobException {
305
+ public ResultDTO <Void > disableWorkflow (Long workflowId ) {
316
306
RequestBody body = new FormBody .Builder ()
317
307
.add ("workflowId" , workflowId .toString ())
318
308
.add ("appId" , appId .toString ())
@@ -322,12 +312,11 @@ public ResultDTO<Void> disableWorkflow(Long workflowId) throws PowerJobException
322
312
}
323
313
324
314
/**
325
- * 启用某个工作流
315
+ * Enable Workflow by workflowId
326
316
* @param workflowId workflowId
327
- * @return 标准返回对象
328
- * @throws PowerJobException 异常
317
+ * @return Standard return object
329
318
*/
330
- public ResultDTO <Void > enableWorkflow (Long workflowId ) throws PowerJobException {
319
+ public ResultDTO <Void > enableWorkflow (Long workflowId ) {
331
320
RequestBody body = new FormBody .Builder ()
332
321
.add ("workflowId" , workflowId .toString ())
333
322
.add ("appId" , appId .toString ())
@@ -337,12 +326,11 @@ public ResultDTO<Void> enableWorkflow(Long workflowId) throws PowerJobException
337
326
}
338
327
339
328
/**
340
- * 删除某个工作流
329
+ * Delete Workflow by workflowId
341
330
* @param workflowId workflowId
342
- * @return 标准返回对象
343
- * @throws PowerJobException 异常
331
+ * @return Standard return object
344
332
*/
345
- public ResultDTO <Void > deleteWorkflow (Long workflowId ) throws PowerJobException {
333
+ public ResultDTO <Void > deleteWorkflow (Long workflowId ) {
346
334
RequestBody body = new FormBody .Builder ()
347
335
.add ("workflowId" , workflowId .toString ())
348
336
.add ("appId" , appId .toString ())
@@ -352,14 +340,13 @@ public ResultDTO<Void> deleteWorkflow(Long workflowId) throws PowerJobException
352
340
}
353
341
354
342
/**
355
- * 运行工作流
356
- * @param workflowId 工作流ID
357
- * @param initParams 启动参数
358
- * @param delayMS 延迟时间,单位毫秒 ms
359
- * @return 工作流实例ID
360
- * @throws PowerJobException 异常信息
343
+ * Run a workflow once
344
+ * @param workflowId workflowId
345
+ * @param initParams workflow startup parameters
346
+ * @param delayMS Delay time(Milliseconds)
347
+ * @return workflow instanceId
361
348
*/
362
- public ResultDTO <Long > runWorkflow (Long workflowId , String initParams , long delayMS ) throws PowerJobException {
349
+ public ResultDTO <Long > runWorkflow (Long workflowId , String initParams , long delayMS ) {
363
350
FormBody .Builder builder = new FormBody .Builder ()
364
351
.add ("workflowId" , workflowId .toString ())
365
352
.add ("appId" , appId .toString ())
@@ -376,10 +363,9 @@ public ResultDTO<Long> runWorkflow(Long workflowId) throws PowerJobException {
376
363
377
364
/* ************* Workflow Instance API list ************* */
378
365
/**
379
- * 停止应用实例
380
- * @param wfInstanceId 工作流实例ID
381
- * @return true 停止成功 ; false 停止失败
382
- * @throws PowerJobException 异常
366
+ * Stop one workflow instance
367
+ * @param wfInstanceId workflow instanceId
368
+ * @return Standard return object
383
369
*/
384
370
public ResultDTO <Void > stopWorkflowInstance (Long wfInstanceId ) throws PowerJobException {
385
371
RequestBody body = new FormBody .Builder ()
@@ -391,12 +377,11 @@ public ResultDTO<Void> stopWorkflowInstance(Long wfInstanceId) throws PowerJobEx
391
377
}
392
378
393
379
/**
394
- * 查询任务实例的信息
395
- * @param wfInstanceId 任务实例ID
396
- * @return 任务实例信息
397
- * @throws PowerJobException 潜在的异常
380
+ * Query detail about a workflow instance
381
+ * @param wfInstanceId workflow instanceId
382
+ * @return detail about a workflow
398
383
*/
399
- public ResultDTO <WorkflowInstanceInfoDTO > fetchWorkflowInstanceInfo (Long wfInstanceId ) throws PowerJobException {
384
+ public ResultDTO <WorkflowInstanceInfoDTO > fetchWorkflowInstanceInfo (Long wfInstanceId ) {
400
385
RequestBody body = new FormBody .Builder ()
401
386
.add ("wfInstanceId" , wfInstanceId .toString ())
402
387
.add ("appId" , appId .toString ())
0 commit comments