Skip to content

Commit 538a455

Browse files
committed
The resulting `zookeeper-server` module does not depend on client side codes.
1 parent 383878a commit 538a455

File tree

186 files changed

+769
-329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+769
-329
lines changed

.typos.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@
4848

4949
[files]
5050
extend-exclude = [
51-
"zookeeper-client/src/test/java/org/apache/zookeeper/common/CertificatesToPlayWith.java",
51+
"zookeeper-common/src/test/java/org/apache/zookeeper/common/CertificatesToPlayWith.java",
5252
]

bin/zkEnv.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ for d in "$ZOOBINDIR"/../build/lib/*.jar; do
104104
done
105105

106106
#make it work for developers
107-
for d in "$ZOOBINDIR"/../zookeeper-server/target/lib/*.jar; do
107+
for d in "$ZOOBINDIR"/../zookeeper/target/lib/*.jar; do
108108
CLASSPATH="$d:$CLASSPATH"
109109
done
110110

@@ -117,6 +117,8 @@ done
117117
CLASSPATH="$ZOOBINDIR/../build/classes:$CLASSPATH"
118118

119119
#make it work for developers
120+
CLASSPATH="$ZOOBINDIR/../zookeeper-client/target/classes:$CLASSPATH"
121+
CLASSPATH="$ZOOBINDIR/../zookeeper-common/target/classes:$CLASSPATH"
120122
CLASSPATH="$ZOOBINDIR/../zookeeper-server/target/classes:$CLASSPATH"
121123

122124
#make it work for developers

checkstyleSuppressions.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,20 @@
2424
<suppress checks="LineLength" files=".+[\\/]jute[\\/].+\.java"/>
2525

2626
<!-- TODO ZOOKEEPER-3508 -->
27+
<suppress checks="LineLength" files=".+[\\/]zookeeper[\\/].+\.java"/>
28+
<suppress checks="LineLength" files=".+[\\/]zookeeper-common[\\/].+\.java"/>
2729
<suppress checks="LineLength" files=".+[\\/]zookeeper-client[\\/].+\.java"/>
2830
<suppress checks="LineLength" files=".+[\\/]zookeeper-server[\\/].+\.java"/>
2931

3032
<!-- TODO ZOOKEEPER-3507 -->
33+
<suppress checks=".*Name.*" files=".+[\\/]zookeeper[\\/].+\.java"/>
34+
<suppress checks=".*Name.*" files=".+[\\/]zookeeper-common[\\/].+\.java"/>
3135
<suppress checks=".*Name.*" files=".+[\\/]zookeeper-client[\\/].+\.java"/>
3236
<suppress checks=".*Name.*" files=".+[\\/]zookeeper-server[\\/].+\.java"/>
3337

3438
<!-- TODO ZOOKEEPER-3469 -->
39+
<suppress checks="Javadoc.+" files=".+[\\/]zookeeper[\\/].+\.java"/>
40+
<suppress checks="Javadoc.+" files=".+[\\/]zookeeper-common[\\/].+\.java"/>
3541
<suppress checks="Javadoc.+" files=".+[\\/]zookeeper-client[\\/].+\.java"/>
3642
<suppress checks="Javadoc.+" files=".+[\\/]zookeeper-server[\\/].+\.java"/>
3743
</suppressions>

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@
5757
</licenses>
5858

5959
<modules>
60+
<module>zookeeper</module>
6061
<module>zookeeper-docs</module>
6162
<module>zookeeper-jute</module>
6263
<module>zookeeper-server</module>
6364
<module>zookeeper-metrics-providers</module>
65+
<module>zookeeper-common</module>
6466
<module>zookeeper-client</module>
6567
<module>zookeeper-client-c</module>
6668
<module>zookeeper-recipes</module>

zookeeper-assembly/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@
6464
<artifactId>zookeeper</artifactId>
6565
<version>${project.version}</version>
6666
</dependency>
67-
<dependency>
68-
<groupId>org.apache.zookeeper</groupId>
69-
<artifactId>zookeeper-client</artifactId>
70-
<version>${project.version}</version>
71-
</dependency>
7267
<dependency>
7368
<groupId>org.apache.zookeeper</groupId>
7469
<artifactId>zookeeper-prometheus-metrics</artifactId>

zookeeper-assembly/src/main/assembly/bin-package.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,16 @@
7676
<fileMode>${rw.file.permission}</fileMode>
7777
<directoryMode>${rwx.file.permission}</directoryMode>
7878
</fileSet>
79+
<fileSet>
80+
<!-- ZooKeeper cli generated api document -->
81+
<directory>${project.basedir}/../zookeeper/target/apidocs</directory>
82+
<outputDirectory>docs/apidocs/zookeeper-server</outputDirectory>
83+
<fileMode>${rw.file.permission}</fileMode>
84+
<directoryMode>${rwx.file.permission}</directoryMode>
85+
</fileSet>
7986
<fileSet>
8087
<!-- License files for 3rd party libs -->
81-
<directory>${project.basedir}/../zookeeper-server/src/main/resources/lib</directory>
88+
<directory>${project.basedir}/../zookeeper/src/main/resources/lib</directory>
8289
<includes>
8390
<include>*.txt</include>
8491
</includes>

zookeeper-client-c/tests/zkServer.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,15 @@ fi
8383

8484
CLASSPATH="$CLASSPATH:$zk_base/build/classes"
8585
CLASSPATH="$CLASSPATH:$zk_base/conf"
86-
CLASSPATH="$CLASSPATH:$zk_base/zookeeper-server/target/classes"
8786

8887
for i in "$zk_base"/build/lib/*.jar; do
8988
CLASSPATH="$CLASSPATH:$i"
9089
done
9190

92-
for d in "$zk_base"/zookeeper-server/target/lib/*.jar; do
91+
for d in "$zk_base"/zookeeper/target/lib/*.jar; do
9392
CLASSPATH="$d:$CLASSPATH"
9493
done
9594

96-
for i in "$zk_base"/zookeeper-server/src/main/resource/lib/*.jar; do
97-
CLASSPATH="$CLASSPATH:$i"
98-
done
99-
10095
CLASSPATH="$CLASSPATH:$CLOVER_HOME/lib/clover*.jar"
10196

10297
if $cygwin; then

zookeeper-client/pom.xml

Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
<artifactId>zookeeper-jute</artifactId>
3838
<version>${project.version}</version>
3939
</dependency>
40+
<dependency>
41+
<groupId>org.apache.zookeeper</groupId>
42+
<artifactId>zookeeper-common</artifactId>
43+
<version>${project.version}</version>
44+
</dependency>
4045

4146
<!-- annotations -->
4247
<dependency>
@@ -135,64 +140,6 @@
135140

136141
<build>
137142
<plugins>
138-
<plugin>
139-
<groupId>org.codehaus.mojo</groupId>
140-
<artifactId>build-helper-maven-plugin</artifactId>
141-
<executions>
142-
<execution>
143-
<!-- ${maven.build.timestamp} does not support timezone :( -->
144-
<id>build-time</id>
145-
<goals>
146-
<goal>timestamp-property</goal>
147-
</goals>
148-
<configuration>
149-
<name>build.time</name>
150-
<pattern>yyyy-MM-dd HH:mm zz</pattern>
151-
<locale>en_US</locale>
152-
<timeZone>UTC</timeZone>
153-
</configuration>
154-
</execution>
155-
<execution>
156-
<id>parse-version</id>
157-
<goals>
158-
<goal>parse-version</goal>
159-
</goals>
160-
</execution>
161-
<execution>
162-
<phase>generate-sources</phase>
163-
<goals>
164-
<goal>add-source</goal>
165-
</goals>
166-
<configuration>
167-
<sources>
168-
<source>${project.build.directory}/generated-sources/java</source>
169-
</sources>
170-
</configuration>
171-
</execution>
172-
</executions>
173-
</plugin>
174-
<plugin>
175-
<groupId>org.apache.maven.plugins</groupId>
176-
<artifactId>maven-resources-plugin</artifactId>
177-
<executions>
178-
<execution>
179-
<id>prepare-filtered-java-source</id>
180-
<goals>
181-
<goal>copy-resources</goal>
182-
</goals>
183-
<phase>generate-sources</phase>
184-
<configuration>
185-
<outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
186-
<resources>
187-
<resource>
188-
<directory>src/main/java-filtered</directory>
189-
<filtering>true</filtering>
190-
</resource>
191-
</resources>
192-
</configuration>
193-
</execution>
194-
</executions>
195-
</plugin>
196143

197144
<plugin>
198145
<groupId>org.apache.maven.plugins</groupId>

zookeeper-client/src/main/java/org/apache/zookeeper/ZKUtil.java

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,24 @@
1818

1919
package org.apache.zookeeper;
2020

21-
import java.io.File;
2221
import java.util.ArrayDeque;
2322
import java.util.ArrayList;
2423
import java.util.Collections;
2524
import java.util.List;
26-
import java.util.Map;
2725
import java.util.Queue;
28-
import java.util.concurrent.ConcurrentHashMap;
2926
import java.util.concurrent.Semaphore;
3027
import java.util.concurrent.atomic.AtomicBoolean;
3128
import org.apache.zookeeper.AsyncCallback.MultiCallback;
3229
import org.apache.zookeeper.AsyncCallback.StringCallback;
3330
import org.apache.zookeeper.AsyncCallback.VoidCallback;
3431
import org.apache.zookeeper.KeeperException.Code;
3532
import org.apache.zookeeper.common.PathUtils;
36-
import org.apache.zookeeper.data.ACL;
3733
import org.slf4j.Logger;
3834
import org.slf4j.LoggerFactory;
3935

40-
public class ZKUtil {
36+
public class ZKUtil extends ZKCommonUtil {
4137

4238
private static final Logger LOG = LoggerFactory.getLogger(ZKUtil.class);
43-
private static final Map<Integer, String> permCache = new ConcurrentHashMap<>();
4439
/**
4540
* Recursively delete the node with the given path.
4641
* <p>
@@ -166,24 +161,6 @@ public static void deleteRecursive(
166161
}
167162
}
168163

169-
/**
170-
* @param filePath the file path to be validated
171-
* @return Returns null if valid otherwise error message
172-
*/
173-
public static String validateFileInput(String filePath) {
174-
File file = new File(filePath);
175-
if (!file.exists()) {
176-
return "File '" + file.getAbsolutePath() + "' does not exist.";
177-
}
178-
if (!file.canRead()) {
179-
return "Read permission is denied on the file '" + file.getAbsolutePath() + "'";
180-
}
181-
if (file.isDirectory()) {
182-
return "'" + file.getAbsolutePath() + "' is a directory. it must be a file.";
183-
}
184-
return null;
185-
}
186-
187164
/**
188165
* BFS Traversal of the system under pathRoot, with the entries in the list, in the
189166
* same order as that of the traversal.
@@ -266,45 +243,4 @@ private static void visitSubTreeDFSHelper(
266243
return; // ignore
267244
}
268245
}
269-
270-
/**
271-
* @param perms
272-
* ACL permissions
273-
* @return string representation of permissions
274-
*/
275-
public static String getPermString(int perms) {
276-
return permCache.computeIfAbsent(perms, k -> constructPermString(k));
277-
}
278-
279-
private static String constructPermString(int perms) {
280-
StringBuilder p = new StringBuilder();
281-
if ((perms & ZooDefs.Perms.CREATE) != 0) {
282-
p.append('c');
283-
}
284-
if ((perms & ZooDefs.Perms.DELETE) != 0) {
285-
p.append('d');
286-
}
287-
if ((perms & ZooDefs.Perms.READ) != 0) {
288-
p.append('r');
289-
}
290-
if ((perms & ZooDefs.Perms.WRITE) != 0) {
291-
p.append('w');
292-
}
293-
if ((perms & ZooDefs.Perms.ADMIN) != 0) {
294-
p.append('a');
295-
}
296-
return p.toString();
297-
}
298-
299-
public static String aclToString(List<ACL> acls) {
300-
StringBuilder sb = new StringBuilder();
301-
for (ACL acl : acls) {
302-
sb.append(acl.getId().getScheme());
303-
sb.append(":");
304-
sb.append(acl.getId().getId());
305-
sb.append(":");
306-
sb.append(getPermString(acl.getPerms()));
307-
}
308-
return sb.toString();
309-
}
310246
}

zookeeper-client/src/main/java/org/apache/zookeeper/client/ZKClientConfig.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.nio.file.Path;
2323
import org.apache.yetus.audience.InterfaceAudience;
2424
import org.apache.zookeeper.common.ConfigException;
25+
import org.apache.zookeeper.common.SaslLoginKeys;
2526
import org.apache.zookeeper.common.ZKConfig;
2627

2728
/**
@@ -35,8 +36,8 @@ public class ZKClientConfig extends ZKConfig {
3536
public static final String ZK_SASL_CLIENT_USERNAME_DEFAULT = "zookeeper";
3637
public static final String ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME = "zookeeper.sasl.client.canonicalize.hostname";
3738
public static final String ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME_DEFAULT = "true";
38-
public static final String LOGIN_CONTEXT_NAME_KEY = "zookeeper.sasl.clientconfig";
39-
public static final String LOGIN_CONTEXT_NAME_KEY_DEFAULT = "Client";
39+
public static final String LOGIN_CONTEXT_NAME_KEY = SaslLoginKeys.CLIENT_NAME_KEY;
40+
public static final String LOGIN_CONTEXT_NAME_KEY_DEFAULT = SaslLoginKeys.CLIENT_NAME_KEY_DEFAULT;
4041
public static final String ENABLE_CLIENT_SASL_KEY = "zookeeper.sasl.client";
4142
public static final String ENABLE_CLIENT_SASL_DEFAULT = "true";
4243
public static final String ZOOKEEPER_SERVER_REALM = "zookeeper.server.realm";
@@ -121,6 +122,11 @@ protected void handleBackwardCompatibility() {
121122
setProperty(SECURE_CLIENT, System.getProperty(SECURE_CLIENT));
122123
}
123124

125+
@Override
126+
public boolean isClient() {
127+
return true;
128+
}
129+
124130
/**
125131
* Returns true if the SASL client is enabled. By default, the client is
126132
* enabled but can be disabled by setting the system property

0 commit comments

Comments
 (0)