-
Notifications
You must be signed in to change notification settings - Fork 7.3k
ZOOKEEPER-233: Split zookeeper
module to provide separated zookeeper-client
, zookeeper-server
#2307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
6d60f35
to
6f5b154
Compare
48dcf1f
to
7de4462
Compare
I have been looking forward to this work for long time, amd I had tried in the past. Is there any recent discussion on the mailing list? |
I am dealing with osgi staffs, and planing to start discussion mail soon. Here is the continue work branch: https://github.com/kezhuw/zookeeper/commits/ZOOKEEPER-233-split-server-jar/ |
7de4462
to
6dcbe7c
Compare
@eolivelli Discussion mail posted: https://lists.apache.org/thread/j4hg8bh6y3rjg5hlzrtnod52t7xz18hv |
7008b8e
to
0781442
Compare
zookeeper-client
zookeeper
module to provide separated zookeeper-client
, zookeeper-server
…ption` `ZKConfig` is client accessible, it should avoid accessing server side `QuorumPeerConfig`. Changes: 1. Change method and constructor signatures of `ZKConfig` and `ZKClientConfig` to throw `o.a.zookeeper.common.ConfigException`. 3. Throw `QuorumPeerConfig.ConfigException` if it is in classpath. Given above changes, this pr maintain abi compatibility with old releases. **Breaking change**: methods and constructors of `ZKConfig` and `ZKClientConfig` throw `org.apache.zookeeper.common.ConfigException` now but not `QuorumPeerConfig.ConfigException`, so developers have to fix it to compile. This is a small step towards ZOOKEEPER-233. Refs: ZOOKEEPER-233, ZOOKEEPER-835, ZOOKEEPER-842, ZOOKEEPER-4970, ZOOKEEPER-4966.
The resulting `zookeeper-client` module does not depend on server side codes. Refs: ZOOKEEPER-233, ZOOKEEPER-835.
…keeper` The resulting `zookeeper-server` module does not depend on client side codes.
This makes `zookeeper` a bundle module while keep compatiblity with old `zookeeper` module. The resulting `zookeeper-cli` depends maily on `zookeeper-client`. It does depend on `QuorumPeerConfig` from `zookeeper-server` to parse quorum members. But this functionality should be exported by client also as we have `ZooKeeper::getConfig`, see ZOOKEEPER-4971.
0781442
to
da36e01
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this is really good progress. I think there may be a few small things to adjust after this. It does lay the groundwork for future work to have independent sealed jars with well-defined APIs exposed via JPMS module descriptors, too.
Aside from the couple of things I found and commented on, there are a few things that I think could be done to clean up the directory structure a bit:
- Remove "zookeeper-" from all the module directory names. We're already in the zookeeper directory.
- Instead of keeping all modules based at the root of the project checkout, you could place them in a
modules/
directory, so they can be easily viewed distinct from thebin/
,conf/
,tools/
, etc.
So, instead of:
.
├── bin
├── conf
├── dev
├── tools
├── zookeeper
├── zookeeper-assembly
├── zookeeper-cli
├── zookeeper-client
├── zookeeper-client-c
├── zookeeper-common
...
it could look more like:
.
├── bin
├── conf
├── dev
├── modules
│ ├── assembly
│ ├── cli
│ ├── client
│ ├── client-c
│ ├── common
...
The POM changes for this would be simple. For the <module>
, you just specify the path to the module like <module>modules/assembly</module>
Inside the module's POM files, you specify the <relativePath>
to the parent POM (a good practice anyway, even if it's just one level up), as in:
<parent>
<groupId>org.apache.zookeeper</groupId>
<artifactId>parent</artifactId>
<version>3.10.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
@@ -292,6 +296,7 @@ | |||
<module>zookeeper-contrib</module> | |||
<!-- zookeeper-it needed by fatjar contrib --> | |||
<module>zookeeper-it</module> | |||
<module>zookeeper-client-c</module> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is redundant with line 68 above, where this module has already been added to the normal build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it in commit 8e7eb53.
zookeeper-assembly/pom.xml
Outdated
<dependency> | ||
<groupId>org.apache.zookeeper</groupId> | ||
<artifactId>zookeeper-client</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The client should be included in the assembly, and should be declared explicitly. This old entry brought in the (useless) intermediate pom.xml file, but dropping the <type>pom</type>
line should be sufficient to explicitly declare the new zookeeper-client jar as a dependency of the assembly module.
Currently, it seems like the client is being included in the assembly indirectly, via a transitive dependency through the new OSGi library named simply zookeeper
(immediately prior dependency in this file). The same seems true of the other new jars. However, they shouldn't be brought in transitively... they should be declared explicitly, so it's easier to see what is intended to be included in the assembly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List zookeeper-client
, zookeeper-server
and zookeeper-cli
explicitly now in e690829. I think it is ok for zookeeper-common
to be included transitively ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, I prefer to have tighter control over what gets included in the assembly, so for Accumulo, we do not include any dependencies in our assembly descriptor transitively, and explicitly add them to the POM (see https://github.com/apache/accumulo/tree/2.1/assemble), using a somewhat convoluted process so we just declare what we want in the POM, and only those things get included.
ZooKeeper isn't doing any of that, so it's probably okay for zookeeper-common
to be included transitively, but I would probably include it to try to achieve some consistency.
<fileSet> | ||
<!-- ZooKeeper client generated api document --> | ||
<directory>${project.basedir}/../zookeeper-client/target/apidocs</directory> | ||
<outputDirectory>docs/apidocs/zookeeper-client</outputDirectory> | ||
<fileMode>${rw.file.permission}</fileMode> | ||
<directoryMode>${rwx.file.permission}</directoryMode> | ||
</fileSet> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never noticed before that the apidocs were being included in the ZooKeeper -bin tarball. I don't think it needs to do that. ZK already publishes the javadoc jars, which is a better way to consume the apidocs for IDEs, and for manual viewing, the published apidocs on the zookeeper.apache.org site is sufficient. I think they make the tarball too big, and the build too complicated, and they just aren't needed in the tarball. This is really just an aside comment, though. It's not related to this PR specifically.
<scope>runtime</scope> | ||
<optional>true</optional> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In previous discussions, there may have been a consensus to just use the test scope for these. It has the same effect as runtime+optional for other projects that depend on this artifact (in that, it won't automatically include the logback-classic implementation transitively, which is good, so it doesn't conflict with their preferred logging runtime), but makes it more clear that it's being included in the POM because this particular module still needs some runtime implementation for its own tests.
<scope>runtime</scope> | |
<optional>true</optional> | |
<scope>test</scope> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In previous discussions, there may have been a consensus to just use the test scope for these. I
I though it was optional
runtime
in #2155. Also, zookeeper-cli
uses org.slf4j.Loggeer
explicitly, it has no much differences to other modules. I have no much preference to this, but let's keep it consistent for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I was remembering conceding that test
was fine in my comment #2155 (review) ; however, I don't really feel strongly about it. I agree with you that consistency is the main important thing.
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<configuration> | ||
<!-- this module isn't to be deployed to Maven Central --> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's okay to skip deployment to Maven Central. However, it is also possible to deploy it there, if you want to. Apache Accumulo deploys a minimal source tarball to Maven Central, for example, that users can build in their environment for their system's architecture to add an optional native library. See https://repo1.maven.org/maven2/org/apache/accumulo/accumulo-native/2.1.4/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
We currently don't have this module published. Let's keep it separately to this and explore possible way to reuse a published native jar.
https://mvnrepository.com/artifact/org.apache.zookeeper/zookeeper-client-c
@@ -25,7 +25,6 @@ | |||
import java.util.Properties; | |||
import java.util.concurrent.CountDownLatch; | |||
import java.util.concurrent.TimeUnit; | |||
import jline.internal.Log; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Probably need a checkstyle import control rule or something to catch stuff like that in future. (as a separate patch... this PR is already big enough 😺 )
@@ -156,7 +155,7 @@ public void certificateReloadTest() throws Exception { | |||
try (ZooKeeper zk = new ZooKeeper(zkServer.getSecureConnectionString(), 60000, (WatchedEvent event) -> { | |||
switch (event.getState()) { | |||
case SyncConnected: | |||
l.countDown(); | |||
l2.countDown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a bug in the master branch right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so but I can not find a failure ci for now.
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>build bundle</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>bundle</goal> | ||
</goals> | ||
</execution> | ||
</executions> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section was copied from the old zookeeper-server
module, and is for creating the ZK OSGi bundle. However, because it exists in a new POM named simply zookeeper
, the regular jar build (non-OSGi Maven lifecycle stuff, like maven-compiler-plugin and maven-jar-plugin) still run and create what is essentially an empty zookeeper-<version>.jar
file. Because that file is still included in the binary tarball assembly descriptor, the resulting -bin.tar.gz
file in the assembly module still includes a lib/zookeeper-<version>.jar
file from this POM.
A few things should change here:
- This module's POM should probably include a comment that explains that it only exists with the name
zookeeper
to preserve compatibility with the existing OSGi bundle name. - This module's POM should disable the normal jar lifecycle build by changing to
<packaging>pom</package>
(the default isjar
, and why the regular jar lifecycle plugins get executed). See https://github.com/apache/accumulo/blob/rel/2.1.4/server/native/pom.xml#L31 for a similar scenario. That should prevent the unnecessary jar from being created, and also prevent the assembly module from including it in the tarball assembly. You may need to set the packaging on the maven-bundle-plugin config, since "jar" will no longer be inherited from the module. - Optional: if this pom's artifact was changed from
zookeeper
tozookeeper-osgi
, you could omit the classifier on the bundle object. So, the resulting jar would bezookeeper-osgi-<version>.jar
rather thanzookeeper-<version>-osgi.jar
. That rename would be a slight inconvenience perhaps, but it would make it clear that the module exists for creating the osgi bundle, and not a general placeholder for other artifacts with the common namezookeeper
.
* <p>`maven-bundle-plugin` does not include classes if there is no source code. I have no idea why. | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if that wasn't the maven-bundle-plugin, but the regular jar lifecycle plugins that was causing a problem. I mentioned how to address that in a different comment. I'm not sure if it will help to remove this class, though.
I wonder if it might be possible, as an alternative to creating this class, to have a package-info.java
javadoc class instead. I'm not really very familiar with the quirks of the maven-bundle-plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have replaced it with package-info.java
in 0c53d33.
Split
zookeeper
to separated modules:zookeeper-common
contains common codes for client and server and depends only onzookeeper-jute
.zookeeper-client
contains only client side codes and depends only onzookeeper-jute
andzookeeper-common
. Currently, most of its tests reside inzookeeper-server
still.zookeeper-server
contains only server side code and depends only onzookeeper-jute
andzookeeper-common
. It depend onzookeeper-client
only for tests.zookeeper-cli
contains codes for command line client. It depends mainly onzookeeper-client
, but alsozookeeper-server
forQuorumPeerConfig.parseDynamicConfig
to parse quorum members.zookeeper
bundles above modules and keeps compatibility with oldzookeeper
artifact.Possible future steps:
zookeeper-client-it
for client side tests that requiring server functionality.zookeeper-cli
to dedicated quorum config parse method(ZOOKEEPER-4971) to make itzookeeper-server
free. Then, we probably can rename it tozookeeper-client-cli
.