zoukankan      html  css  js  c++  java
  • Zookeeper源码调试环境踩坑记录

    1. 下载源码

    本文基于zookeeper源码3.6.2版本。

    zookeeper的源码在github上(https://github.com/apache/zookeeper

    2. 找入口类

    zookeeper是一个java项目,启动时有启动脚本,执行命令./zkServer conf/zoo.cfg即可。那么我们可以从这个脚本中找到最终执行的java启动类,为QuarumPeerMain这个主类。

    3. 启动报错

    知道主类后,我们在idea中配置zookeeper的启动参数。zookeeper启动时需要一个配置文件,我们可以从源码的根目录下的conf文件中zoo_sample.cfg复制一份改名为zoo.cfg。然后启动main方法。

    发现报如下错误:


    冒失缺失了一个类,导入对应的maven坐标还是无法解决。最后找到一种方法,将该main方法放到test类下面即可。如QuarumPeerMainTest。将QuarumPeerMain的main方法复制到QuarumPeerMainTest类中。再次启动即可。

        public static void main(String[] args) {
            args = new String[1];
            args[0] = "zoo.cfg";
            QuorumPeerMain main = new QuorumPeerMain();
            try {
                main.initializeAndRun(args);
            } catch (IllegalArgumentException e) {
                LOG.error("Invalid arguments, exiting abnormally", e);
                //LOG.info(USAGE);
                //System.err.println(USAGE);
                ZKAuditProvider.addServerStartFailureAuditLog();
                ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue());
            } catch (QuorumPeerConfig.ConfigException e) {
                LOG.error("Invalid config, exiting abnormally", e);
                System.err.println("Invalid config, exiting abnormally");
                ZKAuditProvider.addServerStartFailureAuditLog();
                ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue());
            } catch (FileTxnSnapLog.DatadirException e) {
                LOG.error("Unable to access datadir, exiting abnormally", e);
                System.err.println("Unable to access datadir, exiting abnormally");
                ZKAuditProvider.addServerStartFailureAuditLog();
                ServiceUtils.requestSystemExit(ExitCode.UNABLE_TO_ACCESS_DATADIR.getValue());
            } catch (AdminServer.AdminServerException e) {
                LOG.error("Unable to start AdminServer, exiting abnormally", e);
                System.err.println("Unable to start AdminServer, exiting abnormally");
                ZKAuditProvider.addServerStartFailureAuditLog();
                ServiceUtils.requestSystemExit(ExitCode.ERROR_STARTING_ADMIN_SERVER.getValue());
            } catch (Exception e) {
                LOG.error("Unexpected exception, exiting abnormally", e);
                ZKAuditProvider.addServerStartFailureAuditLog();
                ServiceUtils.requestSystemExit(ExitCode.UNEXPECTED_ERROR.getValue());
            }
            LOG.info("Exiting normally");
            ServiceUtils.requestSystemExit(ExitCode.EXECUTION_FINISHED.getValue());
        }


     
     
     
     
  • 相关阅读:
    jeecg t:treeSelectTag 联动处理
    saas动态数据源
    jquery ajax超时设置
    创建mysql 数据库脚本
    Java动态创建MySQL数据库
    ant执行sql脚本
    jeecg jeewx 多表查询展示
    @JoinColumn 详解
    hibernate关联映射注解及@JoinColumn的用法
    算发帖——俄罗斯方块覆盖问题一共有多少个解
  • 原文地址:https://www.cnblogs.com/wqsbk/p/13666889.html
Copyright © 2011-2022 走看看