From 40c13eda08afa878c9635edf27a3d14193b9dc68 Mon Sep 17 00:00:00 2001 From: tison Date: Wed, 31 Jan 2024 20:10:37 +0800 Subject: [PATCH] CURATOR-XXX. Upgrade ZooKeeper version to 3.9 Signed-off-by: tison --- .../leader/ChaosMonkeyCnxnFactory.java | 11 +- curator-test-zk35/pom.xml | 2 +- curator-test-zk36/pom.xml | 1 - curator-test-zk37/pom.xml | 232 +++++++++++++++++ .../org/apache/curator/zk37}/TestIs37.java | 4 +- .../src/test/resources/log4j.properties | 25 ++ curator-test-zk38/pom.xml | 237 ++++++++++++++++++ .../org/apache/curator/zk38/TestIs38.java | 37 +++ .../src/test/resources/log4j.properties | 25 ++ .../test/compatibility/CuratorTestBase.java | 1 - pom.xml | 8 +- 11 files changed, 568 insertions(+), 15 deletions(-) create mode 100644 curator-test-zk37/pom.xml rename {curator-client/src/test/java/org/apache/curator => curator-test-zk37/src/test/java/org/apache/curator/zk37}/TestIs37.java (94%) create mode 100644 curator-test-zk37/src/test/resources/log4j.properties create mode 100644 curator-test-zk38/pom.xml create mode 100644 curator-test-zk38/src/test/java/org/apache/curator/zk38/TestIs38.java create mode 100644 curator-test-zk38/src/test/resources/log4j.properties diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/ChaosMonkeyCnxnFactory.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/ChaosMonkeyCnxnFactory.java index e6109f87ce..f6c01c4ec2 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/ChaosMonkeyCnxnFactory.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/ChaosMonkeyCnxnFactory.java @@ -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; @@ -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 diff --git a/curator-test-zk35/pom.xml b/curator-test-zk35/pom.xml index d9bfaf906a..cfb4599012 100644 --- a/curator-test-zk35/pom.xml +++ b/curator-test-zk35/pom.xml @@ -211,7 +211,7 @@ org.apache.curator:curator-recipes zk35TestCompatibility - zk36,zk37 + zk36 diff --git a/curator-test-zk36/pom.xml b/curator-test-zk36/pom.xml index 32261524de..5afd4733c0 100644 --- a/curator-test-zk36/pom.xml +++ b/curator-test-zk36/pom.xml @@ -225,7 +225,6 @@ org.apache.curator:curator-client zk36,zk35TestCompatibility - zk37 diff --git a/curator-test-zk37/pom.xml b/curator-test-zk37/pom.xml new file mode 100644 index 0000000000..062227a111 --- /dev/null +++ b/curator-test-zk37/pom.xml @@ -0,0 +1,232 @@ + + + + + + org.apache.curator + apache-curator + 5.6.1-SNAPSHOT + + 4.0.0 + + curator-test-zk37 + + + 3.7.2 + + + + + org.apache.curator + curator-framework + + + org.apache.zookeeper + zookeeper + + + + + + org.apache.curator + curator-x-async + + + org.apache.zookeeper + zookeeper + + + + + + org.apache.curator + curator-recipes + + + org.apache.zookeeper + zookeeper + + + + + + org.apache.zookeeper + zookeeper + ${zookeeper-37-version} + + + com.sun.jmx + jmxri + + + com.sun.jdmk + jmxtools + + + javax.jms + jms + + + junit + junit + + + org.slf4j + slf4j-log4j12 + + + + + + org.apache.curator + curator-test + + + org.apache.zookeeper + zookeeper + + + test + + + + org.apache.curator + curator-recipes + + + org.apache.zookeeper + zookeeper + + + test-jar + test + + + + org.apache.curator + curator-framework + + + org.apache.zookeeper + zookeeper + + + test-jar + test + + + + org.apache.curator + curator-client + + + org.apache.zookeeper + zookeeper + + + test-jar + test + + + + org.apache.commons + commons-math + test + + + + org.assertj + assertj-core + test + + + + com.fasterxml.jackson.core + jackson-core + test + + + + com.fasterxml.jackson.core + jackson-databind + test + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + ${jackson-version} + test + + + + org.junit.jupiter + junit-jupiter-api + test + + + + org.awaitility + awaitility + test + + + + org.slf4j + slf4j-log4j12 + test + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + + deploy + + true + + + deploy + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.curator:curator-framework + org.apache.curator:curator-recipes + org.apache.curator:curator-client + + zk36,zk35TestCompatibility + + + + + diff --git a/curator-client/src/test/java/org/apache/curator/TestIs37.java b/curator-test-zk37/src/test/java/org/apache/curator/zk37/TestIs37.java similarity index 94% rename from curator-client/src/test/java/org/apache/curator/TestIs37.java rename to curator-test-zk37/src/test/java/org/apache/curator/zk37/TestIs37.java index 87217875d0..328092aa3e 100644 --- a/curator-client/src/test/java/org/apache/curator/TestIs37.java +++ b/curator-test-zk37/src/test/java/org/apache/curator/zk37/TestIs37.java @@ -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 { @@ -34,7 +33,6 @@ public class TestIs37 extends CuratorTestBase { * @see ZOOKEEPER-3969 */ @Test - @Tag(zk37Group) public void testIsZk37() throws Exception { assertNotNull(Class.forName("org.apache.zookeeper.proto.WhoAmIResponse")); } diff --git a/curator-test-zk37/src/test/resources/log4j.properties b/curator-test-zk37/src/test/resources/log4j.properties new file mode 100644 index 0000000000..706484ce59 --- /dev/null +++ b/curator-test-zk37/src/test/resources/log4j.properties @@ -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 diff --git a/curator-test-zk38/pom.xml b/curator-test-zk38/pom.xml new file mode 100644 index 0000000000..93d5034677 --- /dev/null +++ b/curator-test-zk38/pom.xml @@ -0,0 +1,237 @@ + + + + + + org.apache.curator + apache-curator + 5.6.1-SNAPSHOT + + 4.0.0 + + curator-test-zk38 + + + 3.8.3 + + + + + org.apache.curator + curator-framework + + + org.apache.zookeeper + zookeeper + + + + + + org.apache.curator + curator-x-async + + + org.apache.zookeeper + zookeeper + + + + + + org.apache.curator + curator-recipes + + + org.apache.zookeeper + zookeeper + + + + + + org.apache.zookeeper + zookeeper + ${zookeeper-38-version} + + + com.sun.jmx + jmxri + + + com.sun.jdmk + jmxtools + + + javax.jms + jms + + + junit + junit + + + org.slf4j + slf4j-log4j12 + + + ch.qos.logback + logback-classic + + + + + + org.apache.curator + curator-test + + + org.apache.zookeeper + zookeeper + + + test + + + + org.apache.curator + curator-recipes + + + org.apache.zookeeper + zookeeper + + + test-jar + test + + + + org.apache.curator + curator-framework + + + org.apache.zookeeper + zookeeper + + + test-jar + test + + + + org.apache.curator + curator-client + + + org.apache.zookeeper + zookeeper + + + test-jar + test + + + + org.apache.commons + commons-math + test + + + + org.assertj + assertj-core + test + + + + com.fasterxml.jackson.core + jackson-core + test + + + + com.fasterxml.jackson.core + jackson-databind + test + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + ${jackson-version} + test + + + + org.junit.jupiter + junit-jupiter-api + test + + + + org.awaitility + awaitility + test + + + + org.slf4j + slf4j-log4j12 + test + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + + deploy + + true + + + deploy + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.curator:curator-framework + org.apache.curator:curator-recipes + org.apache.curator:curator-client + + zk36,zk35TestCompatibility + + + + + diff --git a/curator-test-zk38/src/test/java/org/apache/curator/zk38/TestIs38.java b/curator-test-zk38/src/test/java/org/apache/curator/zk38/TestIs38.java new file mode 100644 index 0000000000..2d35f88c7c --- /dev/null +++ b/curator-test-zk38/src/test/java/org/apache/curator/zk38/TestIs38.java @@ -0,0 +1,37 @@ +/* + * 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. + */ + +package org.apache.curator.zk38; + +import static org.assertj.core.api.Assertions.assertThat; +import org.apache.curator.test.compatibility.CuratorTestBase; +import org.apache.zookeeper.Version; +import org.junit.jupiter.api.Test; + +public class TestIs38 extends CuratorTestBase { + @Test + public void testIsZk38() { + assertThat(Version.getVersion()).startsWith("3.8"); + } + + @Override + protected void createServer() { + // NOP + } +} diff --git a/curator-test-zk38/src/test/resources/log4j.properties b/curator-test-zk38/src/test/resources/log4j.properties new file mode 100644 index 0000000000..706484ce59 --- /dev/null +++ b/curator-test-zk38/src/test/resources/log4j.properties @@ -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 diff --git a/curator-test/src/main/java/org/apache/curator/test/compatibility/CuratorTestBase.java b/curator-test/src/main/java/org/apache/curator/test/compatibility/CuratorTestBase.java index 47ff1e2747..8c2800b696 100644 --- a/curator-test/src/main/java/org/apache/curator/test/compatibility/CuratorTestBase.java +++ b/curator-test/src/main/java/org/apache/curator/test/compatibility/CuratorTestBase.java @@ -23,7 +23,6 @@ public class CuratorTestBase extends BaseClassForTests { public static final String zk36Group = "zk36"; - public static final String zk37Group = "zk37"; public static final String zk35TestCompatibilityGroup = "zk35TestCompatibility"; protected final Timing2 timing = new Timing2(); diff --git a/pom.xml b/pom.xml index 34dccdcb91..ceaddf3874 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,7 @@ true - 3.7.2 + 3.9.1 5.1.4 3.10.0 3.2.0 @@ -352,6 +352,8 @@ curator-x-async curator-test-zk35 curator-test-zk36 + curator-test-zk37 + curator-test-zk38 @@ -558,6 +560,10 @@ org.slf4j slf4j-log4j12 + + ch.qos.logback + logback-classic +