com.xxl.job.core.biz.model.RegistryParam Java Examples

The following examples show how to use com.xxl.job.core.biz.model.RegistryParam. 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: AdminBizTest.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
/**
 * registry executor remove
 *
 * @throws Exception
 */
@Test
public void registryRemove() throws Exception {
    addressUrl = addressUrl.replace("http://", "");
    AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(
            NetEnum.JETTY,
            Serializer.SerializeEnum.HESSIAN.getSerializer(),
            CallType.SYNC,
            LoadBalance.ROUND,
            AdminBiz.class,
            null,
            10000,
            addressUrl,
            accessToken,
            null,
            null).getObject();

    // test executor registry remove
    RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
    ReturnT<String> returnT = adminBiz.registryRemove(registryParam);
    Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);

    // stop invoker
    XxlRpcInvokerFactory.getInstance().stop();
}
 
Example #2
Source File: AdminBizTest.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
/**
 * registry executor
 *
 * @throws Exception
 */
@Test
public void registryTest() throws Exception {
    addressUrl = addressUrl.replace("http://", "");
    AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(
            NetEnum.JETTY,
            Serializer.SerializeEnum.HESSIAN.getSerializer(),
            CallType.SYNC,
            LoadBalance.ROUND,
            AdminBiz.class,
            null,
            10000,
            addressUrl,
            accessToken,
            null,
            null).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);

    // stop invoker
    XxlRpcInvokerFactory.getInstance().stop();
}
 
Example #3
Source File: AdminBizImpl.java    From xxl-job with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ReturnT<String> registryRemove(RegistryParam registryParam) {

    // valid
    if (!StringUtils.hasText(registryParam.getRegistryGroup())
            || !StringUtils.hasText(registryParam.getRegistryKey())
            || !StringUtils.hasText(registryParam.getRegistryValue())) {
        return new ReturnT<String>(ReturnT.FAIL_CODE, "Illegal Argument.");
    }

    int ret = xxlJobRegistryDao.registryDelete(registryParam.getRegistryGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    if (ret > 0) {

        // fresh
        freshGroupRegistryInfo(registryParam);
    }
    return ReturnT.SUCCESS;
}
 
Example #4
Source File: AdminBizImpl.java    From xxl-job with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ReturnT<String> registry(RegistryParam registryParam) {

    // valid
    if (!StringUtils.hasText(registryParam.getRegistryGroup())
            || !StringUtils.hasText(registryParam.getRegistryKey())
            || !StringUtils.hasText(registryParam.getRegistryValue())) {
        return new ReturnT<String>(ReturnT.FAIL_CODE, "Illegal Argument.");
    }

    int ret = xxlJobRegistryDao.registryUpdate(registryParam.getRegistryGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue(), new Date());
    if (ret < 1) {
        xxlJobRegistryDao.registrySave(registryParam.getRegistryGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue(), new Date());

        // fresh
        freshGroupRegistryInfo(registryParam);
    }
    return ReturnT.SUCCESS;
}
 
Example #5
Source File: AdminBizImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> registry(RegistryParam registryParam) {
    int ret = xxlJobRegistryDao.registryUpdate(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    if (ret < 1) {
        xxlJobRegistryDao.registrySave(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    }
    return ReturnT.SUCCESS;
}
 
Example #6
Source File: AdminBizImpl.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> registry(RegistryParam registryParam) {
    int ret = xxlJobRegistryDao.registryUpdate(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    if (ret < 1) {
        xxlJobRegistryDao.registrySave(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    }
    return ReturnT.SUCCESS;
}
 
Example #7
Source File: AdminBizImpl.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> registry(RegistryParam registryParam) {
    int ret = xxlJobRegistryDao.registryUpdate(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    if (ret < 1) {
        xxlJobRegistryDao.registrySave(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    }
    return ReturnT.SUCCESS;
}
 
Example #8
Source File: AdminBizImpl.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> registry(RegistryParam registryParam) {
    int ret = xxlJobRegistryDao.registryUpdate(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    if (ret < 1) {
        xxlJobRegistryDao.registrySave(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    }
    return ReturnT.SUCCESS;
}
 
Example #9
Source File: AdminBizTest.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
/**
 * registry executor
 *
 * @throws Exception
 */
@Test
public void registry() throws Exception {
    AdminBiz adminBiz = new AdminBizClient(addressUrl, accessToken);

    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);
}
 
Example #10
Source File: AdminBizTest.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
/**
 * registry executor remove
 *
 * @throws Exception
 */
@Test
public void registryRemove() throws Exception {
    AdminBiz adminBiz = new AdminBizClient(addressUrl, accessToken);

    RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
    ReturnT<String> returnT = adminBiz.registryRemove(registryParam);

    Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);

}
 
Example #11
Source File: ExecutorRegistryThread.java    From xxl-job with GNU General Public License v3.0 4 votes vote down vote up
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 #12
Source File: ExecutorRegistryThread.java    From zuihou-admin-boot with Apache License 2.0 4 votes vote down vote up
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 #13
Source File: AdminBizClient.java    From xxl-job with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ReturnT<String> registryRemove(RegistryParam registryParam) {
    return XxlJobRemotingUtil.postBody(addressUrl + "api/registryRemove", accessToken, timeout, registryParam, String.class);
}
 
Example #14
Source File: AdminBizImpl.java    From xxl-job with GNU General Public License v3.0 4 votes vote down vote up
private void freshGroupRegistryInfo(RegistryParam registryParam){
    // Under consideration, prevent affecting core tables
}
 
Example #15
Source File: AdminBizClient.java    From xxl-job with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ReturnT<String> registry(RegistryParam registryParam) {
    return XxlJobRemotingUtil.postBody(addressUrl + "api/registry", accessToken, timeout, registryParam, String.class);
}
 
Example #16
Source File: ExecutorRegistryThread.java    From zuihou-admin-cloud with Apache License 2.0 4 votes vote down vote up
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 #17
Source File: AdminBizImpl.java    From zuihou-admin-cloud with Apache License 2.0 4 votes vote down vote up
@Override
public ReturnT<String> registryRemove(RegistryParam registryParam) {
    xxlJobRegistryDao.registryDelete(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    return ReturnT.SUCCESS;
}
 
Example #18
Source File: AdminBizImpl.java    From zuihou-admin-boot with Apache License 2.0 4 votes vote down vote up
@Override
public ReturnT<String> registryRemove(RegistryParam registryParam) {
    xxlJobRegistryDao.registryDelete(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    return ReturnT.SUCCESS;
}
 
Example #19
Source File: AdminBizImpl.java    From microservices-platform with Apache License 2.0 4 votes vote down vote up
@Override
public ReturnT<String> registryRemove(RegistryParam registryParam) {
    xxlJobRegistryDao.registryDelete(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    return ReturnT.SUCCESS;
}
 
Example #20
Source File: ExecutorRegistryThread.java    From microservices-platform with Apache License 2.0 4 votes vote down vote up
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 #21
Source File: AdminBizImpl.java    From open-capacity-platform with Apache License 2.0 4 votes vote down vote up
@Override
public ReturnT<String> registryRemove(RegistryParam registryParam) {
    xxlJobRegistryDao.registryDelete(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
    return ReturnT.SUCCESS;
}
 
Example #22
Source File: ExecutorRegistryThread.java    From open-capacity-platform with Apache License 2.0 4 votes vote down vote up
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();
    }
 
Example #23
Source File: AdminBiz.java    From open-capacity-platform with Apache License 2.0 2 votes vote down vote up
/**
 * registry
 *
 * @param registryParam
 * @return
 */
public ReturnT<String> registry(RegistryParam registryParam);
 
Example #24
Source File: AdminBiz.java    From zuihou-admin-boot with Apache License 2.0 2 votes vote down vote up
/**
 * registry remove
 *
 * @param registryParam
 * @return
 */
public ReturnT<String> registryRemove(RegistryParam registryParam);
 
Example #25
Source File: AdminBiz.java    From zuihou-admin-cloud with Apache License 2.0 2 votes vote down vote up
/**
 * registry
 *
 * @param registryParam
 * @return
 */
public ReturnT<String> registry(RegistryParam registryParam);
 
Example #26
Source File: AdminBiz.java    From zuihou-admin-cloud with Apache License 2.0 2 votes vote down vote up
/**
 * registry remove
 *
 * @param registryParam
 * @return
 */
public ReturnT<String> registryRemove(RegistryParam registryParam);
 
Example #27
Source File: AdminBiz.java    From zuihou-admin-boot with Apache License 2.0 2 votes vote down vote up
/**
 * registry
 *
 * @param registryParam
 * @return
 */
public ReturnT<String> registry(RegistryParam registryParam);
 
Example #28
Source File: AdminBiz.java    From xxl-job with GNU General Public License v3.0 2 votes vote down vote up
/**
 * registry
 *
 * @param registryParam
 * @return
 */
public ReturnT<String> registry(RegistryParam registryParam);
 
Example #29
Source File: AdminBiz.java    From xxl-job with GNU General Public License v3.0 2 votes vote down vote up
/**
 * registry remove
 *
 * @param registryParam
 * @return
 */
public ReturnT<String> registryRemove(RegistryParam registryParam);
 
Example #30
Source File: AdminBiz.java    From microservices-platform with Apache License 2.0 2 votes vote down vote up
/**
 * registry remove
 *
 * @param registryParam
 * @return
 */
public ReturnT<String> registryRemove(RegistryParam registryParam);