zookeeper (6) Based on Idea start zookeeper source, open source Tour

Zookeeper study the source code, the first step is to build the environment, using the idea to start zk source, the process is relatively simple, the online tutorial is a lot, but to engage them or will encounter a variety of problems here to be a record.

Environment Introduction

. 1, Version 3.5.5 zookeeper source
2, idea editor
3, based ant build zookeeper

step

1, install ant, and add environment variables

1, Download: https://ant.apache.org/bindownload.cgi
2, download version: 1.10.7, zip bag
3, extract, configure the environment variables ANT_HOME = D: \ apache-ant -1.10.7-bin \ the Apache Ant-1.10.7-
4, edit Path, ANT_HOME% increase% \ bin
5, edit the classpath, increase% ANT_HOME% \ lib

2, zookeeper source code and build

1, zk download Source: https://github.com/apache/zookeeper
2, switching to the branch: Branch Checkout Git-3.5.5
. 3, performing ant eclipse Construction: zk project idea is not supported, all constructed using ant eclipse directly into eclipse project, building a successful build success indicator appears.
zookeeper (6) Based on Idea start zookeeper source, open source Tour

Generally here without error.

Import idea zookeeper

1, using the idea into eclipse project

zookeeper (6) Based on Idea start zookeeper source, open source Tour

2. Select the eclipse project, has been next to.

zookeeper (6) Based on Idea start zookeeper source, open source Tour

3, start the project, test.

1, start the zookeeper service, locate the file ZooKeeperServerMain, and calls the main method.
2, found an error, class Info under Version.java can not be found, you need to create a new class.
3, the new Info file, you can

package org.apache.zookeeper.version;

public interface Info {
    int MAJOR=1;
    int MINOR=0;
    int MICRO=0;
    String QUALIFIER=null;
    int REVISION=-1; //TODO: remove as related to SVN VCS
    String REVISION_HASH="1";
    String BUILD_DATE="2019-3-4";
}

Note: If you can not find the other categories, need more than a few times ant eclipse, or re-pull zk code, re-execute ant eclipse. Here I also encountered this situation, after several on it. As for why not get an answer!

If the startup experience the following:
zookeeper (6) Based on Idea start zookeeper source, open source Tour

Log4j configuration needs to be configured, with reference to the next configuration.

4, configure the startup parameters ZooKeeperServerMain
zookeeper (6) Based on Idea start zookeeper source, open source Tour

5, re-execute the main method ZooKeeperServerMain, start the zookeeper service.
zookeeper (6) Based on Idea start zookeeper source, open source Tour

6. Do not pay attention to 8080 port is occupied by another process, because the need to start this port.

7, whether to start locally using zkCli.cmd testing services

zookeeper (6) Based on Idea start zookeeper source, open source Tour

Then you can try zookeeper in a variety of test, debug the code, the source code of the tour.

Guess you like

Origin blog.51cto.com/janephp/2449812