diff --git a/disjob-admin/ruoyi-disjob/src/main/java/cn/ponfee/disjob/admin/DisjobAdminConfiguration.java b/disjob-admin/ruoyi-disjob/src/main/java/cn/ponfee/disjob/admin/DisjobAdminConfiguration.java index 707eda803..dbd50c884 100644 --- a/disjob-admin/ruoyi-disjob/src/main/java/cn/ponfee/disjob/admin/DisjobAdminConfiguration.java +++ b/disjob-admin/ruoyi-disjob/src/main/java/cn/ponfee/disjob/admin/DisjobAdminConfiguration.java @@ -39,7 +39,7 @@ @Configuration @ComponentScan("cn.ponfee.disjob.test.handler") @EnableJacksonDateConfigurer // 解决日期反序列化报错的问题 -@EnableSupervisor // job-admin必须启用Supervisor角色,即:@EnableSupervisor注解是必须加的 +@EnableSupervisor // disjob-admin必须启用Supervisor角色,即:必须加@EnableSupervisor注解 @EnableWorker // 若要取消worker角色可去掉@EnableWorker注解 public class DisjobAdminConfiguration implements WebMvcConfigurer { diff --git a/disjob-admin/ruoyi-disjob/src/main/java/cn/ponfee/disjob/admin/controller/DisjobInstanceController.java b/disjob-admin/ruoyi-disjob/src/main/java/cn/ponfee/disjob/admin/controller/DisjobInstanceController.java index 00881cb55..110e7420c 100644 --- a/disjob-admin/ruoyi-disjob/src/main/java/cn/ponfee/disjob/admin/controller/DisjobInstanceController.java +++ b/disjob-admin/ruoyi-disjob/src/main/java/cn/ponfee/disjob/admin/controller/DisjobInstanceController.java @@ -15,7 +15,7 @@ import cn.ponfee.disjob.supervisor.provider.openapi.request.SchedInstancePageRequest; import cn.ponfee.disjob.supervisor.provider.openapi.response.SchedInstanceResponse; import cn.ponfee.disjob.supervisor.provider.openapi.response.SchedTaskResponse; -import cn.ponfee.disjob.supervisor.service.SupervisorAggregator; +import cn.ponfee.disjob.supervisor.service.SupervisorOpenapiService; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -44,10 +44,10 @@ public class DisjobInstanceController extends BaseController { private static final int WAIT_SLEEP_ROUND = 9; private static final long[] WAIT_SLEEP_MILLIS = {2500, 500}; - private final SupervisorAggregator supervisorAggregator; + private final SupervisorOpenapiService supervisorOpenapiService; - public DisjobInstanceController(SupervisorAggregator supervisorAggregator) { - this.supervisorAggregator = supervisorAggregator; + public DisjobInstanceController(SupervisorOpenapiService supervisorOpenapiService) { + this.supervisorOpenapiService = supervisorOpenapiService; } @RequiresPermissions(PERMISSION_VIEW) @@ -66,7 +66,7 @@ public TableDataInfo tree(SchedInstancePageRequest request) { request.setParent(true); request.setPageNumber(super.getPageNumber()); request.setPageSize(super.getPageSize()); - return PageUtils.toTableDataInfo(supervisorAggregator.queryInstanceForPage(request)); + return PageUtils.toTableDataInfo(supervisorOpenapiService.queryInstanceForPage(request)); } /** @@ -79,20 +79,20 @@ public TableDataInfo flat(SchedInstancePageRequest request) { request.setParent(false); request.setPageNumber(super.getPageNumber()); request.setPageSize(super.getPageSize()); - return PageUtils.toTableDataInfo(supervisorAggregator.queryInstanceForPage(request)); + return PageUtils.toTableDataInfo(supervisorOpenapiService.queryInstanceForPage(request)); } @RequiresPermissions(PERMISSION_QUERY) @PostMapping("/children") @ResponseBody public List children(@RequestParam("pnstanceId") Long pnstanceId) { - return supervisorAggregator.listInstanceChildren(pnstanceId); + return supervisorOpenapiService.listInstanceChildren(pnstanceId); } @RequiresPermissions(PERMISSION_QUERY) @GetMapping("/tasks/{instanceId}") public String tasks(@PathVariable("instanceId") Long instanceId, ModelMap mmap) { - List tasks = supervisorAggregator.getInstanceTasks(instanceId); + List tasks = supervisorOpenapiService.getInstanceTasks(instanceId); mmap.put("tasks", Jsons.toJson(tasks)); return PREFIX + "/tasks"; } @@ -107,7 +107,7 @@ public String tasks(@PathVariable("instanceId") Long instanceId, ModelMap mmap) @PostMapping("/remove/{instanceId}") @ResponseBody public AjaxResult remove(@PathVariable("instanceId") Long instanceId) { - supervisorAggregator.deleteInstance(instanceId); + supervisorOpenapiService.deleteInstance(instanceId); return success(); } @@ -119,9 +119,9 @@ public AjaxResult remove(@PathVariable("instanceId") Long instanceId) { @PostMapping("/pause/{instanceId}") @ResponseBody public AjaxResult pause(@PathVariable("instanceId") Long instanceId) { - supervisorAggregator.pauseInstance(instanceId); + supervisorOpenapiService.pauseInstance(instanceId); SleepWaitUtils.waitUntil(WAIT_SLEEP_ROUND, WAIT_SLEEP_MILLIS, () -> { - SchedInstanceResponse instance = supervisorAggregator.getInstance(instanceId, false); + SchedInstanceResponse instance = supervisorOpenapiService.getInstance(instanceId, false); return !RunState.PAUSABLE_LIST.contains(RunState.of(instance.getRunState())); }); return success(); @@ -135,9 +135,9 @@ public AjaxResult pause(@PathVariable("instanceId") Long instanceId) { @PostMapping("/resume/{instanceId}") @ResponseBody public AjaxResult resume(@PathVariable("instanceId") Long instanceId) { - supervisorAggregator.resumeInstance(instanceId); + supervisorOpenapiService.resumeInstance(instanceId); SleepWaitUtils.waitUntil(WAIT_SLEEP_ROUND, new long[]{500, 200}, () -> { - SchedInstanceResponse instance = supervisorAggregator.getInstance(instanceId, false); + SchedInstanceResponse instance = supervisorOpenapiService.getInstance(instanceId, false); return !RunState.PAUSED.equals(instance.getRunState()); }); return success(); @@ -151,9 +151,9 @@ public AjaxResult resume(@PathVariable("instanceId") Long instanceId) { @PostMapping("/cancel/{instanceId}") @ResponseBody public AjaxResult cancel(@PathVariable("instanceId") Long instanceId) { - supervisorAggregator.cancelInstance(instanceId); + supervisorOpenapiService.cancelInstance(instanceId); SleepWaitUtils.waitUntil(WAIT_SLEEP_ROUND, WAIT_SLEEP_MILLIS, () -> { - SchedInstanceResponse instance = supervisorAggregator.getInstance(instanceId, false); + SchedInstanceResponse instance = supervisorOpenapiService.getInstance(instanceId, false); return RunState.of(instance.getRunState()).isTerminal(); }); return success(); diff --git a/disjob-admin/ruoyi-disjob/src/main/java/cn/ponfee/disjob/admin/controller/DisjobJobController.java b/disjob-admin/ruoyi-disjob/src/main/java/cn/ponfee/disjob/admin/controller/DisjobJobController.java index 62c1e6738..f0e0eebe9 100644 --- a/disjob-admin/ruoyi-disjob/src/main/java/cn/ponfee/disjob/admin/controller/DisjobJobController.java +++ b/disjob-admin/ruoyi-disjob/src/main/java/cn/ponfee/disjob/admin/controller/DisjobJobController.java @@ -17,7 +17,7 @@ import cn.ponfee.disjob.supervisor.provider.openapi.request.SchedJobPageRequest; import cn.ponfee.disjob.supervisor.provider.openapi.request.UpdateSchedJobRequest; import cn.ponfee.disjob.supervisor.provider.openapi.response.SchedJobResponse; -import cn.ponfee.disjob.supervisor.service.SupervisorAggregator; +import cn.ponfee.disjob.supervisor.service.SupervisorOpenapiService; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -50,10 +50,10 @@ public class DisjobJobController extends BaseController { private static final String PERMISSION_QUERY = "disjob:job:query"; private static final String PERMISSION_OPERATE = "disjob:job:operate"; - private final SupervisorAggregator supervisorAggregator; + private final SupervisorOpenapiService supervisorOpenapiService; - public DisjobJobController(SupervisorAggregator supervisorAggregator) { - this.supervisorAggregator = supervisorAggregator; + public DisjobJobController(SupervisorOpenapiService supervisorOpenapiService) { + this.supervisorOpenapiService = supervisorOpenapiService; } // -------------------------------------------------------查询 @@ -73,7 +73,7 @@ public String job() { public TableDataInfo list(SchedJobPageRequest request) { request.setPageNumber(super.getPageNumber()); request.setPageSize(super.getPageSize()); - PageResponse response = supervisorAggregator.queryJobForPage(request); + PageResponse response = supervisorOpenapiService.queryJobForPage(request); return PageUtils.toTableDataInfo(response); } @@ -83,7 +83,7 @@ public TableDataInfo list(SchedJobPageRequest request) { @RequiresPermissions(PERMISSION_QUERY) @GetMapping("/detail/{jobId}") public String detail(@PathVariable("jobId") long jobId, ModelMap mmap) { - SchedJobResponse job = supervisorAggregator.getJob(jobId); + SchedJobResponse job = supervisorOpenapiService.getJob(jobId); Assert.notNull(job, () -> "Job id not found: " + jobId); mmap.put("job", job); return PREFIX + "/detail"; @@ -98,7 +98,7 @@ public String detail(@PathVariable("jobId") long jobId, ModelMap mmap) { @ResponseBody public AjaxResult export(SchedJobPageRequest request) { request.setPaged(false); - List rows = supervisorAggregator.queryJobForPage(request).getRows(); + List rows = supervisorOpenapiService.queryJobForPage(request).getRows(); List list = Collects.convert(rows, SchedJobExport::ofSchedJobResponse); ExcelUtil excel = new ExcelUtil<>(SchedJobExport.class); return excel.exportExcel(list, "调度配置数据"); @@ -121,7 +121,7 @@ public String add(ModelMap mmap) { @RequiresPermissions(PERMISSION_OPERATE) @GetMapping("/copy/{id}") public String copy(@PathVariable("id") long jobId, ModelMap mmap) { - return toAdd(supervisorAggregator.getJob(jobId), mmap); + return toAdd(supervisorOpenapiService.getJob(jobId), mmap); } private String toAdd(SchedJobResponse job, ModelMap mmap) { @@ -138,7 +138,7 @@ private String toAdd(SchedJobResponse job, ModelMap mmap) { @ResponseBody public AjaxResult doAdd(AddSchedJobRequest req) throws JobException { req.setCreatedBy(getLoginName()); - supervisorAggregator.addJob(req); + supervisorOpenapiService.addJob(req); return success(); } @@ -148,7 +148,7 @@ public AjaxResult doAdd(AddSchedJobRequest req) throws JobException { @RequiresPermissions(PERMISSION_OPERATE) @GetMapping("/edit/{id}") public String edit(@PathVariable("id") long jobId, ModelMap mmap) { - SchedJobResponse job = supervisorAggregator.getJob(jobId); + SchedJobResponse job = supervisorOpenapiService.getJob(jobId); Assert.notNull(job, () -> "Job id not found: " + jobId); mmap.put("job", job); return PREFIX + "/edit"; @@ -163,7 +163,7 @@ public String edit(@PathVariable("id") long jobId, ModelMap mmap) { @ResponseBody public AjaxResult doEdit(UpdateSchedJobRequest req) throws JobException { req.setUpdatedBy(getLoginName()); - supervisorAggregator.updateJob(req); + supervisorOpenapiService.updateJob(req); return success(); } @@ -182,7 +182,7 @@ public AjaxResult remove(@RequestParam("ids") String ids) { if (jobIds.isEmpty()) { return error("Job id不能为空"); } - jobIds.parallelStream().forEach(supervisorAggregator::deleteJob); + jobIds.parallelStream().forEach(supervisorOpenapiService::deleteJob); return success(); } @@ -195,7 +195,7 @@ public AjaxResult remove(@RequestParam("ids") String ids) { @ResponseBody public AjaxResult changeState(@RequestParam("jobId") long jobId, @RequestParam("toState") Integer toState) { - boolean result = supervisorAggregator.changeJobState(jobId, toState); + boolean result = supervisorOpenapiService.changeJobState(jobId, toState); return toAjax(result); } @@ -207,7 +207,7 @@ public AjaxResult changeState(@RequestParam("jobId") long jobId, @PostMapping("/trigger") @ResponseBody public AjaxResult trigger(@RequestParam("jobId") long jobId) throws JobException { - supervisorAggregator.triggerJob(jobId); + supervisorOpenapiService.triggerJob(jobId); return success(); } diff --git a/disjob-common/src/main/java/cn/ponfee/disjob/common/spring/JdbcTemplateWrapper.java b/disjob-common/src/main/java/cn/ponfee/disjob/common/spring/JdbcTemplateWrapper.java index c98c5a775..19a414444 100644 --- a/disjob-common/src/main/java/cn/ponfee/disjob/common/spring/JdbcTemplateWrapper.java +++ b/disjob-common/src/main/java/cn/ponfee/disjob/common/spring/JdbcTemplateWrapper.java @@ -129,7 +129,8 @@ public T executeInTransaction(ThrowingFunction>> 4]; charArray[++i] = HEX_LOWER_CODES[ 0x0F & b ]; } - public static String hexEncode(byte b, boolean lowercase) { + public static String encodeHex(byte b, boolean lowercase) { char[] codes = lowercase ? HEX_LOWER_CODES : HEX_UPPER_CODES; return new String(new char[] { codes[(0xF0 & b) >>> 4], codes[0x0F & b] }); } - public static String hexEncode(byte[] bytes) { - return hexEncode(bytes, true); + public static String encodeHex(byte[] bytes) { + return encodeHex(bytes, true); } /** @@ -52,13 +52,11 @@ public static String hexEncode(byte[] bytes) { * @param lowercase the boolean * @return string */ - public static String hexEncode(byte[] bytes, boolean lowercase) { + public static String encodeHex(byte[] bytes, boolean lowercase) { //new BigInteger(1, bytes).toString(16); int len = bytes.length; char[] out = new char[len << 1]; - char[] codes = lowercase ? HEX_LOWER_CODES : HEX_UPPER_CODES; - // one byte -> two char for (int i = 0, j = 0; i < len; i++) { out[j++] = codes[(0xF0 & bytes[i]) >>> 4]; @@ -68,23 +66,22 @@ public static String hexEncode(byte[] bytes, boolean lowercase) { } /** - * decode the hex string to byte array + * Decode hex string to byte array * - * @param hex - * @return + * @param hex the hex string + * @return byte array */ - public static byte[] hexDecode(String hex) { - char[] data = hex.toCharArray(); - int len = data.length; + public static byte[] decodeHex(String hex) { + int len = hex.length(); if ((len & 0x01) == 1) { - throw new IllegalArgumentException("Invalid hex string."); + throw new IllegalArgumentException("Hex string must be twice length."); } byte[] out = new byte[len >> 1]; - // two char -> one byte for (int i = 0, j = 0; j < len; i++, j += 2) { - out[i] = (byte) ( Character.digit(data[j], 16) << 4 | Character.digit(data[j + 1], 16) ); + char c1 = hex.charAt(j), c2 = hex.charAt(j + 1); + out[i] = (byte) (Character.digit(c1, 16) << 4 | Character.digit(c2, 16)); } return out; } @@ -173,6 +170,7 @@ public static byte[] toBytes(char[] chars, Charset charset) { } // -----------------------------------------------------------------char + public static byte[] toBytes(char value) { return new byte[]{(byte) (value >>> 8), (byte) value}; } @@ -189,6 +187,7 @@ public static char toChar(byte[] bytes, int fromIdx) { } // -----------------------------------------------------------------int + public static byte[] toBytes(int value) { byte[] bytes = new byte[4]; put(value, bytes, 0); diff --git a/disjob-common/src/main/java/cn/ponfee/disjob/common/util/ClassUtils.java b/disjob-common/src/main/java/cn/ponfee/disjob/common/util/ClassUtils.java index 6d6563c78..7bcde4ac8 100644 --- a/disjob-common/src/main/java/cn/ponfee/disjob/common/util/ClassUtils.java +++ b/disjob-common/src/main/java/cn/ponfee/disjob/common/util/ClassUtils.java @@ -242,6 +242,7 @@ public static String getPackagePath(Class clazz) { } // -----------------------------------------------------------------------------constructor & instance + @SuppressWarnings("unchecked") public static Constructor getConstructor(Class type, Class... parameterTypes) { boolean noArgs = ArrayUtils.isEmpty(parameterTypes); @@ -320,6 +321,7 @@ public static T newInstance(Class type, Object[] args) { } // -------------------------------------------------------------------------------------------method & invoke + public static Method getMethod(Object caller, String methodName, Class... parameterTypes) { Tuple2, Predicates> tuple = obtainClass(caller); Class type = tuple.a; @@ -572,4 +574,5 @@ private static String toString(Class[] parameterTypes) { ? "()" : "(" + Joiner.on(", ").join(parameterTypes) + ")"; } + } diff --git a/disjob-common/src/main/java/cn/ponfee/disjob/common/util/Numbers.java b/disjob-common/src/main/java/cn/ponfee/disjob/common/util/Numbers.java index 06ce87714..a026cb4b0 100644 --- a/disjob-common/src/main/java/cn/ponfee/disjob/common/util/Numbers.java +++ b/disjob-common/src/main/java/cn/ponfee/disjob/common/util/Numbers.java @@ -52,6 +52,7 @@ public final class Numbers { public static final byte ZERO_BYTE = 0x00; // --------------------------------------------------------------character convert + public static char toChar(Object obj) { return toChar(obj, Char.ZERO); } @@ -79,6 +80,7 @@ public static Character toWrapChar(Object obj) { } // -----------------------------------------------------------------boolean convert + public static boolean toBoolean(Object obj) { return toBoolean(obj, false); } @@ -101,6 +103,7 @@ public static Boolean toWrapBoolean(Object obj) { } // -----------------------------------------------------------------byte convert + public static byte toByte(Object obj) { return toByte(obj, (byte) 0); } @@ -125,6 +128,7 @@ public static Byte toWrapByte(Object obj) { } // -----------------------------------------------------------------short convert + public static short toShort(Object obj) { return toShort(obj, (short) 0); } @@ -149,6 +153,7 @@ public static Short toWrapShort(Object obj) { } // -----------------------------------------------------------------int convert + public static int toInt(Object obj) { return toInt(obj, 0); } @@ -173,6 +178,7 @@ public static Integer toWrapInt(Object obj) { } // -----------------------------------------------------------------long convert + public static long toLong(Object obj) { return toLong(obj, 0L); } @@ -196,6 +202,7 @@ public static Long toWrapLong(Object obj) { } // -----------------------------------------------------------------float convert + public static float toFloat(Object obj) { return toFloat(obj, 0.0F); } @@ -220,6 +227,7 @@ public static Float toWrapFloat(Object obj) { } // -----------------------------------------------------------------double convert + public static double toDouble(Object obj) { return toDouble(obj, 0.0D); } @@ -243,12 +251,13 @@ public static Double toWrapDouble(Object obj) { } // ---------------------------------------------------------------------number format + /** - * 数字精度化 + * 数字精度 * - * @param value - * @param scale - * @return + * @param value the number value + * @param scale the scale + * @return double value */ public static double scale(Object value, int scale) { double val = toDouble(value); @@ -265,9 +274,9 @@ public static double scale(Object value, int scale) { /** * 向下转单位 * - * @param value - * @param pow - * @return + * @param value the number value + * @param pow the pow + * @return double value */ public static double lower(double value, int pow) { return BigDecimal.valueOf(value / Math.pow(10, pow)).doubleValue(); @@ -445,9 +454,9 @@ public static double sum(Double a, Double b) { * slice(12, 3) -> [4, 4, 4] * * - * @param quantity - * @param segment - * @return + * @param quantity the quantity + * @param segment the segment + * @return int array */ public static int[] slice(int quantity, int segment) { int[] result = new int[segment]; @@ -569,6 +578,7 @@ public static String toHex(BigInteger num) { } // -------------------------------------------------------private methods + private static Long parseLong(Object obj) { if (obj == null) { return null; @@ -593,4 +603,5 @@ private static Double parseDouble(Object obj) { return null; } } + } diff --git a/disjob-common/src/main/java/cn/ponfee/disjob/common/util/UuidUtils.java b/disjob-common/src/main/java/cn/ponfee/disjob/common/util/UuidUtils.java index d0ddf1a54..ddd8e072b 100644 --- a/disjob-common/src/main/java/cn/ponfee/disjob/common/util/UuidUtils.java +++ b/disjob-common/src/main/java/cn/ponfee/disjob/common/util/UuidUtils.java @@ -18,11 +18,10 @@ */ public final class UuidUtils { - /** - * uuid byte array + * Returns 16 length byte array uuid * - * @return + * @return 16 length uuid byte array */ public static byte[] uuid() { UUID uuid = UUID.randomUUID(); @@ -33,20 +32,20 @@ public static byte[] uuid() { } /** - * uuid 32 string + * Returns 32 length string uuid, use hex encoding * - * @return 32 length uuid + * @return 32 length uuid string */ public static String uuid32() { UUID uuid = UUID.randomUUID(); - return Bytes.toHex(uuid.getMostSignificantBits(), true) - + Bytes.toHex(uuid.getLeastSignificantBits(), true); + return Bytes.toHex(uuid.getMostSignificantBits(), true) + + Bytes.toHex(uuid.getLeastSignificantBits(), true); } /** - * 22位uuid + * Returns 22 length string uuid, use base64 url encoding and without padding * - * @return 22 length uuid + * @return 22 length uuid string */ public static String uuid22() { return Base64.getUrlEncoder().withoutPadding().encodeToString(uuid()); diff --git a/disjob-common/src/test/java/cn/ponfee/disjob/common/date/DatePeriodsTest.java b/disjob-common/src/test/java/cn/ponfee/disjob/common/date/DatePeriodsTest.java index 644a4443b..d4aa3de8c 100644 --- a/disjob-common/src/test/java/cn/ponfee/disjob/common/date/DatePeriodsTest.java +++ b/disjob-common/src/test/java/cn/ponfee/disjob/common/date/DatePeriodsTest.java @@ -100,6 +100,6 @@ public void test() throws DecoderException { System.out.println(number); System.out.println(Long.toHexString(number)); Assertions.assertEquals("cb703fbc86a41b0", Long.toHexString(number)); - Assertions.assertEquals("0cb703fbc86a41b0", Bytes.hexEncode(Bytes.toBytes(number))); + Assertions.assertEquals("0cb703fbc86a41b0", Bytes.encodeHex(Bytes.toBytes(number))); } } diff --git a/disjob-common/src/test/java/cn/ponfee/disjob/common/util/BytesTest.java b/disjob-common/src/test/java/cn/ponfee/disjob/common/util/BytesTest.java new file mode 100644 index 000000000..762c69461 --- /dev/null +++ b/disjob-common/src/test/java/cn/ponfee/disjob/common/util/BytesTest.java @@ -0,0 +1,49 @@ +/* __________ _____ *\ +** \______ \____ _____/ ____\____ ____ Copyright (c) 2017-2023 Ponfee ** +** | ___/ _ \ / \ __\/ __ \_/ __ \ http://www.ponfee.cn ** +** | | ( <_> ) | \ | \ ___/\ ___/ Apache License Version 2.0 ** +** |____| \____/|___| /__| \___ >\___ > http://www.apache.org/licenses/ ** +** \/ \/ \/ ** +\* */ + +package cn.ponfee.disjob.common.util; + +import com.google.common.primitives.Longs; +import org.apache.commons.codec.binary.Hex; +import org.apache.commons.lang3.RandomUtils; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.concurrent.ThreadLocalRandom; + +/** + * Bytes test + * + * @author Ponfee + */ +public class BytesTest { + + @Test + public void testEncodeHex() { + for (int i = 0; i < 1000; i++) { + byte[] bytes1 = RandomUtils.nextBytes(ThreadLocalRandom.current().nextInt(100) + 1); + String s1 = Bytes.encodeHex(bytes1); + String s2 = Hex.encodeHexString(bytes1); + Assertions.assertEquals(s1, s2); + byte[] bytes2 = Bytes.decodeHex(s1); + Assertions.assertArrayEquals(bytes1, bytes2); + } + } + + @Test + public void testToHexString() { + for (int i = 0; i < 1000; i++) { + long value = ThreadLocalRandom.current().nextLong(); + byte[] bytes1 = Bytes.toBytes(value); + byte[] bytes2 = Longs.toByteArray(value); + Assertions.assertArrayEquals(bytes1, bytes2); + Assertions.assertEquals(value, Bytes.toLong(bytes1)); + } + } + +} diff --git a/disjob-core/src/main/java/cn/ponfee/disjob/core/base/Supervisor.java b/disjob-core/src/main/java/cn/ponfee/disjob/core/base/Supervisor.java index 763477fb2..6c76d6f83 100644 --- a/disjob-core/src/main/java/cn/ponfee/disjob/core/base/Supervisor.java +++ b/disjob-core/src/main/java/cn/ponfee/disjob/core/base/Supervisor.java @@ -40,6 +40,8 @@ public class Supervisor extends Server { public Supervisor(String host, int port) { super(host, port); + + Assert.isTrue(!host.contains(COLON), "Host cannot contains symbol ':'"); this.serializedValue = host + COLON + port; } @@ -118,7 +120,7 @@ public Supervisor deserialize(JsonParser p, DeserializationContext ctx) throws I */ public static abstract class Current extends Supervisor { private static final long serialVersionUID = -239845054171219365L; - private static volatile Current instance; + private static volatile Current instance = null; private Current(String host, int port) { super(host, port); diff --git a/disjob-core/src/main/java/cn/ponfee/disjob/core/base/Worker.java b/disjob-core/src/main/java/cn/ponfee/disjob/core/base/Worker.java index f857653f4..73f32fc7b 100644 --- a/disjob-core/src/main/java/cn/ponfee/disjob/core/base/Worker.java +++ b/disjob-core/src/main/java/cn/ponfee/disjob/core/base/Worker.java @@ -69,8 +69,9 @@ public class Worker extends Server { public Worker(String group, String workerId, String host, int port) { super(host, port); + Assert.isTrue(!group.contains(COLON), "Group cannot contains symbol ':'"); Assert.isTrue(!workerId.contains(COLON), "Worker id cannot contains symbol ':'"); - Assert.isTrue(!group.contains(COLON), "Group name cannot contains symbol ':'"); + Assert.isTrue(!host.contains(COLON), "Host cannot contains symbol ':'"); this.group = Strings.requireNonBlank(group.trim()); this.workerId = workerId; @@ -194,7 +195,7 @@ public Worker deserialize(JsonParser p, DeserializationContext ctx) throws IOExc public static abstract class Current extends Worker { private static final long serialVersionUID = -480329874106279202L; - private static volatile Current instance; + private static volatile Current instance = null; private Current(String group, String workerId, String host, int port) { super(group, workerId, host, port); diff --git a/disjob-dispatch/disjob-dispatch-api/src/main/java/cn/ponfee/disjob/dispatch/TaskDispatcher.java b/disjob-dispatch/disjob-dispatch-api/src/main/java/cn/ponfee/disjob/dispatch/TaskDispatcher.java index b574ad130..26fa77160 100644 --- a/disjob-dispatch/disjob-dispatch-api/src/main/java/cn/ponfee/disjob/dispatch/TaskDispatcher.java +++ b/disjob-dispatch/disjob-dispatch-api/src/main/java/cn/ponfee/disjob/dispatch/TaskDispatcher.java @@ -176,7 +176,7 @@ private void assignWorker(List params) { private void doDispatch(ExecuteTaskParam task) throws Exception { boolean result; - if (timingWheel != null && Worker.current().equals(task.getWorker())) { + if (timingWheel != null && task.getWorker().equals(Worker.current())) { // if the server both is supervisor & worker: dispatch to local worker log.info("Dispatching task to local worker {} | {} | {}", task.getTaskId(), task.getOperation(), task.getWorker()); result = timingWheel.offer(task); diff --git a/disjob-registry/disjob-registry-api/src/main/java/cn/ponfee/disjob/registry/DiscoveryRestProxy.java b/disjob-registry/disjob-registry-api/src/main/java/cn/ponfee/disjob/registry/DiscoveryRestProxy.java index 55f9ee0bd..6a87f9fd4 100644 --- a/disjob-registry/disjob-registry-api/src/main/java/cn/ponfee/disjob/registry/DiscoveryRestProxy.java +++ b/disjob-registry/disjob-registry-api/src/main/java/cn/ponfee/disjob/registry/DiscoveryRestProxy.java @@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import java.lang.invoke.MethodHandle; +import java.lang.reflect.AnnotatedElement; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; @@ -42,7 +43,7 @@ * } * } * - *

{Alias for annotation: @link AnnotatedElementUtils#findMergedAnnotation(AnnotatedElement, Class)} + *

Alias for annotation: {@link AnnotatedElementUtils#findMergedAnnotation(AnnotatedElement, Class)} *

{@code
  *   public @interface PostMapping {
  *     @AliasFor(annotation = RequestMapping.class)
diff --git a/disjob-samples/disjob-samples-frameless-worker/src/main/java/cn/ponfee/disjob/samples/worker/util/JobHandlerParser.java b/disjob-samples/disjob-samples-frameless-worker/src/main/java/cn/ponfee/disjob/samples/worker/util/JobHandlerParser.java
index deb9183fe..bf687e722 100644
--- a/disjob-samples/disjob-samples-frameless-worker/src/main/java/cn/ponfee/disjob/samples/worker/util/JobHandlerParser.java
+++ b/disjob-samples/disjob-samples-frameless-worker/src/main/java/cn/ponfee/disjob/samples/worker/util/JobHandlerParser.java
@@ -10,6 +10,7 @@
 
 import cn.ponfee.disjob.common.spring.ResourceScanner;
 import cn.ponfee.disjob.common.util.Fields;
+import cn.ponfee.disjob.common.util.Files;
 import cn.ponfee.disjob.core.handle.JobHandler;
 import cn.ponfee.disjob.core.handle.JobHandlerUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -22,7 +23,9 @@
 import java.beans.Introspector;
 import java.lang.reflect.Modifier;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * Job handler parser
@@ -58,7 +61,23 @@ public class JobHandlerParser {
     }
 
     public static void init() {
-        JOB_HANDLER_MAP.size();
+        String ls = Files.SYSTEM_LINE_SEPARATOR;
+        StringBuilder builder = new StringBuilder(ls);
+        List list = JOB_HANDLER_MAP
+            .entrySet()
+            .stream()
+            .map(e -> "|   " + e.getKey() + " -> " + e.getValue().getName())
+            .collect(Collectors.toList());
+        int maxLen = list.stream().mapToInt(String::length).max().getAsInt();
+
+        builder.append(StringUtils.rightPad("/", maxLen + 1, "-")).append("\\").append(ls);
+        builder.append(StringUtils.rightPad("| Job handler map:", maxLen, " ")).append(" |").append(ls);
+
+        list.forEach(e -> builder.append(StringUtils.rightPad(e, maxLen, " ")).append(" |").append(ls));
+
+        builder.append(StringUtils.rightPad("\\", maxLen + 1, "-")).append("/").append(ls);
+
+        System.out.println(builder);
     }
 
     /**
diff --git a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/auth/AuthenticationConfigurer.java b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/auth/AuthenticationConfigurer.java
index 3bc6f64b7..5f43fec77 100644
--- a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/auth/AuthenticationConfigurer.java
+++ b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/auth/AuthenticationConfigurer.java
@@ -10,7 +10,7 @@
 
 import cn.ponfee.disjob.core.base.JobConstants;
 import cn.ponfee.disjob.core.exception.AuthenticationException;
-import cn.ponfee.disjob.supervisor.service.SchedGroupManager;
+import cn.ponfee.disjob.supervisor.service.SchedGroupService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.core.Ordered;
 import org.springframework.web.method.HandlerMethod;
@@ -41,8 +41,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
                 return true;
             }
 
-            Class beanType = ((HandlerMethod) handler).getBeanType();
-            SupervisorAuthentication annotation = beanType.getAnnotation(SupervisorAuthentication.class);
+            SupervisorAuthentication annotation = getAnnotation((HandlerMethod) handler);
             if (annotation == null) {
                 return true;
             }
@@ -67,7 +66,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
         }
 
         private static void authenticateWorker(HttpServletRequest request, String group) {
-            String workerToken = SchedGroupManager.get(group).getWorkerToken();
+            String workerToken = SchedGroupService.get(group).getWorkerToken();
             if (StringUtils.isBlank(workerToken)) {
                 return;
             }
@@ -79,7 +78,7 @@ private static void authenticateWorker(HttpServletRequest request, String group)
         }
 
         private static void authenticateUser(HttpServletRequest request, String group) {
-            String userToken = SchedGroupManager.get(group).getUserToken();
+            String userToken = SchedGroupService.get(group).getUserToken();
             if (StringUtils.isBlank(userToken)) {
                 return;
             }
@@ -89,6 +88,11 @@ private static void authenticateUser(HttpServletRequest request, String group) {
                 throw new AuthenticationException("Authenticate failed.");
             }
         }
+
+        private static SupervisorAuthentication getAnnotation(HandlerMethod hm) {
+            SupervisorAuthentication a = hm.getMethodAnnotation(SupervisorAuthentication.class);
+            return a != null ? a : hm.getBeanType().getAnnotation(SupervisorAuthentication.class);
+        }
     }
 
 }
diff --git a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/auth/SupervisorAuthentication.java b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/auth/SupervisorAuthentication.java
index 74eb26fd7..d134e54fb 100644
--- a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/auth/SupervisorAuthentication.java
+++ b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/auth/SupervisorAuthentication.java
@@ -16,7 +16,7 @@
  * @author Ponfee
  */
 @Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
+@Target({ElementType.TYPE, ElementType.METHOD})
 @Documented
 public @interface SupervisorAuthentication {
 
diff --git a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/base/WorkerRpcClient.java b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/base/WorkerRpcClient.java
index e0139230b..20424e57f 100644
--- a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/base/WorkerRpcClient.java
+++ b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/base/WorkerRpcClient.java
@@ -19,7 +19,7 @@
 import cn.ponfee.disjob.registry.DiscoveryRestProxy;
 import cn.ponfee.disjob.registry.DiscoveryRestTemplate;
 import cn.ponfee.disjob.registry.SupervisorRegistry;
-import cn.ponfee.disjob.supervisor.service.SchedGroupManager;
+import cn.ponfee.disjob.supervisor.service.SchedGroupService;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 import javax.annotation.Nullable;
@@ -58,12 +58,12 @@ public WorkerRpcClient(HttpProperties httpProperties,
     }
 
     public void verify(JobHandlerParam param) throws JobException {
-        param.setSupervisorToken(SchedGroupManager.get(param.getGroup()).getSupervisorToken());
+        param.setSupervisorToken(SchedGroupService.get(param.getGroup()).getSupervisorToken());
         grouped(param.getGroup()).verify(param);
     }
 
     public List split(JobHandlerParam param) throws JobException {
-        param.setSupervisorToken(SchedGroupManager.get(param.getGroup()).getSupervisorToken());
+        param.setSupervisorToken(SchedGroupService.get(param.getGroup()).getSupervisorToken());
         return grouped(param.getGroup()).split(param);
     }
 
diff --git a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/provider/openapi/SupervisorOpenapiProvider.java b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/provider/openapi/SupervisorOpenapiProvider.java
index 9204eb54f..f1084f037 100644
--- a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/provider/openapi/SupervisorOpenapiProvider.java
+++ b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/provider/openapi/SupervisorOpenapiProvider.java
@@ -20,7 +20,7 @@
 import cn.ponfee.disjob.supervisor.provider.openapi.response.SchedInstanceResponse;
 import cn.ponfee.disjob.supervisor.provider.openapi.response.SchedJobResponse;
 import cn.ponfee.disjob.supervisor.provider.openapi.response.SchedTaskResponse;
-import cn.ponfee.disjob.supervisor.service.SupervisorAggregator;
+import cn.ponfee.disjob.supervisor.service.SupervisorOpenapiService;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.web.bind.annotation.*;
 
@@ -37,47 +37,47 @@
 @SupervisorAuthentication(SupervisorAuthentication.Subject.USER)
 public class SupervisorOpenapiProvider extends BaseController {
 
-    private final SupervisorAggregator supervisorAggregator;
+    private final SupervisorOpenapiService supervisorOpenapiService;
 
-    public SupervisorOpenapiProvider(SupervisorAggregator supervisorAggregator) {
-        this.supervisorAggregator = supervisorAggregator;
+    public SupervisorOpenapiProvider(SupervisorOpenapiService supervisorOpenapiService) {
+        this.supervisorOpenapiService = supervisorOpenapiService;
     }
 
     // ------------------------------------------------------------------job
 
     @PostMapping("job/add")
     public Result addJob(@RequestBody AddSchedJobRequest req) throws JobException {
-        supervisorAggregator.addJob(req);
+        supervisorOpenapiService.addJob(req);
         return Result.success();
     }
 
     @PutMapping("job/update")
     public Result updateJob(@RequestBody UpdateSchedJobRequest req) throws JobException {
-        supervisorAggregator.updateJob(req);
+        supervisorOpenapiService.updateJob(req);
         return Result.success();
     }
 
     @DeleteMapping("job/delete")
     public Result deleteJob(@RequestParam("jobId") long jobId) {
-        supervisorAggregator.deleteJob(jobId);
+        supervisorOpenapiService.deleteJob(jobId);
         return Result.success();
     }
 
     @PostMapping("job/state/change")
     public Result changeJobState(@RequestParam("jobId") long jobId,
                                           @RequestParam("jobState") int jobState) {
-        return Result.success(supervisorAggregator.changeJobState(jobId, jobState));
+        return Result.success(supervisorOpenapiService.changeJobState(jobId, jobState));
     }
 
     @PostMapping("job/trigger")
     public Result triggerJob(@RequestParam("jobId") long jobId) throws JobException {
-        supervisorAggregator.triggerJob(jobId);
+        supervisorOpenapiService.triggerJob(jobId);
         return Result.success();
     }
 
     @GetMapping("job/get")
     public Result getJob(@RequestParam("jobId") long jobId) {
-        return Result.success(supervisorAggregator.getJob(jobId));
+        return Result.success(supervisorOpenapiService.getJob(jobId));
     }
 
     /**
@@ -90,51 +90,51 @@ public Result getJob(@RequestParam("jobId") long jobId) {
      */
     @GetMapping("job/page")
     public Result> queryJobForPage(SchedJobPageRequest pageRequest) {
-        return Result.success(supervisorAggregator.queryJobForPage(pageRequest));
+        return Result.success(supervisorOpenapiService.queryJobForPage(pageRequest));
     }
 
     // ------------------------------------------------------------------ sched instance
 
     @PostMapping("instance/pause")
     public Result pauseInstance(@RequestParam("instanceId") long instanceId) {
-        supervisorAggregator.pauseInstance(instanceId);
+        supervisorOpenapiService.pauseInstance(instanceId);
         return Result.success();
     }
 
     @PostMapping("instance/cancel")
     public Result cancelInstance(@RequestParam("instanceId") long instanceId) {
-        supervisorAggregator.cancelInstance(instanceId);
+        supervisorOpenapiService.cancelInstance(instanceId);
         return Result.success();
     }
 
     @PostMapping("instance/resume")
     public Result resumeInstance(@RequestParam("instanceId") long instanceId) {
-        supervisorAggregator.resumeInstance(instanceId);
+        supervisorOpenapiService.resumeInstance(instanceId);
         return Result.success();
     }
 
     @DeleteMapping("instance/delete")
     public Result deleteInstance(@RequestParam("instanceId") long instanceId) {
-        supervisorAggregator.deleteInstance(instanceId);
+        supervisorOpenapiService.deleteInstance(instanceId);
         return Result.success();
     }
 
     @PostMapping("instance/state/change")
     public Result changeInstanceState(@RequestParam("instanceId") long instanceId,
                                             @RequestParam("targetExecuteState") int targetExecuteState) {
-        supervisorAggregator.changeInstanceState(instanceId, targetExecuteState);
+        supervisorOpenapiService.changeInstanceState(instanceId, targetExecuteState);
         return Result.success();
     }
 
     @GetMapping("instance/get")
     public Result getInstance(@RequestParam(value = "instanceId") long instanceId,
                                                      @RequestParam(value = "withTasks", defaultValue = "false") boolean withTasks) {
-        return Result.success(supervisorAggregator.getInstance(instanceId, withTasks));
+        return Result.success(supervisorOpenapiService.getInstance(instanceId, withTasks));
     }
 
     @GetMapping("instance/tasks")
     public Result> getInstanceTasks(@RequestParam("instanceId") long instanceId) {
-        return Result.success(supervisorAggregator.getInstanceTasks(instanceId));
+        return Result.success(supervisorOpenapiService.getInstanceTasks(instanceId));
     }
 
     /**
@@ -147,12 +147,12 @@ public Result> getInstanceTasks(@RequestParam("instanceI
      */
     @GetMapping("instance/page")
     public Result> queryInstanceForPage(SchedInstancePageRequest pageRequest) {
-        return Result.success(supervisorAggregator.queryInstanceForPage(pageRequest));
+        return Result.success(supervisorOpenapiService.queryInstanceForPage(pageRequest));
     }
 
     @GetMapping("instance/children")
     public Result> listInstanceChildren(@RequestParam("pnstanceId") long pnstanceId) {
-        return Result.success(supervisorAggregator.listInstanceChildren(pnstanceId));
+        return Result.success(supervisorOpenapiService.listInstanceChildren(pnstanceId));
     }
 
 }
diff --git a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/AbstractJobManager.java b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/AbstractJobManager.java
index 9c342952c..355c62681 100644
--- a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/AbstractJobManager.java
+++ b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/AbstractJobManager.java
@@ -47,7 +47,7 @@
 import static cn.ponfee.disjob.supervisor.dao.SupervisorDataSourceConfig.DB_NAME;
 
 /**
- * The base job manager
+ * Abstract job manager
  *
  * @author Ponfee
  */
@@ -249,7 +249,7 @@ public boolean hasNotDiscoveredWorkers() {
     }
 
     public boolean dispatch(SchedJob job, SchedInstance instance, List tasks) {
-        String supervisorToken = SchedGroupManager.get(job.getGroup()).getSupervisorToken();
+        String supervisorToken = SchedGroupService.get(job.getGroup()).getSupervisorToken();
         ExecuteTaskParam.Builder builder = ExecuteTaskParam.builder(instance, job, supervisorToken);
         List list;
         if (RouteStrategy.BROADCAST.equals(job.getRouteStrategy())) {
diff --git a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/DistributedJobManager.java b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/DistributedJobManager.java
index bdf273850..eb9226ac5 100644
--- a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/DistributedJobManager.java
+++ b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/DistributedJobManager.java
@@ -892,7 +892,7 @@ private void dependJob(SchedInstance parentInstance) {
     private List loadExecutingTasks(SchedInstance instance, Operations ops) {
         List executingTasks = new ArrayList<>();
         SchedJob schedJob = LazyLoader.of(SchedJob.class, jobMapper::get, instance.getJobId());
-        String supervisorToken = SchedGroupManager.get(schedJob.getGroup()).getSupervisorToken();
+        String supervisorToken = SchedGroupService.get(schedJob.getGroup()).getSupervisorToken();
         ExecuteTaskParam.Builder builder = ExecuteTaskParam.builder(instance, schedJob, supervisorToken);
         // immediate trigger
         long triggerTime = 0L;
diff --git a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/SchedGroupManager.java b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/SchedGroupService.java
similarity index 97%
rename from disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/SchedGroupManager.java
rename to disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/SchedGroupService.java
index f760c896a..803d3e5a1 100644
--- a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/SchedGroupManager.java
+++ b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/SchedGroupService.java
@@ -29,12 +29,12 @@
 import static cn.ponfee.disjob.supervisor.base.SupervisorConstants.AFFECTED_ONE_ROW;
 
 /**
- * Sched group manager
+ * Sched group service
  *
  * @author Ponfee
  */
 @Component
-public class SchedGroupManager extends SingletonClassConstraint implements Closeable, DisposableBean {
+public class SchedGroupService extends SingletonClassConstraint implements Closeable, DisposableBean {
 
     private static final Lock LOCK = new ReentrantLock();
     private static volatile Map all;
@@ -42,7 +42,7 @@ public class SchedGroupManager extends SingletonClassConstraint implements Close
     private final SchedGroupMapper schedGroupMapper;
     private final LoopThread refresher;
 
-    public SchedGroupManager(SchedGroupMapper schedGroupMapper) {
+    public SchedGroupService(SchedGroupMapper schedGroupMapper) {
         this.schedGroupMapper = schedGroupMapper;
         this.refresher = new LoopThread("group_metadata_refresher", 30, 30, this::refresh);
         refresh();
diff --git a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/SupervisorAggregator.java b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/SupervisorOpenapiService.java
similarity index 95%
rename from disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/SupervisorAggregator.java
rename to disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/SupervisorOpenapiService.java
index 905aafb15..b152c8a94 100644
--- a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/SupervisorAggregator.java
+++ b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/service/SupervisorOpenapiService.java
@@ -34,20 +34,20 @@
 import java.util.stream.Collectors;
 
 /**
- * Supervisor aggregator.
+ * Supervisor openapi service.
  *
  * @author Ponfee
  */
 @Component
-public class SupervisorAggregator {
+public class SupervisorOpenapiService {
 
-    protected static final Logger LOG = LoggerFactory.getLogger(SupervisorAggregator.class);
+    private static final Logger LOG = LoggerFactory.getLogger(SupervisorOpenapiService.class);
 
     private final DistributedJobManager jobManager;
     private final DistributedJobQuerier jobQuerier;
 
-    public SupervisorAggregator(DistributedJobManager jobManager,
-                                DistributedJobQuerier jobQuerier) {
+    public SupervisorOpenapiService(DistributedJobManager jobManager,
+                                    DistributedJobQuerier jobQuerier) {
         this.jobManager = jobManager;
         this.jobQuerier = jobQuerier;
     }
diff --git a/disjob-worker/src/main/java/cn/ponfee/disjob/worker/WorkerStartup.java b/disjob-worker/src/main/java/cn/ponfee/disjob/worker/WorkerStartup.java
index 8dbaac631..95b6f60ff 100644
--- a/disjob-worker/src/main/java/cn/ponfee/disjob/worker/WorkerStartup.java
+++ b/disjob-worker/src/main/java/cn/ponfee/disjob/worker/WorkerStartup.java
@@ -187,8 +187,8 @@ private static SupervisorRpcService createProxy(SupervisorRpcService local,
                                                     WorkerRegistry workerRegistry,
                                                     ObjectMapper objectMapper) {
         if (local != null) {
-            // 此Worker同时也是Supervisor身份,则本地调用:cn.ponfee.disjob.supervisor.provider.rpc.SupervisorRpcProvider
-            // 使用动态代理增加重试能力
+            // cn.ponfee.disjob.supervisor.provider.rpc.SupervisorRpcProvider
+            // 此Worker同时也是Supervisor身份,则是本地调用,并使用动态代理增加重试能力
             InvocationHandler ih = new RetryInvocationHandler(local, retry.getMaxCount(), retry.getBackoffPeriod());
             return ProxyUtils.create(SupervisorRpcService.class, ih);
         } else {