NOTE

Building ZooKeeper from Source

How to identify ZooKeeper's startup class and build/start its source code with Ant or Maven.

ZooKeeperCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. What Is the Startup Class?

  • It can be seen from line 71 of zkServer.sh.
ZOOMAIN="org.apache.zookeeper.server.quorum.QuorumPeerMain"
  • It can also be seen by using jps -l after startup.
org.apache.zookeeper.server.quorum.QuorumPeerMain

2. Starting from Source Code

2.1. Ant Environment

2.1.1. Configure the Ant Environment

ant -version

2.1.2. Clone the Code and Compile with Ant

  • Clone
git clone <EMAIL>:apache/zookeeper.git
  • Compile with Ant
ant eclipse

2.1.3. Import into IDEA

2.1.4. Create a Version File

package org.apache.zookeeper.version;

/**
 * @description:
 * @author: [REDACTED]
 * @create: 2020-04-01 21:28
 **/
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";
}

2.1.5. Start

  • Arguments
-Dlog4j.configuration=file:<USER_HOME>\code\demo\zookeeper-3.4.14\conf\log4j.properties

<USER_HOME>\code\demo\zookeeper-3.4.14\conf\zoo.cfg

2.2. Maven Environment

2.2.1. Compile

Directly import the root project, then execute:

mvn clean package install -Dmaven.test.skip=true

2.2.2. Create a Version File

package org.apache.zookeeper.version;

/**
 * @description:
 * @author: [REDACTED]
 * @create: 2020-04-01 21:28
 **/
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";
}

2.2.3. Start

3. References

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub