执行器注册线程优化,线程销毁时主动摘除注册机器;
This commit is contained in:
parent
0b4849bb61
commit
7bc11fcbc4
|
@ -987,6 +987,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
|
|||
- 4、执行器手动设置IP时将会绑定Host;
|
||||
- 5、项目主页搭建,提供中英文文档;
|
||||
- 6、执行器回调线程优化,线程销毁前批量回调队列中所有数据;
|
||||
- 7、执行器注册线程优化,线程销毁时主动摘除注册机器;
|
||||
|
||||
### TODO LIST
|
||||
- 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限;
|
||||
|
|
|
@ -22,4 +22,8 @@ public interface XxlJobRegistryDao {
|
|||
@Param("registryKey") String registryKey,
|
||||
@Param("registryValue") String registryValue);
|
||||
|
||||
public int registryDelete(@Param("registryGroup") String registGroup,
|
||||
@Param("registryKey") String registryKey,
|
||||
@Param("registryValue") String registryValue);
|
||||
|
||||
}
|
||||
|
|
|
@ -118,4 +118,10 @@ public class AdminBizImpl implements AdminBiz {
|
|||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReturnT<String> registryRemove(RegistryParam registryParam) {
|
||||
xxlJobRegistryDao.registryDelete(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,4 +43,11 @@
|
|||
VALUES( #{registryGroup} , #{registryKey} , #{registryValue}, NOW())
|
||||
</insert>
|
||||
|
||||
<delete id="registryDelete" >
|
||||
DELETE FROM XXL_JOB_QRTZ_TRIGGER_REGISTRY
|
||||
WHERE registry_group = #{registryGroup}
|
||||
AND registry_key = #{registryKey}
|
||||
AND registry_value = #{registryValue}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
|
@ -27,6 +27,13 @@ public class AdminBizTest {
|
|||
ReturnT<String> returnT = adminBiz.registry(registryParam);
|
||||
Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
|
||||
|
||||
|
||||
|
||||
// test executor registry remove
|
||||
registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
|
||||
returnT = adminBiz.registryRemove(registryParam);
|
||||
Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,4 +29,12 @@ public interface AdminBiz {
|
|||
*/
|
||||
public ReturnT<String> registry(RegistryParam registryParam);
|
||||
|
||||
/**
|
||||
* registry remove
|
||||
*
|
||||
* @param registryParam
|
||||
* @return
|
||||
*/
|
||||
public ReturnT<String> registryRemove(RegistryParam registryParam);
|
||||
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ public class ExecutorRegistryThread extends Thread {
|
|||
registryThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// registry
|
||||
while (!toStop) {
|
||||
try {
|
||||
RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), appName, executorAddress);
|
||||
|
@ -77,7 +79,26 @@ public class ExecutorRegistryThread extends Thread {
|
|||
}
|
||||
|
||||
// registry remove
|
||||
try {
|
||||
RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), appName, executorAddress);
|
||||
for (AdminBiz adminBiz: XxlJobExecutor.getAdminBizList()) {
|
||||
try {
|
||||
ReturnT<String> registryResult = adminBiz.registryRemove(registryParam);
|
||||
if (registryResult!=null && ReturnT.SUCCESS_CODE == registryResult.getCode()) {
|
||||
registryResult = ReturnT.SUCCESS;
|
||||
logger.info(">>>>>>>>>>> xxl-job registry-remove success, registryParam:{}, registryResult:{}", new Object[]{registryParam, registryResult});
|
||||
break;
|
||||
} else {
|
||||
logger.info(">>>>>>>>>>> xxl-job registry-remove fail, registryParam:{}, registryResult:{}", new Object[]{registryParam, registryResult});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info(">>>>>>>>>>> xxl-job registry-remove error, registryParam:{}", registryParam, e);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue