Skip to content

Commit

Permalink
rename job exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ponfee committed Nov 11, 2023
1 parent 8e4206f commit 1c61ff5
Show file tree
Hide file tree
Showing 27 changed files with 141 additions and 136 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ disjob # 主项目①

## Comparison

| **Feature** | **Quartz** | **Elastic-Job** | **Xxl-Job** | **Disjob** |
| ------------ | ---------- |-----------------|----------------------|----------------------------------------|
| **Feature** | **Quartz** | **Elastic-Job** | **Xxl-Job** | **Disjob** |
| ---------------- | ---------- |-----------------|----------------------|----------------------------------------|
| **触发类型** | Cron | Cron | Cron、固定频率、父子依赖 | Cron、指定时间、固定频率、固定延时、父子依赖 |
| **任务编排** | 不支持 | 不支持 | 不支持 | DAG表达式 |
| **任务编排** | 不支持 | 不支持 | 不支持 | DAG表达式 |
| **任务分片** | 不支持 | 静态分片 | 广播任务 | 广播任务、动态分片 |
| **停止与恢复** | 不支持 | 不支持 | 终止运行中的任务 | 暂停执行中的任务、恢复已暂停的任务 |
| **保存执行快照** | 不支持 | 不支持 | 不支持 | 支持 |
Expand Down Expand Up @@ -116,14 +116,14 @@ disjob # 主项目①

- 浏览器访问【 http://127.0.0.1:80/ 】登录管理后台,用户名/密码:`admin`/`admin123`
- 登录后在左侧菜单栏找到`调度管理`菜单,即可使用调度管理功能
- 调度配置:作业(job)配置,包括查看、新增、修改、删除、触发、禁用等
- 调度实例:job具体时间点要触发执行的实例(instance),一个实例被拆分成若干个任务(task)
- 第一个分页表格为`查询root实例`并支持下钻,root是指首次触发的实例,包括:普通的非重试实例、工作流(DAG)的lead实例、依赖关系的第一个实例
- 鼠标向下滚动页面后看到的第二个分页表格为`查询所有实例`
- **调度配置**:作业(job)配置,包括查看、新增、修改、删除、触发、禁用等
- **调度实例**:job在某一时间点被触发执行的实例(instance),一个实例会拆分成若干个任务(task)
- 在页面上方的`第一个分页表格`是以树状(tree)方式展示调度实例,并支持下钻
- 鼠标向下滚动页面后看到的`第二个分页表格`是以扁平(flat)方式展示调度实例

4. 链接地址
- 管理后台演示地址:【 http://ponfee.cn:8000/ 】,用户名/密码:`disjob`/`disjob123`
- 在线文档地址`正在建设中,敬请期待!`
- 管理后台**演示地址**:【 http://ponfee.cn:8000/ 】,用户名/密码:`disjob`/`disjob123`
- 在线查看**文档地址**`正在建设中,敬请期待!`

## User Guide

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.text.NumberFormat;
Expand Down Expand Up @@ -978,7 +979,12 @@ public static String digitUppercase(double n)
String s = "";
for (int i = 0; i < fraction.length; i++)
{
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
// 优化double计算精度丢失问题
BigDecimal nNum = new BigDecimal(n);
BigDecimal decimal = new BigDecimal(10);
BigDecimal scale = nNum.multiply(decimal).setScale(2, RoundingMode.HALF_EVEN);
double d = scale.doubleValue();
s += (digit[(int) (Math.floor(d * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
}
if (s.length() < 1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import cn.ponfee.disjob.core.api.supervisor.request.SchedJobPageRequest;
import cn.ponfee.disjob.core.api.supervisor.request.UpdateSchedJobRequest;
import cn.ponfee.disjob.core.api.supervisor.response.SchedJobResponse;
import cn.ponfee.disjob.core.exception.JobCheckedException;
import cn.ponfee.disjob.core.exception.JobException;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
Expand Down Expand Up @@ -136,7 +136,7 @@ private String toAdd(SchedJobResponse job, ModelMap mmap) {
@Log(title = "调度配置", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult doAdd(AddSchedJobRequest req) throws JobCheckedException {
public AjaxResult doAdd(AddSchedJobRequest req) throws JobException {
req.setCreatedBy(getLoginName());
supervisorOpenRpcService.addJob(req);
return success();
Expand All @@ -161,7 +161,7 @@ public String edit(@PathVariable("id") long jobId, ModelMap mmap) {
@Log(title = "调度配置", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult doEdit(UpdateSchedJobRequest req) throws JobCheckedException {
public AjaxResult doEdit(UpdateSchedJobRequest req) throws JobException {
req.setUpdatedBy(getLoginName());
supervisorOpenRpcService.updateJob(req);
return success();
Expand Down Expand Up @@ -206,7 +206,7 @@ public AjaxResult changeState(@RequestParam("jobId") long jobId,
@Log(title = "触发执行", businessType = BusinessType.OTHER)
@PostMapping("/trigger")
@ResponseBody
public AjaxResult trigger(@RequestParam("jobId") long jobId) throws JobCheckedException {
public AjaxResult trigger(@RequestParam("jobId") long jobId) throws JobException {
supervisorOpenRpcService.triggerJob(jobId);
return success();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@
import cn.ponfee.disjob.common.model.CodeMsg;

/**
* Base unchecked exception definition(运行时异常)
* Base checked exception definition(编译时异常)
*
* @author Ponfee
*/
public abstract class BaseUncheckedException extends RuntimeException {
private static final long serialVersionUID = 5960744547215706709L;
public abstract class BaseException extends Exception {
private static final long serialVersionUID = -5891689205125494699L;

/**
* Error code
*/
private final int code;

public BaseUncheckedException(int code) {
public BaseException(int code) {
this(code, null, null);
}

public BaseUncheckedException(CodeMsg codeMsg) {
public BaseException(CodeMsg codeMsg) {
this(codeMsg.getCode(), codeMsg.getMsg(), null);
}

/**
* @param code error code
* @param message error message
*/
public BaseUncheckedException(int code, String message) {
public BaseException(int code, String message) {
this(code, message, null);
}

public BaseUncheckedException(CodeMsg codeMsg, Throwable cause) {
public BaseException(CodeMsg codeMsg, Throwable cause) {
this(codeMsg.getCode(), codeMsg.getMsg(), cause);
}

Expand All @@ -48,7 +48,7 @@ public BaseUncheckedException(CodeMsg codeMsg, Throwable cause) {
* @param message error message
* @param cause root cause
*/
public BaseUncheckedException(int code, String message, Throwable cause) {
public BaseException(int code, String message, Throwable cause) {
super(message, cause);
this.code = code;
}
Expand All @@ -60,11 +60,11 @@ public BaseUncheckedException(int code, String message, Throwable cause) {
* @param enableSuppression the enableSuppression
* @param writableStackTrace then writableStackTrace
*/
public BaseUncheckedException(int code,
String message,
Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
public BaseException(int code,
String message,
Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
this.code = code;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@
import cn.ponfee.disjob.common.model.CodeMsg;

/**
* Base checked exception definition(编译时异常)
* Base unchecked(runtime) exception definition(运行时异常)
*
* @author Ponfee
*/
public abstract class BaseCheckedException extends Exception {
private static final long serialVersionUID = -5891689205125494699L;
public abstract class BaseRuntimeException extends RuntimeException {
private static final long serialVersionUID = 5960744547215706709L;

/**
* Error code
*/
private final int code;

public BaseCheckedException(int code) {
public BaseRuntimeException(int code) {
this(code, null, null);
}

public BaseCheckedException(CodeMsg codeMsg) {
public BaseRuntimeException(CodeMsg codeMsg) {
this(codeMsg.getCode(), codeMsg.getMsg(), null);
}

/**
* @param code error code
* @param message error message
*/
public BaseCheckedException(int code, String message) {
public BaseRuntimeException(int code, String message) {
this(code, message, null);
}

public BaseCheckedException(CodeMsg codeMsg, Throwable cause) {
public BaseRuntimeException(CodeMsg codeMsg, Throwable cause) {
this(codeMsg.getCode(), codeMsg.getMsg(), cause);
}

Expand All @@ -48,7 +48,7 @@ public BaseCheckedException(CodeMsg codeMsg, Throwable cause) {
* @param message error message
* @param cause root cause
*/
public BaseCheckedException(int code, String message, Throwable cause) {
public BaseRuntimeException(int code, String message, Throwable cause) {
super(message, cause);
this.code = code;
}
Expand All @@ -60,7 +60,7 @@ public BaseCheckedException(int code, String message, Throwable cause) {
* @param enableSuppression the enableSuppression
* @param writableStackTrace then writableStackTrace
*/
public BaseCheckedException(int code,
public BaseRuntimeException(int code,
String message,
Throwable cause,
boolean enableSuppression,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import cn.ponfee.disjob.core.api.supervisor.response.SchedInstanceResponse;
import cn.ponfee.disjob.core.api.supervisor.response.SchedJobResponse;
import cn.ponfee.disjob.core.api.supervisor.response.SchedTaskResponse;
import cn.ponfee.disjob.core.exception.JobCheckedException;
import cn.ponfee.disjob.core.exception.JobException;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.web.bind.annotation.*;

Expand All @@ -34,10 +34,10 @@ public interface SupervisorOpenRpcService {
// ------------------------------------------------------------------job

@PostMapping("job/add")
void addJob(AddSchedJobRequest req) throws JobCheckedException;
void addJob(AddSchedJobRequest req) throws JobException;

@PutMapping("job/update")
void updateJob(UpdateSchedJobRequest req) throws JobCheckedException;
void updateJob(UpdateSchedJobRequest req) throws JobException;

@DeleteMapping("job/delete")
void deleteJob(long jobId);
Expand All @@ -46,7 +46,7 @@ public interface SupervisorOpenRpcService {
Boolean changeJobState(long jobId, int jobState);

@PostMapping("job/trigger")
void triggerJob(long jobId) throws JobCheckedException;
void triggerJob(long jobId) throws JobException;

@GetMapping("job/get")
SchedJobResponse getJob(long jobId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
package cn.ponfee.disjob.core.base;

import cn.ponfee.disjob.core.enums.Operations;
import cn.ponfee.disjob.core.handle.Savepoint;
import cn.ponfee.disjob.core.handle.execution.WorkflowPredecessorNode;
import cn.ponfee.disjob.core.model.SchedTask;
import cn.ponfee.disjob.core.param.StartTaskParam;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package cn.ponfee.disjob.core.base;

import cn.ponfee.disjob.core.exception.JobCheckedException;
import cn.ponfee.disjob.core.exception.JobException;
import cn.ponfee.disjob.core.handle.SplitTask;
import cn.ponfee.disjob.core.param.JobHandlerParam;
import io.swagger.v3.oas.annotations.Hidden;
Expand All @@ -29,9 +29,9 @@ public interface WorkerCoreRpcService {
String PREFIX_PATH = "worker/core/rpc/";

@PostMapping("job/verify")
void verify(JobHandlerParam param) throws JobCheckedException;
void verify(JobHandlerParam param) throws JobException;

@PostMapping("job/split")
List<SplitTask> split(JobHandlerParam param) throws JobCheckedException;
List<SplitTask> split(JobHandlerParam param) throws JobException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

package cn.ponfee.disjob.core.exception;

import cn.ponfee.disjob.common.exception.BaseCheckedException;
import cn.ponfee.disjob.common.exception.BaseException;
import cn.ponfee.disjob.common.model.CodeMsg;

/**
* Executing task failure then should be canceling.
*
* @author Ponfee
*/
public class CancelTaskException extends BaseCheckedException {
public class CancelTaskException extends BaseException {
private static final long serialVersionUID = -3461401416673580272L;

public CancelTaskException(CodeMsg cm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,42 @@

package cn.ponfee.disjob.core.exception;

import cn.ponfee.disjob.common.exception.BaseUncheckedException;
import cn.ponfee.disjob.common.exception.BaseException;
import cn.ponfee.disjob.common.model.CodeMsg;

/**
* Job unchecked exception definition.
* Job checked exception definition.
*
* @author Ponfee
*/
public class JobUncheckedException extends BaseUncheckedException {
private static final long serialVersionUID = -5627922900462363679L;
public class JobException extends BaseException {
private static final long serialVersionUID = -6568546076593428337L;

public JobUncheckedException(int code) {
public JobException(int code) {
this(code, null, null);
}

public JobUncheckedException(int code, String message) {
public JobException(int code, String message) {
this(code, message, null);
}

public JobUncheckedException(int code, Throwable cause) {
public JobException(int code, Throwable cause) {
this(code, null, cause);
}

public JobUncheckedException(int code, String message, Throwable cause) {
public JobException(int code, String message, Throwable cause) {
super(code, message, cause);
}

public JobUncheckedException(CodeMsg cm) {
public JobException(CodeMsg cm) {
super(cm.getCode(), cm.getMsg(), null);
}

public JobUncheckedException(CodeMsg cm, String message) {
public JobException(CodeMsg cm, String message) {
super(cm.getCode(), message, null);
}

public JobUncheckedException(CodeMsg cm, String message, Throwable cause) {
public JobException(CodeMsg cm, String message, Throwable cause) {
super(cm.getCode(), message, cause);
}

Expand All @@ -56,8 +56,8 @@ public JobUncheckedException(CodeMsg cm, String message, Throwable cause) {
* @param enableSuppression the enableSuppression
* @param writableStackTrace the writableStackTrace
*/
public JobUncheckedException(int code, String message, Throwable cause,
boolean enableSuppression, boolean writableStackTrace) {
public JobException(int code, String message, Throwable cause,
boolean enableSuppression, boolean writableStackTrace) {
super(code, message, cause, enableSuppression, writableStackTrace);
}

Expand Down
Loading

0 comments on commit 1c61ff5

Please sign in to comment.