com.xxl.job.core.executor.XxlJobExecutor Java Examples
The following examples show how to use
com.xxl.job.core.executor.XxlJobExecutor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JbootConfig.java From xxl-job with GNU General Public License v3.0 | 6 votes |
private void initXxlJobExecutor() { // registry jobhandler XxlJobExecutor.registJobHandler("demoJobHandler", new DemoJobHandler()); XxlJobExecutor.registJobHandler("shardingJobHandler", new ShardingJobHandler()); XxlJobExecutor.registJobHandler("httpJobHandler", new HttpJobHandler()); XxlJobExecutor.registJobHandler("commandJobHandler", new CommandJobHandler()); // init executor xxlJobExecutor = new XxlJobExecutor(); xxlJobExecutor.setAdminAddresses(Jboot.configValue("xxl.job.admin.addresses")); xxlJobExecutor.setAccessToken(Jboot.configValue("xxl.job.accessToken")); xxlJobExecutor.setAddress(Jboot.configValue("xxl.job.executor.address")); xxlJobExecutor.setAppname(Jboot.configValue("xxl.job.executor.appname")); xxlJobExecutor.setIp(Jboot.configValue("xxl.job.executor.ip")); xxlJobExecutor.setPort(Integer.valueOf(Jboot.configValue("xxl.job.executor.port"))); xxlJobExecutor.setLogPath(Jboot.configValue("xxl.job.executor.logpath")); xxlJobExecutor.setLogRetentionDays(Integer.valueOf(Jboot.configValue("xxl.job.executor.logretentiondays"))); // start executor try { xxlJobExecutor.start(); } catch (Exception e) { logger.error(e.getMessage(), e); } }
Example #2
Source File: TriggerCallbackThread.java From open-capacity-platform with Apache License 2.0 | 6 votes |
/** * do callback, will retry if error * @param callbackParamList */ private void doCallback(List<HandleCallbackParam> callbackParamList){ // callback, will retry if error for (AdminBiz adminBiz: XxlJobExecutor.getAdminBizList()) { try { ReturnT<String> callbackResult = adminBiz.callback(callbackParamList); if (callbackResult!=null && ReturnT.SUCCESS_CODE == callbackResult.getCode()) { callbackResult = ReturnT.SUCCESS; logger.info(">>>>>>>>>>> xxl-job callback success, callbackParamList:{}, callbackResult:{}", new Object[]{callbackParamList, callbackResult}); break; } else { logger.info(">>>>>>>>>>> xxl-job callback fail, callbackParamList:{}, callbackResult:{}", new Object[]{callbackParamList, callbackResult}); } } catch (Exception e) { logger.error(">>>>>>>>>>> xxl-job callback error, callbackParamList:{}", callbackParamList, e); //getInstance().callBackQueue.addAll(callbackParamList); } } }
Example #3
Source File: TriggerCallbackThread.java From xxl-job with GNU General Public License v3.0 | 6 votes |
/** * do callback, will retry if error * @param callbackParamList */ private void doCallback(List<HandleCallbackParam> callbackParamList){ boolean callbackRet = false; // callback, will retry if error for (AdminBiz adminBiz: XxlJobExecutor.getAdminBizList()) { try { ReturnT<String> callbackResult = adminBiz.callback(callbackParamList); if (callbackResult!=null && ReturnT.SUCCESS_CODE == callbackResult.getCode()) { callbackLog(callbackParamList, "<br>----------- xxl-job job callback finish."); callbackRet = true; break; } else { callbackLog(callbackParamList, "<br>----------- xxl-job job callback fail, callbackResult:" + callbackResult); } } catch (Exception e) { callbackLog(callbackParamList, "<br>----------- xxl-job job callback error, errorMsg:" + e.getMessage()); } } if (!callbackRet) { appendFailCallbackFile(callbackParamList); } }
Example #4
Source File: TriggerCallbackThread.java From microservices-platform with Apache License 2.0 | 6 votes |
/** * do callback, will retry if error * @param callbackParamList */ private void doCallback(List<HandleCallbackParam> callbackParamList){ boolean callbackRet = false; // callback, will retry if error for (AdminBiz adminBiz: XxlJobExecutor.getAdminBizList()) { try { ReturnT<String> callbackResult = adminBiz.callback(callbackParamList); if (callbackResult!=null && ReturnT.SUCCESS_CODE == callbackResult.getCode()) { callbackLog(callbackParamList, "<br>----------- xxl-job job callback finish."); callbackRet = true; break; } else { callbackLog(callbackParamList, "<br>----------- xxl-job job callback fail, callbackResult:" + callbackResult); } } catch (Exception e) { callbackLog(callbackParamList, "<br>----------- xxl-job job callback error, errorMsg:" + e.getMessage()); } } if (!callbackRet) { appendFailCallbackFile(callbackParamList); } }
Example #5
Source File: TriggerCallbackThread.java From zuihou-admin-cloud with Apache License 2.0 | 6 votes |
/** * do callback, will retry if error * * @param callbackParamList */ private void doCallback(List<HandleCallbackParam> callbackParamList) { boolean callbackRet = false; // callback, will retry if error for (AdminBiz adminBiz : XxlJobExecutor.getAdminBizList()) { try { ReturnT<String> callbackResult = adminBiz.callback(callbackParamList); if (callbackResult != null && ReturnT.SUCCESS_CODE == callbackResult.getCode()) { callbackLog(callbackParamList, "<br>----------- xxl-job job callback finish."); callbackRet = true; break; } else { callbackLog(callbackParamList, "<br>----------- xxl-job job callback fail, callbackResult:" + callbackResult); } } catch (Exception e) { callbackLog(callbackParamList, "<br>----------- xxl-job job callback error, errorMsg:" + e.getMessage()); } } if (!callbackRet) { appendFailCallbackFile(callbackParamList); } }
Example #6
Source File: TriggerCallbackThread.java From zuihou-admin-boot with Apache License 2.0 | 6 votes |
/** * do callback, will retry if error * * @param callbackParamList */ private void doCallback(List<HandleCallbackParam> callbackParamList) { boolean callbackRet = false; // callback, will retry if error for (AdminBiz adminBiz : XxlJobExecutor.getAdminBizList()) { try { ReturnT<String> callbackResult = adminBiz.callback(callbackParamList); if (callbackResult != null && ReturnT.SUCCESS_CODE == callbackResult.getCode()) { callbackLog(callbackParamList, "<br>----------- xxl-job job callback finish."); callbackRet = true; break; } else { callbackLog(callbackParamList, "<br>----------- xxl-job job callback fail, callbackResult:" + callbackResult); } } catch (Exception e) { callbackLog(callbackParamList, "<br>----------- xxl-job job callback error, errorMsg:" + e.getMessage()); } } if (!callbackRet) { appendFailCallbackFile(callbackParamList); } }
Example #7
Source File: JobCenterAutoConfiguration.java From summerframework with Apache License 2.0 | 5 votes |
@PostConstruct public void init() { this.initDefaultParm(); ScheduledExecutorService scheduleReport = Executors.newScheduledThreadPool(1, new NamedThreadFactory()); scheduleReport.scheduleAtFixedRate(new Runnable() { @Override public void run() { try { XxlJobExecutor xxlJobExecutor = applicationContext.getBean(XxlJobExecutor.class); String adminAddresses = discoveryAdminAddress(); if (StringUtils.isEmpty(adminAddresses)) { return; } if (adminAddresses.equals(xxlJobExecutor.getAdminAddresses())) { LOGGER.info("AdminAddresses has no changes."); return; } if (xxlJobExecutor.getAdminAddresses() == null) { LOGGER.info("Old adminAddresses is NULL"); } else { LOGGER.info("Remove old node {}", xxlJobExecutor.getAdminAddresses()); XxlJobExecutor.getAdminBizList().clear(); } LOGGER.info("Find all adminAddresses:" + adminAddresses + " from eureka"); xxlJobExecutor.setAdminAddresses(adminAddresses); xxlJobExecutor.reInitAdminBizList(); } catch (Throwable e) { LOGGER.warn(e.getMessage(), e); } } }, 0, 30, TimeUnit.SECONDS); }
Example #8
Source File: JFinalCoreConfig.java From xxl-job with GNU General Public License v3.0 | 5 votes |
private void initXxlJobExecutor() { // registry jobhandler XxlJobExecutor.registJobHandler("demoJobHandler", new DemoJobHandler()); XxlJobExecutor.registJobHandler("shardingJobHandler", new ShardingJobHandler()); XxlJobExecutor.registJobHandler("httpJobHandler", new HttpJobHandler()); XxlJobExecutor.registJobHandler("commandJobHandler", new CommandJobHandler()); // load executor prop Prop xxlJobProp = PropKit.use("xxl-job-executor.properties"); // init executor xxlJobExecutor = new XxlJobExecutor(); xxlJobExecutor.setAdminAddresses(xxlJobProp.get("xxl.job.admin.addresses")); xxlJobExecutor.setAccessToken(xxlJobProp.get("xxl.job.accessToken")); xxlJobExecutor.setAddress(xxlJobProp.get("xxl.job.executor.address")); xxlJobExecutor.setAppname(xxlJobProp.get("xxl.job.executor.appname")); xxlJobExecutor.setIp(xxlJobProp.get("xxl.job.executor.ip")); xxlJobExecutor.setPort(xxlJobProp.getInt("xxl.job.executor.port")); xxlJobExecutor.setLogPath(xxlJobProp.get("xxl.job.executor.logpath")); xxlJobExecutor.setLogRetentionDays(xxlJobProp.getInt("xxl.job.executor.logretentiondays")); // start executor try { xxlJobExecutor.start(); } catch (Exception e) { logger.error(e.getMessage(), e); } }
Example #9
Source File: NutzSetup.java From xxl-job with GNU General Public License v3.0 | 5 votes |
@Override public void init(NutConfig cfg) { // registry jobhandler XxlJobExecutor.registJobHandler("demoJobHandler", new DemoJobHandler()); XxlJobExecutor.registJobHandler("shardingJobHandler", new ShardingJobHandler()); XxlJobExecutor.registJobHandler("httpJobHandler", new HttpJobHandler()); XxlJobExecutor.registJobHandler("commandJobHandler", new CommandJobHandler()); // load executor prop PropertiesProxy xxlJobProp = new PropertiesProxy("xxl-job-executor.properties"); // init executor xxlJobExecutor = new XxlJobExecutor(); xxlJobExecutor.setAdminAddresses(xxlJobProp.get("xxl.job.admin.addresses")); xxlJobExecutor.setAccessToken(xxlJobProp.get("xxl.job.accessToken")); xxlJobExecutor.setAppname(xxlJobProp.get("xxl.job.executor.appname")); xxlJobExecutor.setAddress(xxlJobProp.get("xxl.job.executor.address")); xxlJobExecutor.setIp(xxlJobProp.get("xxl.job.executor.ip")); xxlJobExecutor.setPort(xxlJobProp.getInt("xxl.job.executor.port")); xxlJobExecutor.setLogPath(xxlJobProp.get("xxl.job.executor.logpath")); xxlJobExecutor.setLogRetentionDays(xxlJobProp.getInt("xxl.job.executor.logretentiondays")); // start executor try { xxlJobExecutor.start(); } catch (Exception e) { logger.error(e.getMessage(), e); } }
Example #10
Source File: FrameLessXxlJobConfig.java From xxl-job with GNU General Public License v3.0 | 5 votes |
/** * init */ public void initXxlJobExecutor() { // registry jobhandler XxlJobExecutor.registJobHandler("demoJobHandler", new DemoJobHandler()); XxlJobExecutor.registJobHandler("shardingJobHandler", new ShardingJobHandler()); XxlJobExecutor.registJobHandler("httpJobHandler", new HttpJobHandler()); XxlJobExecutor.registJobHandler("commandJobHandler", new CommandJobHandler()); // load executor prop Properties xxlJobProp = loadProperties("xxl-job-executor.properties"); // init executor xxlJobExecutor = new XxlJobExecutor(); xxlJobExecutor.setAdminAddresses(xxlJobProp.getProperty("xxl.job.admin.addresses")); xxlJobExecutor.setAccessToken(xxlJobProp.getProperty("xxl.job.accessToken")); xxlJobExecutor.setAppname(xxlJobProp.getProperty("xxl.job.executor.appname")); xxlJobExecutor.setAddress(xxlJobProp.getProperty("xxl.job.executor.address")); xxlJobExecutor.setIp(xxlJobProp.getProperty("xxl.job.executor.ip")); xxlJobExecutor.setPort(Integer.valueOf(xxlJobProp.getProperty("xxl.job.executor.port"))); xxlJobExecutor.setLogPath(xxlJobProp.getProperty("xxl.job.executor.logpath")); xxlJobExecutor.setLogRetentionDays(Integer.valueOf(xxlJobProp.getProperty("xxl.job.executor.logretentiondays"))); // start executor try { xxlJobExecutor.start(); } catch (Exception e) { logger.error(e.getMessage(), e); } }
Example #11
Source File: ExecutorBizImpl.java From xxl-job with GNU General Public License v3.0 | 5 votes |
@Override public ReturnT<String> kill(KillParam killParam) { // kill handlerThread, and create new one JobThread jobThread = XxlJobExecutor.loadJobThread(killParam.getJobId()); if (jobThread != null) { XxlJobExecutor.removeJobThread(killParam.getJobId(), "scheduling center kill job."); return ReturnT.SUCCESS; } return new ReturnT<String>(ReturnT.SUCCESS_CODE, "job thread already killed."); }
Example #12
Source File: ExecutorBizImpl.java From xxl-job with GNU General Public License v3.0 | 5 votes |
@Override public ReturnT<String> idleBeat(IdleBeatParam idleBeatParam) { // isRunningOrHasQueue boolean isRunningOrHasQueue = false; JobThread jobThread = XxlJobExecutor.loadJobThread(idleBeatParam.getJobId()); if (jobThread != null && jobThread.isRunningOrHasQueue()) { isRunningOrHasQueue = true; } if (isRunningOrHasQueue) { return new ReturnT<String>(ReturnT.FAIL_CODE, "job thread is running or has trigger queue."); } return ReturnT.SUCCESS; }
Example #13
Source File: ExecutorBizImpl.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> kill(int jobId) { // kill handlerThread, and create new one JobThread jobThread = XxlJobExecutor.loadJobThread(jobId); if (jobThread != null) { XxlJobExecutor.removeJobThread(jobId, "scheduling center kill job."); return ReturnT.SUCCESS; } return new ReturnT<String>(ReturnT.SUCCESS_CODE, "job thread aleady killed."); }
Example #14
Source File: ExecutorBizImpl.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> idleBeat(int jobId) { // isRunningOrHasQueue boolean isRunningOrHasQueue = false; JobThread jobThread = XxlJobExecutor.loadJobThread(jobId); if (jobThread != null && jobThread.isRunningOrHasQueue()) { isRunningOrHasQueue = true; } if (isRunningOrHasQueue) { return new ReturnT<String>(ReturnT.FAIL_CODE, "job thread is running or has trigger queue."); } return ReturnT.SUCCESS; }
Example #15
Source File: ExecutorBizImpl.java From open-capacity-platform with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> idleBeat(int jobId) { // isRunningOrHasQueue boolean isRunningOrHasQueue = false; JobThread jobThread = XxlJobExecutor.loadJobThread(jobId); if (jobThread != null && jobThread.isRunningOrHasQueue()) { isRunningOrHasQueue = true; } if (isRunningOrHasQueue) { return new ReturnT<String>(ReturnT.FAIL_CODE, "job thread is running or has trigger queue."); } return ReturnT.SUCCESS; }
Example #16
Source File: ExecutorBizImpl.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> kill(int jobId) { // kill handlerThread, and create new one JobThread jobThread = XxlJobExecutor.loadJobThread(jobId); if (jobThread != null) { XxlJobExecutor.removeJobThread(jobId, "scheduling center kill job."); return ReturnT.SUCCESS; } return new ReturnT<String>(ReturnT.SUCCESS_CODE, "job thread aleady killed."); }
Example #17
Source File: ExecutorBizImpl.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> idleBeat(int jobId) { // isRunningOrHasQueue boolean isRunningOrHasQueue = false; JobThread jobThread = XxlJobExecutor.loadJobThread(jobId); if (jobThread != null && jobThread.isRunningOrHasQueue()) { isRunningOrHasQueue = true; } if (isRunningOrHasQueue) { return new ReturnT<String>(ReturnT.FAIL_CODE, "job thread is running or has trigger queue."); } return ReturnT.SUCCESS; }
Example #18
Source File: ExecutorBizImpl.java From microservices-platform with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> kill(int jobId) { // kill handlerThread, and create new one JobThread jobThread = XxlJobExecutor.loadJobThread(jobId); if (jobThread != null) { XxlJobExecutor.removeJobThread(jobId, "scheduling center kill job."); return ReturnT.SUCCESS; } return new ReturnT<String>(ReturnT.SUCCESS_CODE, "job thread aleady killed."); }
Example #19
Source File: ExecutorBizImpl.java From microservices-platform with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> idleBeat(int jobId) { // isRunningOrHasQueue boolean isRunningOrHasQueue = false; JobThread jobThread = XxlJobExecutor.loadJobThread(jobId); if (jobThread != null && jobThread.isRunningOrHasQueue()) { isRunningOrHasQueue = true; } if (isRunningOrHasQueue) { return new ReturnT<String>(ReturnT.FAIL_CODE, "job thread is running or has trigger queue."); } return ReturnT.SUCCESS; }
Example #20
Source File: ExecutorBizImpl.java From open-capacity-platform with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> kill(int jobId) { // kill handlerThread, and create new one JobThread jobThread = XxlJobExecutor.loadJobThread(jobId); if (jobThread != null) { XxlJobExecutor.removeJobThread(jobId, "人工手动终止"); return ReturnT.SUCCESS; } return new ReturnT<String>(ReturnT.SUCCESS_CODE, "job thread aleady killed."); }
Example #21
Source File: TriggerCallbackThread.java From zuihou-admin-boot with Apache License 2.0 | 4 votes |
public void start() { // valid if (XxlJobExecutor.getAdminBizList() == null) { logger.warn(">>>>>>>>>>> xxl-job, executor callback config fail, adminAddresses is null."); return; } // callback triggerCallbackThread = new Thread(new Runnable() { @Override public void run() { // normal callback while (!toStop) { try { HandleCallbackParam callback = getInstance().callBackQueue.take(); if (callback != null) { // callback list param List<HandleCallbackParam> callbackParamList = new ArrayList<HandleCallbackParam>(); int drainToNum = getInstance().callBackQueue.drainTo(callbackParamList); callbackParamList.add(callback); // callback, will retry if error if (callbackParamList != null && callbackParamList.size() > 0) { doCallback(callbackParamList); } } } catch (Exception e) { logger.error(e.getMessage(), e); } } // last callback try { List<HandleCallbackParam> callbackParamList = new ArrayList<HandleCallbackParam>(); int drainToNum = getInstance().callBackQueue.drainTo(callbackParamList); if (callbackParamList != null && callbackParamList.size() > 0) { doCallback(callbackParamList); } } catch (Exception e) { logger.error(e.getMessage(), e); } logger.info(">>>>>>>>>>> xxl-job, executor callback thread destory."); } }); triggerCallbackThread.setDaemon(true); triggerCallbackThread.start(); // retry triggerRetryCallbackThread = new Thread(new Runnable() { @Override public void run() { while (!toStop) { try { retryFailCallbackFile(); } catch (Exception e) { logger.error(e.getMessage(), e); } try { TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT); } catch (InterruptedException e) { logger.warn(">>>>>>>>>>> xxl-job, executor retry callback thread interrupted, error msg:{}", e.getMessage()); } } logger.info(">>>>>>>>>>> xxl-job, executor retry callback thread destory."); } }); triggerRetryCallbackThread.setDaemon(true); triggerRetryCallbackThread.start(); }
Example #22
Source File: ExecutorRegistryThread.java From zuihou-admin-boot with Apache License 2.0 | 4 votes |
public void start(final String appName, final String address, final String registryLazy) { // valid if (appName == null || appName.trim().length() == 0) { logger.warn(">>>>>>>>>>> xxl-job, executor registry config fail, appName is null."); return; } if (XxlJobExecutor.getAdminBizList() == null) { logger.warn(">>>>>>>>>>> xxl-job, executor registry config fail, adminAddresses is null."); return; } REGISTRY_LAZY = Convert.toLong(registryLazy, 10000L); registryThread = new Thread(new Runnable() { @Override public void run() { // 首次主次延迟 REGISTRY_LAZY 毫秒, 防止尚未启动完成时,注册失败 if (REGISTRY_LAZY > 0) { try { Thread.sleep(REGISTRY_LAZY); } catch (InterruptedException e) { logger.error(">>>>>>>>>>> xxl-job 首次注册延迟失败, appName:{}, address:{}", new Object[]{appName, address}); } finally { REGISTRY_LAZY = 0; } } // registry while (!toStop) { try { RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), appName, address); for (AdminBiz adminBiz : XxlJobExecutor.getAdminBizList()) { try { ReturnT<String> registryResult = adminBiz.registry(registryParam); if (registryResult != null && ReturnT.SUCCESS_CODE == registryResult.getCode()) { registryResult = ReturnT.SUCCESS; logger.info(">>>>>>>>>>> xxl-job registry success, registryParam:{}, registryResult:{}", new Object[]{registryParam, registryResult}); break; } else { logger.info(">>>>>>>>>>> xxl-job registry fail, registryParam:{}, registryResult:{}", new Object[]{registryParam, registryResult}); } } catch (Exception e) { logger.info(">>>>>>>>>>> xxl-job registry error, registryParam:{}", registryParam, e); } } } catch (Exception e) { logger.error(e.getMessage(), e); } try { TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT); } catch (InterruptedException e) { logger.warn(">>>>>>>>>>> xxl-job, executor registry thread interrupted, error msg:{}", e.getMessage()); } } // registry remove try { RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), appName, address); 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); } logger.info(">>>>>>>>>>> xxl-job, executor registry thread destory."); } }); registryThread.setDaemon(true); registryThread.start(); }
Example #23
Source File: ExecutorRegistryThread.java From zuihou-admin-cloud with Apache License 2.0 | 4 votes |
public void start(final String appName, final String address, final String registryLazy) { // valid if (appName == null || appName.trim().length() == 0) { logger.warn(">>>>>>>>>>> xxl-job, executor registry config fail, appName is null."); return; } if (XxlJobExecutor.getAdminBizList() == null) { logger.warn(">>>>>>>>>>> xxl-job, executor registry config fail, adminAddresses is null."); return; } REGISTRY_LAZY = Convert.toLong(registryLazy, 10000L); registryThread = new Thread(new Runnable() { @Override public void run() { // 首次主次延迟 REGISTRY_LAZY 毫秒, 防止尚未启动完成时,注册失败 if (REGISTRY_LAZY > 0) { try { Thread.sleep(REGISTRY_LAZY); } catch (InterruptedException e) { logger.error(">>>>>>>>>>> xxl-job 首次注册延迟失败, appName:{}, address:{}", new Object[]{appName, address}); } finally { REGISTRY_LAZY = 0; } } // registry while (!toStop) { try { RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), appName, address); for (AdminBiz adminBiz : XxlJobExecutor.getAdminBizList()) { try { ReturnT<String> registryResult = adminBiz.registry(registryParam); if (registryResult != null && ReturnT.SUCCESS_CODE == registryResult.getCode()) { registryResult = ReturnT.SUCCESS; logger.info(">>>>>>>>>>> xxl-job registry success, registryParam:{}, registryResult:{}", new Object[]{registryParam, registryResult}); break; } else { logger.info(">>>>>>>>>>> xxl-job registry fail, registryParam:{}, registryResult:{}", new Object[]{registryParam, registryResult}); } } catch (Exception e) { logger.info(">>>>>>>>>>> xxl-job registry error, registryParam:{}", registryParam, e); } } } catch (Exception e) { logger.error(e.getMessage(), e); } try { TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT); } catch (InterruptedException e) { logger.warn(">>>>>>>>>>> xxl-job, executor registry thread interrupted, error msg:{}", e.getMessage()); } } // registry remove try { RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), appName, address); 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); } logger.info(">>>>>>>>>>> xxl-job, executor registry thread destory."); } }); registryThread.setDaemon(true); registryThread.start(); }
Example #24
Source File: TriggerCallbackThread.java From zuihou-admin-cloud with Apache License 2.0 | 4 votes |
public void start() { // valid if (XxlJobExecutor.getAdminBizList() == null) { logger.warn(">>>>>>>>>>> xxl-job, executor callback config fail, adminAddresses is null."); return; } // callback triggerCallbackThread = new Thread(new Runnable() { @Override public void run() { // normal callback while (!toStop) { try { HandleCallbackParam callback = getInstance().callBackQueue.take(); if (callback != null) { // callback list param List<HandleCallbackParam> callbackParamList = new ArrayList<HandleCallbackParam>(); int drainToNum = getInstance().callBackQueue.drainTo(callbackParamList); callbackParamList.add(callback); // callback, will retry if error if (callbackParamList != null && callbackParamList.size() > 0) { doCallback(callbackParamList); } } } catch (Exception e) { logger.error(e.getMessage(), e); } } // last callback try { List<HandleCallbackParam> callbackParamList = new ArrayList<HandleCallbackParam>(); int drainToNum = getInstance().callBackQueue.drainTo(callbackParamList); if (callbackParamList != null && callbackParamList.size() > 0) { doCallback(callbackParamList); } } catch (Exception e) { logger.error(e.getMessage(), e); } logger.info(">>>>>>>>>>> xxl-job, executor callback thread destory."); } }); triggerCallbackThread.setDaemon(true); triggerCallbackThread.start(); // retry triggerRetryCallbackThread = new Thread(new Runnable() { @Override public void run() { while (!toStop) { try { retryFailCallbackFile(); } catch (Exception e) { logger.error(e.getMessage(), e); } try { TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT); } catch (InterruptedException e) { logger.warn(">>>>>>>>>>> xxl-job, executor retry callback thread interrupted, error msg:{}", e.getMessage()); } } logger.info(">>>>>>>>>>> xxl-job, executor retry callback thread destory."); } }); triggerRetryCallbackThread.setDaemon(true); triggerRetryCallbackThread.start(); }
Example #25
Source File: TriggerCallbackThread.java From microservices-platform with Apache License 2.0 | 4 votes |
public void start() { // valid if (XxlJobExecutor.getAdminBizList() == null) { logger.warn(">>>>>>>>>>> xxl-job, executor callback config fail, adminAddresses is null."); return; } // callback triggerCallbackThread = new Thread(new Runnable() { @Override public void run() { // normal callback while(!toStop){ try { HandleCallbackParam callback = getInstance().callBackQueue.take(); if (callback != null) { // callback list param List<HandleCallbackParam> callbackParamList = new ArrayList<HandleCallbackParam>(); int drainToNum = getInstance().callBackQueue.drainTo(callbackParamList); callbackParamList.add(callback); // callback, will retry if error if (callbackParamList!=null && callbackParamList.size()>0) { doCallback(callbackParamList); } } } catch (Exception e) { if (!toStop) { logger.error(e.getMessage(), e); } } } // last callback try { List<HandleCallbackParam> callbackParamList = new ArrayList<HandleCallbackParam>(); int drainToNum = getInstance().callBackQueue.drainTo(callbackParamList); if (callbackParamList!=null && callbackParamList.size()>0) { doCallback(callbackParamList); } } catch (Exception e) { if (!toStop) { logger.error(e.getMessage(), e); } } logger.info(">>>>>>>>>>> xxl-job, executor callback thread destory."); } }); triggerCallbackThread.setDaemon(true); triggerCallbackThread.start(); // retry triggerRetryCallbackThread = new Thread(new Runnable() { @Override public void run() { while(!toStop){ try { retryFailCallbackFile(); } catch (Exception e) { if (!toStop) { logger.error(e.getMessage(), e); } } try { TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT); } catch (InterruptedException e) { if (!toStop) { logger.error(e.getMessage(), e); } } } logger.info(">>>>>>>>>>> xxl-job, executor retry callback thread destory."); } }); triggerRetryCallbackThread.setDaemon(true); triggerRetryCallbackThread.start(); }
Example #26
Source File: ExecutorRegistryThread.java From microservices-platform with Apache License 2.0 | 4 votes |
public void start(final String appName, final String address){ // valid if (appName==null || appName.trim().length()==0) { logger.warn(">>>>>>>>>>> xxl-job, executor registry config fail, appName is null."); return; } if (XxlJobExecutor.getAdminBizList() == null) { logger.warn(">>>>>>>>>>> xxl-job, executor registry config fail, adminAddresses is null."); return; } registryThread = new Thread(new Runnable() { @Override public void run() { // registry while (!toStop) { try { RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), appName, address); for (AdminBiz adminBiz: XxlJobExecutor.getAdminBizList()) { try { ReturnT<String> registryResult = adminBiz.registry(registryParam); if (registryResult!=null && ReturnT.SUCCESS_CODE == registryResult.getCode()) { registryResult = ReturnT.SUCCESS; logger.info(">>>>>>>>>>> xxl-job registry success, registryParam:{}, registryResult:{}", new Object[]{registryParam, registryResult}); break; } else { logger.info(">>>>>>>>>>> xxl-job registry fail, registryParam:{}, registryResult:{}", new Object[]{registryParam, registryResult}); } } catch (Exception e) { logger.info(">>>>>>>>>>> xxl-job registry error, registryParam:{}", registryParam, e); } } } catch (Exception e) { if (!toStop) { logger.error(e.getMessage(), e); } } try { TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT); } catch (InterruptedException e) { if (!toStop) { logger.warn(">>>>>>>>>>> xxl-job, executor registry thread interrupted, error msg:{}", e.getMessage()); } } } // registry remove try { RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), appName, address); 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); } logger.info(">>>>>>>>>>> xxl-job, executor registry thread destory."); } }); registryThread.setDaemon(true); registryThread.start(); }
Example #27
Source File: ExecutorRegistryThread.java From xxl-job with GNU General Public License v3.0 | 4 votes |
public void start(final String appname, final String address){ // valid if (appname==null || appname.trim().length()==0) { logger.warn(">>>>>>>>>>> xxl-job, executor registry config fail, appname is null."); return; } if (XxlJobExecutor.getAdminBizList() == null) { logger.warn(">>>>>>>>>>> xxl-job, executor registry config fail, adminAddresses is null."); return; } registryThread = new Thread(new Runnable() { @Override public void run() { // registry while (!toStop) { try { RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), appname, address); for (AdminBiz adminBiz: XxlJobExecutor.getAdminBizList()) { try { ReturnT<String> registryResult = adminBiz.registry(registryParam); if (registryResult!=null && ReturnT.SUCCESS_CODE == registryResult.getCode()) { registryResult = ReturnT.SUCCESS; logger.debug(">>>>>>>>>>> xxl-job registry success, registryParam:{}, registryResult:{}", new Object[]{registryParam, registryResult}); break; } else { logger.info(">>>>>>>>>>> xxl-job registry fail, registryParam:{}, registryResult:{}", new Object[]{registryParam, registryResult}); } } catch (Exception e) { logger.info(">>>>>>>>>>> xxl-job registry error, registryParam:{}", registryParam, e); } } } catch (Exception e) { if (!toStop) { logger.error(e.getMessage(), e); } } try { if (!toStop) { TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT); } } catch (InterruptedException e) { if (!toStop) { logger.warn(">>>>>>>>>>> xxl-job, executor registry thread interrupted, error msg:{}", e.getMessage()); } } } // registry remove try { RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), appname, address); 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) { if (!toStop) { logger.info(">>>>>>>>>>> xxl-job registry-remove error, registryParam:{}", registryParam, e); } } } } catch (Exception e) { if (!toStop) { logger.error(e.getMessage(), e); } } logger.info(">>>>>>>>>>> xxl-job, executor registry thread destory."); } }); registryThread.setDaemon(true); registryThread.setName("xxl-job, executor ExecutorRegistryThread"); registryThread.start(); }
Example #28
Source File: TriggerCallbackThread.java From xxl-job with GNU General Public License v3.0 | 4 votes |
public void start() { // valid if (XxlJobExecutor.getAdminBizList() == null) { logger.warn(">>>>>>>>>>> xxl-job, executor callback config fail, adminAddresses is null."); return; } // callback triggerCallbackThread = new Thread(new Runnable() { @Override public void run() { // normal callback while(!toStop){ try { HandleCallbackParam callback = getInstance().callBackQueue.take(); if (callback != null) { // callback list param List<HandleCallbackParam> callbackParamList = new ArrayList<HandleCallbackParam>(); int drainToNum = getInstance().callBackQueue.drainTo(callbackParamList); callbackParamList.add(callback); // callback, will retry if error if (callbackParamList!=null && callbackParamList.size()>0) { doCallback(callbackParamList); } } } catch (Exception e) { if (!toStop) { logger.error(e.getMessage(), e); } } } // last callback try { List<HandleCallbackParam> callbackParamList = new ArrayList<HandleCallbackParam>(); int drainToNum = getInstance().callBackQueue.drainTo(callbackParamList); if (callbackParamList!=null && callbackParamList.size()>0) { doCallback(callbackParamList); } } catch (Exception e) { if (!toStop) { logger.error(e.getMessage(), e); } } logger.info(">>>>>>>>>>> xxl-job, executor callback thread destory."); } }); triggerCallbackThread.setDaemon(true); triggerCallbackThread.setName("xxl-job, executor TriggerCallbackThread"); triggerCallbackThread.start(); // retry triggerRetryCallbackThread = new Thread(new Runnable() { @Override public void run() { while(!toStop){ try { retryFailCallbackFile(); } catch (Exception e) { if (!toStop) { logger.error(e.getMessage(), e); } } try { TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT); } catch (InterruptedException e) { if (!toStop) { logger.error(e.getMessage(), e); } } } logger.info(">>>>>>>>>>> xxl-job, executor retry callback thread destory."); } }); triggerRetryCallbackThread.setDaemon(true); triggerRetryCallbackThread.start(); }
Example #29
Source File: TriggerCallbackThread.java From open-capacity-platform with Apache License 2.0 | 4 votes |
public void start() { // valid if (XxlJobExecutor.getAdminBizList() == null) { logger.warn(">>>>>>>>>>> xxl-job, executor callback config fail, adminAddresses is null."); return; } triggerCallbackThread = new Thread(new Runnable() { @Override public void run() { // normal callback while(!toStop){ try { HandleCallbackParam callback = getInstance().callBackQueue.take(); if (callback != null) { // callback list param List<HandleCallbackParam> callbackParamList = new ArrayList<HandleCallbackParam>(); int drainToNum = getInstance().callBackQueue.drainTo(callbackParamList); callbackParamList.add(callback); // callback, will retry if error if (callbackParamList!=null && callbackParamList.size()>0) { doCallback(callbackParamList); } } } catch (Exception e) { logger.error(e.getMessage(), e); } } // last callback try { List<HandleCallbackParam> callbackParamList = new ArrayList<HandleCallbackParam>(); int drainToNum = getInstance().callBackQueue.drainTo(callbackParamList); if (callbackParamList!=null && callbackParamList.size()>0) { doCallback(callbackParamList); } } catch (Exception e) { logger.error(e.getMessage(), e); } logger.info(">>>>>>>>>>> xxl-job, executor callback thread destory."); } }); triggerCallbackThread.setDaemon(true); triggerCallbackThread.start(); }
Example #30
Source File: ExecutorRegistryThread.java From open-capacity-platform with Apache License 2.0 | 4 votes |
public void start(final int port, final String ip, final String appName){ // valid if (appName==null || appName.trim().length()==0) { logger.warn(">>>>>>>>>>> xxl-job, executor registry config fail, appName is null."); return; } if (XxlJobExecutor.getAdminBizList() == null) { logger.warn(">>>>>>>>>>> xxl-job, executor registry config fail, adminAddresses is null."); return; } // executor address (generate addredd = ip:port) final String executorAddress; if (ip != null && ip.trim().length()>0) { executorAddress = ip.trim().concat(":").concat(String.valueOf(port)); } else { executorAddress = IpUtil.getIpPort(port); } registryThread = new Thread(new Runnable() { @Override public void run() { // registry while (!toStop) { try { RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), appName, executorAddress); for (AdminBiz adminBiz: XxlJobExecutor.getAdminBizList()) { try { ReturnT<String> registryResult = adminBiz.registry(registryParam); if (registryResult!=null && ReturnT.SUCCESS_CODE == registryResult.getCode()) { registryResult = ReturnT.SUCCESS; logger.info(">>>>>>>>>>> xxl-job registry success, registryParam:{}, registryResult:{}", new Object[]{registryParam, registryResult}); break; } else { logger.info(">>>>>>>>>>> xxl-job registry fail, registryParam:{}, registryResult:{}", new Object[]{registryParam, registryResult}); } } catch (Exception e) { logger.info(">>>>>>>>>>> xxl-job registry error, registryParam:{}", registryParam, e); } } } catch (Exception e) { logger.error(e.getMessage(), e); } try { TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT); } catch (InterruptedException e) { logger.error(e.getMessage(), e); } } // 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); } logger.info(">>>>>>>>>>> xxl-job, executor registry thread destory."); } }); registryThread.setDaemon(true); registryThread.start(); }