Skip to content

Commit

Permalink
CURATOR-XXX. Upgrade ZooKeeper version to 3.9
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Jan 31, 2024
1 parent 2f1fc4e commit 40c13ed
Show file tree
Hide file tree
Showing 11 changed files with 568 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
package org.apache.curator.framework.recipes.leader;

import java.io.IOException;
import java.nio.ByteBuffer;
import org.apache.curator.test.Compatibility;
import org.apache.curator.test.TestingZooKeeperMain;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.proto.CreateRequest;
import org.apache.zookeeper.server.ByteBufferInputStream;
import org.apache.zookeeper.server.NIOServerCnxnFactory;
import org.apache.zookeeper.server.Request;
import org.apache.zookeeper.server.ZooKeeperServer;
Expand Down Expand Up @@ -81,22 +79,19 @@ public void submitRequest(Request si) {
&& si.type != ZooDefs.OpCode.ping
&& firstError != 0
&& remaining > 0) {
log.debug("Rejected : " + si.toString());
log.debug("Rejected : {}", si);
// Still reject request
log.debug("Still not ready for " + remaining + "ms");
Compatibility.serverCnxnClose(si.cnxn);
return;
}
// Submit the request to the legacy Zookeeper server
log.debug("Applied : " + si.toString());
log.debug("Applied : {}", si);
super.submitRequest(si);
// Raise an error if a lock is created
if ((si.type == ZooDefs.OpCode.create) || (si.type == ZooDefs.OpCode.create2)) {
CreateRequest createRequest = new CreateRequest();
try {
ByteBuffer duplicate = si.request.duplicate();
duplicate.rewind();
ByteBufferInputStream.byteBuffer2Record(duplicate, createRequest);
CreateRequest createRequest = si.readRequestRecord(CreateRequest::new);
if (createRequest.getPath().startsWith(CHAOS_ZNODE_PREFIX) && firstError == 0) {
firstError = System.currentTimeMillis();
// The znode has been created, close the connection and don't tell it to client
Expand Down
2 changes: 1 addition & 1 deletion curator-test-zk35/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
<dependency>org.apache.curator:curator-recipes</dependency>
</dependenciesToScan>
<groups>zk35TestCompatibility</groups>
<excludedGroups>zk36,zk37</excludedGroups>
<excludedGroups>zk36</excludedGroups>
</configuration>
</plugin>
</plugins>
Expand Down
1 change: 0 additions & 1 deletion curator-test-zk36/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@
<dependency>org.apache.curator:curator-client</dependency>
</dependenciesToScan>
<groups>zk36,zk35TestCompatibility</groups>
<excludedGroups>zk37</excludedGroups>
</configuration>
</plugin>
</plugins>
Expand Down
232 changes: 232 additions & 0 deletions curator-test-zk37/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
<version>5.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>curator-test-zk37</artifactId>

<properties>
<zookeeper-37-version>3.7.2</zookeeper-37-version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-x-async</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper-37-version}</version>
<exclusions>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-client</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${jackson-version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<phase>deploy</phase>
<configuration>
<skip>true</skip>
</configuration>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<dependenciesToScan>
<dependency>org.apache.curator:curator-framework</dependency>
<dependency>org.apache.curator:curator-recipes</dependency>
<dependency>org.apache.curator:curator-client</dependency>
</dependenciesToScan>
<excludedGroups>zk36,zk35TestCompatibility</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
* under the License.
*/

package org.apache.curator;
package org.apache.curator.zk37;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.zookeeper.proto.WhoAmIResponse;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

public class TestIs37 extends CuratorTestBase {
Expand All @@ -34,7 +33,6 @@ public class TestIs37 extends CuratorTestBase {
* @see <a href="https://issues.apache.org/jira/browse/ZOOKEEPER-3969">ZOOKEEPER-3969</a>
*/
@Test
@Tag(zk37Group)
public void testIsZk37() throws Exception {
assertNotNull(Class.forName("org.apache.zookeeper.proto.WhoAmIResponse"));
}
Expand Down
25 changes: 25 additions & 0 deletions curator-test-zk37/src/test/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

log4j.rootLogger=ERROR, console

log4j.logger.org.apache.curator=DEBUG, console
log4j.additivity.org.apache.curator=false

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p %c %x %m [%t]%n
Loading

0 comments on commit 40c13ed

Please sign in to comment.