diff --git "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" index 86f4719..2fe2fa5 100644 --- "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" +++ "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" @@ -998,14 +998,14 @@ ### 5.12 执行器API服务 执行器提供了API服务,供调度中心选择使用,目前提供的API服务有: - 1、心跳检测 - 2、忙碌检测 - 3、触发任务执行 - 4、获取Rolling Log - 5、终止任务 + 1、心跳检测:调度中心使用 + 2、忙碌检测:调度中心使用 + 3、触发任务执行:调度中心使用;本地进行任务开发时,可使用该API服务模拟触发任务; + 4、获取Rolling Log:调度中心使用 + 5、终止任务:调度中心使用 API服务位置:com.xxl.job.core.biz.ExecutorBiz -API服务请求参考代码:com.xxl.executor.test.DemoJobHandlerTest +API服务请求参考代码:com.xxl.job.executor.ExecutorBizTest ### 5.13 故障转移 & 失败重试 一次完整任务流程包括"调度(调度中心) + 执行(执行器)"两个阶段。 diff --git "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" index 86f4719..2fe2fa5 100644 --- "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" +++ "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" @@ -998,14 +998,14 @@ ### 5.12 执行器API服务 执行器提供了API服务,供调度中心选择使用,目前提供的API服务有: - 1、心跳检测 - 2、忙碌检测 - 3、触发任务执行 - 4、获取Rolling Log - 5、终止任务 + 1、心跳检测:调度中心使用 + 2、忙碌检测:调度中心使用 + 3、触发任务执行:调度中心使用;本地进行任务开发时,可使用该API服务模拟触发任务; + 4、获取Rolling Log:调度中心使用 + 5、终止任务:调度中心使用 API服务位置:com.xxl.job.core.biz.ExecutorBiz -API服务请求参考代码:com.xxl.executor.test.DemoJobHandlerTest +API服务请求参考代码:com.xxl.job.executor.ExecutorBizTest ### 5.13 故障转移 & 失败重试 一次完整任务流程包括"调度(调度中心) + 执行(执行器)"两个阶段。 diff --git a/xxl-job-admin/src/test/java/com/xxl/job/executor/ExecutorBizTest.java b/xxl-job-admin/src/test/java/com/xxl/job/executor/ExecutorBizTest.java new file mode 100644 index 0000000..bf3abab --- /dev/null +++ b/xxl-job-admin/src/test/java/com/xxl/job/executor/ExecutorBizTest.java @@ -0,0 +1,56 @@ +package com.xxl.job.executor; + +import com.xxl.job.core.biz.ExecutorBiz; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.biz.model.TriggerParam; +import com.xxl.job.core.enums.ExecutorBlockStrategyEnum; +import com.xxl.job.core.glue.GlueTypeEnum; +import com.xxl.rpc.remoting.invoker.call.CallType; +import com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean; +import com.xxl.rpc.remoting.net.NetEnum; +import com.xxl.rpc.serialize.Serializer; + +/** + * executor-api client, test + * + * Created by xuxueli on 17/5/12. + */ +public class ExecutorBizTest { + + public static void main(String[] args) throws Exception { + + // param + String jobHandler = "demoJobHandler"; + String params = ""; + + runTest(jobHandler, params); + } + + /** + * run jobhandler + * + * @param jobHandler + * @param params + */ + private static void runTest(String jobHandler, String params){ + // trigger data + TriggerParam triggerParam = new TriggerParam(); + triggerParam.setJobId(1); + triggerParam.setExecutorHandler(jobHandler); + triggerParam.setExecutorParams(params); + triggerParam.setExecutorBlockStrategy(ExecutorBlockStrategyEnum.COVER_EARLY.name()); + triggerParam.setGlueType(GlueTypeEnum.BEAN.name()); + triggerParam.setGlueSource(null); + triggerParam.setGlueUpdatetime(System.currentTimeMillis()); + triggerParam.setLogId(1); + triggerParam.setLogDateTim(System.currentTimeMillis()); + + // do remote trigger + String accessToken = null; + ExecutorBiz executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC, + ExecutorBiz.class, null, 10000, "127.0.0.1:9999", null, null).getObject(); + + ReturnT runResult = executorBiz.run(triggerParam); + } + +} diff --git "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" index 86f4719..2fe2fa5 100644 --- "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" +++ "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" @@ -998,14 +998,14 @@ ### 5.12 执行器API服务 执行器提供了API服务,供调度中心选择使用,目前提供的API服务有: - 1、心跳检测 - 2、忙碌检测 - 3、触发任务执行 - 4、获取Rolling Log - 5、终止任务 + 1、心跳检测:调度中心使用 + 2、忙碌检测:调度中心使用 + 3、触发任务执行:调度中心使用;本地进行任务开发时,可使用该API服务模拟触发任务; + 4、获取Rolling Log:调度中心使用 + 5、终止任务:调度中心使用 API服务位置:com.xxl.job.core.biz.ExecutorBiz -API服务请求参考代码:com.xxl.executor.test.DemoJobHandlerTest +API服务请求参考代码:com.xxl.job.executor.ExecutorBizTest ### 5.13 故障转移 & 失败重试 一次完整任务流程包括"调度(调度中心) + 执行(执行器)"两个阶段。 diff --git a/xxl-job-admin/src/test/java/com/xxl/job/executor/ExecutorBizTest.java b/xxl-job-admin/src/test/java/com/xxl/job/executor/ExecutorBizTest.java new file mode 100644 index 0000000..bf3abab --- /dev/null +++ b/xxl-job-admin/src/test/java/com/xxl/job/executor/ExecutorBizTest.java @@ -0,0 +1,56 @@ +package com.xxl.job.executor; + +import com.xxl.job.core.biz.ExecutorBiz; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.biz.model.TriggerParam; +import com.xxl.job.core.enums.ExecutorBlockStrategyEnum; +import com.xxl.job.core.glue.GlueTypeEnum; +import com.xxl.rpc.remoting.invoker.call.CallType; +import com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean; +import com.xxl.rpc.remoting.net.NetEnum; +import com.xxl.rpc.serialize.Serializer; + +/** + * executor-api client, test + * + * Created by xuxueli on 17/5/12. + */ +public class ExecutorBizTest { + + public static void main(String[] args) throws Exception { + + // param + String jobHandler = "demoJobHandler"; + String params = ""; + + runTest(jobHandler, params); + } + + /** + * run jobhandler + * + * @param jobHandler + * @param params + */ + private static void runTest(String jobHandler, String params){ + // trigger data + TriggerParam triggerParam = new TriggerParam(); + triggerParam.setJobId(1); + triggerParam.setExecutorHandler(jobHandler); + triggerParam.setExecutorParams(params); + triggerParam.setExecutorBlockStrategy(ExecutorBlockStrategyEnum.COVER_EARLY.name()); + triggerParam.setGlueType(GlueTypeEnum.BEAN.name()); + triggerParam.setGlueSource(null); + triggerParam.setGlueUpdatetime(System.currentTimeMillis()); + triggerParam.setLogId(1); + triggerParam.setLogDateTim(System.currentTimeMillis()); + + // do remote trigger + String accessToken = null; + ExecutorBiz executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC, + ExecutorBiz.class, null, 10000, "127.0.0.1:9999", null, null).getObject(); + + ReturnT runResult = executorBiz.run(triggerParam); + } + +} diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/test/java/com/xxl/executor/test/DemoJobHandlerTest.java b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/test/java/com/xxl/executor/test/DemoJobHandlerTest.java deleted file mode 100644 index 82027a3..0000000 --- a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/test/java/com/xxl/executor/test/DemoJobHandlerTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.xxl.executor.test; - -import com.xxl.job.core.biz.ExecutorBiz; -import com.xxl.job.core.biz.model.ReturnT; -import com.xxl.job.core.biz.model.TriggerParam; -import com.xxl.job.core.enums.ExecutorBlockStrategyEnum; -import com.xxl.job.core.glue.GlueTypeEnum; -import com.xxl.rpc.remoting.invoker.call.CallType; -import com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean; -import com.xxl.rpc.remoting.net.NetEnum; -import com.xxl.rpc.serialize.Serializer; - -/** - * executor-api client, test - * - * Created by xuxueli on 17/5/12. - */ -public class DemoJobHandlerTest { - - public static void main(String[] args) throws Exception { - - // param - String jobHandler = "demoJobHandler"; - String params = ""; - - // trigger data - TriggerParam triggerParam = new TriggerParam(); - triggerParam.setJobId(1); - triggerParam.setExecutorHandler(jobHandler); - triggerParam.setExecutorParams(params); - triggerParam.setExecutorBlockStrategy(ExecutorBlockStrategyEnum.COVER_EARLY.name()); - triggerParam.setGlueType(GlueTypeEnum.BEAN.name()); - triggerParam.setGlueSource(null); - triggerParam.setGlueUpdatetime(System.currentTimeMillis()); - triggerParam.setLogId(1); - triggerParam.setLogDateTim(System.currentTimeMillis()); - - // do remote trigger - String accessToken = null; - ExecutorBiz executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC, - ExecutorBiz.class, null, 10000, "127.0.0.1:9999", null, null).getObject(); - - ReturnT runResult = executorBiz.run(triggerParam); - } - -}