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());
        }


     
     
     
     
  • 相关阅读:
    vue项目中使用定时器,离开页面时清除定时器
    不能在循环中使用res.send(err);
    React使用require加载图片失败
    实验五 单元测试
    实验四 代码评审
    UML 建模工具的安装与使用
    结对编程 第二阶段
    结对编程
    GIT 代码版本管理
    结构化方法与面向对象化方法的比较
  • 原文地址:https://www.cnblogs.com/wqsbk/p/13666889.html
Copyright © 2011-2022 走看看