心跳注册和结果回调,重试逻辑优化
This commit is contained in:
parent
f83346de2d
commit
02818b4d6b
|
@ -903,6 +903,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
|
||||||
- 4、执行器集群地址列表进行自然排序;
|
- 4、执行器集群地址列表进行自然排序;
|
||||||
- 5、调度中心,DAO层代码精简优化并且新增测试用例覆盖;
|
- 5、调度中心,DAO层代码精简优化并且新增测试用例覆盖;
|
||||||
- 6、调度中心API服务改为自研RPC形式,统一底层通讯模型;
|
- 6、调度中心API服务改为自研RPC形式,统一底层通讯模型;
|
||||||
|
- 7、新增调度中心API服务测试Demo,方便在调度中心API扩展和测试;
|
||||||
|
|
||||||
#### TODO LIST
|
#### TODO LIST
|
||||||
- 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限;
|
- 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.xxl.job.admin.controller;
|
package com.xxl.job.admin.controller;
|
||||||
|
|
||||||
import com.xxl.job.admin.controller.annotation.PermessionLimit;
|
import com.xxl.job.admin.controller.annotation.PermessionLimit;
|
||||||
|
import com.xxl.job.core.biz.AdminBiz;
|
||||||
import com.xxl.job.core.rpc.codec.RpcRequest;
|
import com.xxl.job.core.rpc.codec.RpcRequest;
|
||||||
import com.xxl.job.core.rpc.codec.RpcResponse;
|
import com.xxl.job.core.rpc.codec.RpcResponse;
|
||||||
import com.xxl.job.core.rpc.netcom.NetComServerFactory;
|
import com.xxl.job.core.rpc.netcom.NetComServerFactory;
|
||||||
|
@ -46,7 +47,7 @@ public class JobApiController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/api")
|
@RequestMapping(AdminBiz.MAPPING)
|
||||||
@PermessionLimit(limit=false)
|
@PermessionLimit(limit=false)
|
||||||
public void api(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
public void api(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ import com.xxl.job.core.biz.model.ReturnT;
|
||||||
import com.xxl.job.core.rpc.netcom.NetComClientProxy;
|
import com.xxl.job.core.rpc.netcom.NetComClientProxy;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.time.DateUtils;
|
import org.apache.commons.lang.time.DateUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -32,6 +34,7 @@ import java.util.Map;
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/joblog")
|
@RequestMapping("/joblog")
|
||||||
public class JobLogController {
|
public class JobLogController {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(JobLogController.class);
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private XxlJobGroupDao xxlJobGroupDao;
|
private XxlJobGroupDao xxlJobGroupDao;
|
||||||
|
@ -129,7 +132,7 @@ public class JobLogController {
|
||||||
|
|
||||||
return logResult;
|
return logResult;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
logger.error(e.getMessage(), e);
|
||||||
return new ReturnT<LogResult>(ReturnT.FAIL_CODE, e.getMessage());
|
return new ReturnT<LogResult>(ReturnT.FAIL_CODE, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,14 +151,14 @@ public class JobLogController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// request of kill
|
// request of kill
|
||||||
ExecutorBiz executorBiz = null;
|
ReturnT<String> runResult = null;
|
||||||
try {
|
try {
|
||||||
executorBiz = (ExecutorBiz) new NetComClientProxy(ExecutorBiz.class, log.getExecutorAddress()).getObject();
|
ExecutorBiz executorBiz = (ExecutorBiz) new NetComClientProxy(ExecutorBiz.class, log.getExecutorAddress()).getObject();
|
||||||
|
runResult = executorBiz.kill(jobInfo.getId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
logger.error(e.getMessage(), e);
|
||||||
return new ReturnT<String>(500, e.getMessage());
|
runResult = new ReturnT<String>(500, e.getMessage());
|
||||||
}
|
}
|
||||||
ReturnT<String> runResult = executorBiz.kill(jobInfo.getId());
|
|
||||||
|
|
||||||
if (ReturnT.SUCCESS_CODE == runResult.getCode()) {
|
if (ReturnT.SUCCESS_CODE == runResult.getCode()) {
|
||||||
log.setHandleCode(ReturnT.FAIL_CODE);
|
log.setHandleCode(ReturnT.FAIL_CODE);
|
||||||
|
|
|
@ -36,7 +36,7 @@ public abstract class ExecutorRouter {
|
||||||
ExecutorBiz executorBiz = (ExecutorBiz) new NetComClientProxy(ExecutorBiz.class, address).getObject();
|
ExecutorBiz executorBiz = (ExecutorBiz) new NetComClientProxy(ExecutorBiz.class, address).getObject();
|
||||||
runResult = executorBiz.run(triggerParam);
|
runResult = executorBiz.run(triggerParam);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("", e);
|
logger.error(e.getMessage(), e);
|
||||||
runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
|
runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.xxl.job.dao.impl;
|
||||||
|
|
||||||
|
import com.xxl.job.core.biz.AdminBiz;
|
||||||
|
import com.xxl.job.core.biz.model.RegistryParam;
|
||||||
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
|
import com.xxl.job.core.enums.RegistryConfig;
|
||||||
|
import com.xxl.job.core.rpc.netcom.NetComClientProxy;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* admin-api client, test
|
||||||
|
* @author xuxueli 2017-07-28 22:14:52
|
||||||
|
*/
|
||||||
|
public class AdminBizTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void registryTest() throws Exception {
|
||||||
|
|
||||||
|
// admin-client
|
||||||
|
String addressUrl = "http://127.0.0.1:8080/xxl-job-admin".concat(AdminBiz.MAPPING);
|
||||||
|
AdminBiz adminBiz = (AdminBiz) new NetComClientProxy(AdminBiz.class, addressUrl).getObject();
|
||||||
|
|
||||||
|
// test executor registry
|
||||||
|
RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
|
||||||
|
ReturnT<String> returnT = adminBiz.registry(registryParam);
|
||||||
|
Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -11,6 +11,8 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface AdminBiz {
|
public interface AdminBiz {
|
||||||
|
|
||||||
|
public static final String MAPPING = "/api";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* callback
|
* callback
|
||||||
*
|
*
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class XxlJobExecutor implements ApplicationContextAware, ApplicationListe
|
||||||
if (adminAddresses!=null && adminAddresses.trim().length()>0) {
|
if (adminAddresses!=null && adminAddresses.trim().length()>0) {
|
||||||
for (String address: adminAddresses.trim().split(",")) {
|
for (String address: adminAddresses.trim().split(",")) {
|
||||||
if (address!=null && address.trim().length()>0) {
|
if (address!=null && address.trim().length()>0) {
|
||||||
String addressUrl = address.concat("/api");
|
String addressUrl = address.concat(AdminBiz.MAPPING);
|
||||||
AdminBiz adminBiz = (AdminBiz) new NetComClientProxy(AdminBiz.class, addressUrl).getObject();
|
AdminBiz adminBiz = (AdminBiz) new NetComClientProxy(AdminBiz.class, addressUrl).getObject();
|
||||||
if (adminBizList == null) {
|
if (adminBizList == null) {
|
||||||
adminBizList = new ArrayList<AdminBiz>();
|
adminBizList = new ArrayList<AdminBiz>();
|
||||||
|
|
|
@ -8,6 +8,8 @@ import com.xxl.job.core.glue.GlueTypeEnum;
|
||||||
import com.xxl.job.core.rpc.netcom.NetComClientProxy;
|
import com.xxl.job.core.rpc.netcom.NetComClientProxy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* executor-api client, test
|
||||||
|
*
|
||||||
* Created by xuxueli on 17/5/12.
|
* Created by xuxueli on 17/5/12.
|
||||||
*/
|
*/
|
||||||
public class DemoJobHandlerTest {
|
public class DemoJobHandlerTest {
|
||||||
|
|
Loading…
Reference in New Issue