From 729e83ca4e40aaae5169b6249fce3522fd7e6c16 Mon Sep 17 00:00:00 2001 From: stellar Date: Tue, 2 Apr 2024 13:41:06 +0800 Subject: [PATCH 1/4] feat:remove old zookeeper (#13960) --- .artifacts | 2 - dubbo-compatible/pom.xml | 2 +- .../dubbo-dependencies-zookeeper/pom.xml | 212 ------- dubbo-dependencies/pom.xml | 1 - dubbo-distribution/dubbo-all-shaded/pom.xml | 3 +- dubbo-distribution/dubbo-all/pom.xml | 8 - dubbo-distribution/dubbo-bom/pom.xml | 5 - .../zookeeper/ZookeeperTransporter.java | 4 +- .../dubbo-remoting-zookeeper/pom.xml | 81 --- .../curator/CuratorZookeeperClient.java | 591 ------------------ .../curator/CuratorZookeeperTransporter.java | 28 - ...eeperReflectionTypeDescriberRegistrar.java | 52 -- ...o.aot.api.ReflectionTypeDescriberRegistrar | 1 - ...bo.remoting.zookeeper.ZookeeperTransporter | 1 - .../curator/CuratorZookeeperClientTest.java | 515 --------------- .../CuratorZookeeperTransporterTest.java | 55 -- .../AbstractZookeeperTransporterTest.java | 250 -------- .../src/test/resources/dubbo.properties | 2 - dubbo-remoting/pom.xml | 1 - dubbo-test/dubbo-dependencies-all/pom.xml | 5 - 20 files changed, 3 insertions(+), 1816 deletions(-) delete mode 100644 dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper/pom.xml delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperTransporter.java delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/aot/CuratorZookeeperReflectionTypeDescriberRegistrar.java delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClientTest.java delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperTransporterTest.java delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/curator/support/AbstractZookeeperTransporterTest.java delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper/src/test/resources/dubbo.properties diff --git a/.artifacts b/.artifacts index cd6334693d0..4b590ccb63b 100644 --- a/.artifacts +++ b/.artifacts @@ -38,7 +38,6 @@ dubbo-core-spi dubbo-dependencies dubbo-dependencies-all dubbo-dependencies-bom -dubbo-dependencies-zookeeper dubbo-dependencies-zookeeper-curator5 dubbo-distribution dubbo-filter-cache @@ -81,7 +80,6 @@ dubbo-remoting-http12 dubbo-remoting-netty dubbo-remoting-netty4 dubbo-remoting-zookeeper-api -dubbo-remoting-zookeeper dubbo-remoting-zookeeper-curator5 dubbo-rpc dubbo-rpc-api diff --git a/dubbo-compatible/pom.xml b/dubbo-compatible/pom.xml index 656bfed56f0..999941c6c69 100644 --- a/dubbo-compatible/pom.xml +++ b/dubbo-compatible/pom.xml @@ -45,7 +45,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper + dubbo-remoting-zookeeper-curator5 ${project.parent.version} diff --git a/dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml b/dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml deleted file mode 100644 index 0bab7fa215f..00000000000 --- a/dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml +++ /dev/null @@ -1,212 +0,0 @@ - - - - 4.0.0 - - - org.apache - apache - 31 - - - - org.apache.dubbo - dubbo-dependencies-zookeeper - ${revision} - pom - - - 3.3.0-beta.2-SNAPSHOT - 1.6.0 - 1.7.36 - 4.3.0 - 3.4.14 - 2.43.0 - check - 1.0.0 - 2.38.0 - - - - - org.apache.curator - curator-x-discovery - ${curator_version} - - - org.apache.zookeeper - zookeeper - - - org.slf4j - slf4j-api - - - com.google.guava - listenablefuture - - - - - org.apache.zookeeper - zookeeper - ${zookeeper_version} - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - com.github.spotbugs - spotbugs-annotations - - - org.apache.yetus - audience-annotations - - - jline - jline - - - io.netty - * - - - org.slf4j - slf4j-api - - - - - org.slf4j - slf4j-api - ${slf4j_version} - - - - - - - org.codehaus.mojo - flatten-maven-plugin - ${maven_flatten_version} - - true - oss - - - - flatten - - flatten - - process-resources - - - flatten.clean - - clean - - clean - - - - - - - - - release - - - - org.apache.maven.plugins - maven-gpg-plugin - - - - sign - - verify - - - - - - - - java11+ - - [11,) - - - - - - com.diffplug.spotless - spotless-maven-plugin - ${spotless-maven-plugin.version} - - - - ${palantirJavaFormat.version} - - - - dubbo-importorder.txt - - - checkstyle-header.txt - - - - - false - true - - - - true - - - - - com.alibaba - dubbo-shared-resources - ${dubbo-shared-resources.version} - - - - - - ${spotless.action} - - process-sources - - - - - - - - diff --git a/dubbo-dependencies/pom.xml b/dubbo-dependencies/pom.xml index 585c25fc95c..afc7ab7ab44 100644 --- a/dubbo-dependencies/pom.xml +++ b/dubbo-dependencies/pom.xml @@ -27,7 +27,6 @@ dubbo-dependencies pom - dubbo-dependencies-zookeeper dubbo-dependencies-zookeeper-curator5 diff --git a/dubbo-distribution/dubbo-all-shaded/pom.xml b/dubbo-distribution/dubbo-all-shaded/pom.xml index b0591156921..d6fb3e6e0e8 100644 --- a/dubbo-distribution/dubbo-all-shaded/pom.xml +++ b/dubbo-distribution/dubbo-all-shaded/pom.xml @@ -328,7 +328,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper + dubbo-remoting-zookeeper-curator5 ${project.version} compile true @@ -502,7 +502,6 @@ org.apache.dubbo:dubbo-remoting-http org.apache.dubbo:dubbo-remoting-netty4 org.apache.dubbo:dubbo-remoting-netty - org.apache.dubbo:dubbo-remoting-zookeeper org.apache.dubbo:dubbo-remoting-zookeeper-curator5 org.apache.dubbo:dubbo-rpc-api org.apache.dubbo:dubbo-rpc-dubbo diff --git a/dubbo-distribution/dubbo-all/pom.xml b/dubbo-distribution/dubbo-all/pom.xml index 19fd7dbbfc3..1f82941d24c 100644 --- a/dubbo-distribution/dubbo-all/pom.xml +++ b/dubbo-distribution/dubbo-all/pom.xml @@ -378,13 +378,6 @@ compile true - - org.apache.dubbo - dubbo-remoting-zookeeper - ${project.version} - compile - true - org.apache.dubbo dubbo-remoting-zookeeper-curator5 @@ -558,7 +551,6 @@ org.apache.dubbo:dubbo-remoting-netty4 org.apache.dubbo:dubbo-remoting-netty org.apache.dubbo:dubbo-remoting-zookeeper-api - org.apache.dubbo:dubbo-remoting-zookeeper org.apache.dubbo:dubbo-remoting-zookeeper-curator5 org.apache.dubbo:dubbo-rpc-api org.apache.dubbo:dubbo-rpc-dubbo diff --git a/dubbo-distribution/dubbo-bom/pom.xml b/dubbo-distribution/dubbo-bom/pom.xml index 7e535f3421d..0b7366af181 100644 --- a/dubbo-distribution/dubbo-bom/pom.xml +++ b/dubbo-distribution/dubbo-bom/pom.xml @@ -415,11 +415,6 @@ dubbo-remoting-zookeeper-api ${project.version} - - org.apache.dubbo - dubbo-remoting-zookeeper - ${project.version} - org.apache.dubbo dubbo-remoting-zookeeper-curator5 diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperTransporter.java index f73bc6b1a7e..89f3dbd4254 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperTransporter.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperTransporter.java @@ -27,8 +27,6 @@ public interface ZookeeperTransporter { String CURATOR_5 = "curator5"; - String CURATOR = "curator"; - ZookeeperClient connect(URL url); void destroy(); @@ -36,7 +34,7 @@ public interface ZookeeperTransporter { static ZookeeperTransporter getExtension(ApplicationModel applicationModel) { ExtensionLoader extensionLoader = applicationModel.getExtensionLoader(ZookeeperTransporter.class); - return isHighVersionCurator() ? extensionLoader.getExtension(CURATOR_5) : extensionLoader.getExtension(CURATOR); + return extensionLoader.getExtension(CURATOR_5); } static boolean isHighVersionCurator() { diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml b/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml deleted file mode 100644 index ef9990c0829..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - 4.0.0 - - org.apache.dubbo - dubbo-remoting - ${revision} - ../pom.xml - - dubbo-remoting-zookeeper - jar - ${project.artifactId} - The zookeeper remoting module of dubbo project - - false - 3.4.14 - 4.3.0 - - - - org.apache.dubbo - dubbo-remoting-zookeeper-api - ${project.parent.version} - - - org.apache.dubbo - dubbo-common - ${project.parent.version} - - - org.apache.curator - curator-recipes - ${curator_version} - - - org.apache.curator - curator-framework - ${curator_version} - - - org.apache.curator - curator-x-discovery - ${curator_version} - - - - org.apache.dubbo - dubbo-native - ${project.parent.version} - - - - org.apache.zookeeper - zookeeper - ${zookeeper_version} - - - - org.apache.dubbo - dubbo-test-common - ${project.parent.version} - test - - - diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java deleted file mode 100644 index e9a99f38b44..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java +++ /dev/null @@ -1,591 +0,0 @@ -/* - * 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.dubbo.remoting.zookeeper.curator; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.config.configcenter.ConfigItem; -import org.apache.dubbo.common.logger.ErrorTypeAwareLogger; -import org.apache.dubbo.common.logger.LoggerFactory; -import org.apache.dubbo.common.utils.NamedThreadFactory; -import org.apache.dubbo.common.utils.StringUtils; -import org.apache.dubbo.remoting.zookeeper.AbstractZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.ChildListener; -import org.apache.dubbo.remoting.zookeeper.DataListener; -import org.apache.dubbo.remoting.zookeeper.EventType; -import org.apache.dubbo.remoting.zookeeper.StateListener; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.CuratorFrameworkFactory; -import org.apache.curator.framework.api.ACLProvider; -import org.apache.curator.framework.api.CuratorWatcher; -import org.apache.curator.framework.recipes.cache.ChildData; -import org.apache.curator.framework.recipes.cache.NodeCache; -import org.apache.curator.framework.recipes.cache.NodeCacheListener; -import org.apache.curator.framework.state.ConnectionState; -import org.apache.curator.framework.state.ConnectionStateListener; -import org.apache.curator.retry.RetryNTimes; -import org.apache.zookeeper.CreateMode; -import org.apache.zookeeper.KeeperException.NoNodeException; -import org.apache.zookeeper.KeeperException.NodeExistsException; -import org.apache.zookeeper.WatchedEvent; -import org.apache.zookeeper.Watcher; -import org.apache.zookeeper.ZooDefs; -import org.apache.zookeeper.data.ACL; -import org.apache.zookeeper.data.Stat; - -import static org.apache.dubbo.common.constants.CommonConstants.SESSION_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY; -import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_CONNECT_REGISTRY; -import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION; - -public class CuratorZookeeperClient - extends AbstractZookeeperClient< - CuratorZookeeperClient.NodeCacheListenerImpl, CuratorZookeeperClient.CuratorWatcherImpl> { - - protected static final ErrorTypeAwareLogger logger = - LoggerFactory.getErrorTypeAwareLogger(CuratorZookeeperClient.class); - - private static final Charset CHARSET = StandardCharsets.UTF_8; - private final CuratorFramework client; - private static final Map nodeCacheMap = new ConcurrentHashMap<>(); - - public CuratorZookeeperClient(URL url) { - super(url); - try { - int timeout = url.getParameter(TIMEOUT_KEY, DEFAULT_CONNECTION_TIMEOUT_MS); - int sessionExpireMs = url.getParameter(SESSION_KEY, DEFAULT_SESSION_TIMEOUT_MS); - CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() - .connectString(url.getBackupAddress()) - .retryPolicy(new RetryNTimes(1, 1000)) - .connectionTimeoutMs(timeout) - .sessionTimeoutMs(sessionExpireMs); - String userInformation = url.getUserInformation(); - if (StringUtils.isNotEmpty(userInformation)) { - builder = builder.authorization("digest", userInformation.getBytes()); - builder.aclProvider(new ACLProvider() { - @Override - public List getDefaultAcl() { - return ZooDefs.Ids.CREATOR_ALL_ACL; - } - - @Override - public List getAclForPath(String path) { - return ZooDefs.Ids.CREATOR_ALL_ACL; - } - }); - } - client = builder.build(); - client.getConnectionStateListenable().addListener(new CuratorConnectionStateListener(url)); - client.start(); - - boolean connected = client.blockUntilConnected(timeout, TimeUnit.MILLISECONDS); - if (!connected) { - IllegalStateException illegalStateException = - new IllegalStateException("zookeeper not connected, the address is: " + url); - - // 5-1 Failed to connect to configuration center. - logger.error( - CONFIG_FAILED_CONNECT_REGISTRY, - "Zookeeper server offline", - "", - "Failed to connect with zookeeper", - illegalStateException); - - throw illegalStateException; - } - - CuratorWatcherImpl.closed = false; - } catch (Exception e) { - close(); - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - public void createPersistent(String path, boolean faultTolerant) { - try { - client.create().forPath(path); - } catch (NodeExistsException e) { - if (!faultTolerant) { - logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "ZNode " + path + " already exists.", e); - throw new IllegalStateException(e.getMessage(), e); - } - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - public void createEphemeral(String path, boolean faultTolerant) { - try { - client.create().withMode(CreateMode.EPHEMERAL).forPath(path); - } catch (NodeExistsException e) { - if (faultTolerant) { - logger.info("ZNode " + path - + " already exists, since we will only try to recreate a node on a session expiration" - + ", this duplication might be caused by a delete delay from the zk server, which means the old expired session" - + " may still holds this ZNode and the server just hasn't got time to do the deletion. In this case, " - + "we can just try to delete and create again."); - deletePath(path); - createEphemeral(path, true); - } else { - logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "ZNode " + path + " already exists.", e); - throw new IllegalStateException(e.getMessage(), e); - } - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - protected void createPersistent(String path, String data, boolean faultTolerant) { - byte[] dataBytes = data.getBytes(CHARSET); - try { - client.create().forPath(path, dataBytes); - } catch (NodeExistsException e) { - if (faultTolerant) { - logger.info("ZNode " + path + " already exists. Will be override with new data."); - try { - client.setData().forPath(path, dataBytes); - } catch (Exception e1) { - throw new IllegalStateException(e.getMessage(), e1); - } - } else { - logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "ZNode " + path + " already exists.", e); - throw new IllegalStateException(e.getMessage(), e); - } - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - protected void createEphemeral(String path, String data, boolean faultTolerant) { - byte[] dataBytes = data.getBytes(CHARSET); - try { - client.create().withMode(CreateMode.EPHEMERAL).forPath(path, dataBytes); - } catch (NodeExistsException e) { - if (faultTolerant) { - logger.info("ZNode " + path - + " already exists, since we will only try to recreate a node on a session expiration" - + ", this duplication might be caused by a delete delay from the zk server, which means the old expired session" - + " may still holds this ZNode and the server just hasn't got time to do the deletion. In this case, " - + "we can just try to delete and create again."); - deletePath(path); - createEphemeral(path, data, true); - } else { - logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "ZNode " + path + " already exists.", e); - throw new IllegalStateException(e.getMessage(), e); - } - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - protected void update(String path, String data, int version) { - byte[] dataBytes = data.getBytes(CHARSET); - try { - client.setData().withVersion(version).forPath(path, dataBytes); - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - protected void update(String path, String data) { - byte[] dataBytes = data.getBytes(CHARSET); - try { - client.setData().forPath(path, dataBytes); - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - protected void createOrUpdatePersistent(String path, String data) { - try { - if (checkExists(path)) { - update(path, data); - } else { - createPersistent(path, data, true); - } - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - protected void createOrUpdateEphemeral(String path, String data) { - try { - if (checkExists(path)) { - update(path, data); - } else { - createEphemeral(path, data, true); - } - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - protected void createOrUpdatePersistent(String path, String data, Integer version) { - try { - if (checkExists(path) && version != null) { - update(path, data, version); - } else { - createPersistent(path, data, false); - } - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - protected void createOrUpdateEphemeral(String path, String data, Integer version) { - try { - if (checkExists(path) && version != null) { - update(path, data, version); - } else { - createEphemeral(path, data, false); - } - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - protected void deletePath(String path) { - try { - client.delete().deletingChildrenIfNeeded().forPath(path); - } catch (NoNodeException ignored) { - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - public List getChildren(String path) { - try { - return client.getChildren().forPath(path); - } catch (NoNodeException e) { - return null; - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - public boolean checkExists(String path) { - try { - if (client.checkExists().forPath(path) != null) { - return true; - } - } catch (Exception ignored) { - } - return false; - } - - @Override - public boolean isConnected() { - return client.getZookeeperClient().isConnected(); - } - - @Override - public String doGetContent(String path) { - try { - byte[] dataBytes = client.getData().forPath(path); - return (dataBytes == null || dataBytes.length == 0) ? null : new String(dataBytes, CHARSET); - } catch (NoNodeException e) { - // ignore NoNode Exception. - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - return null; - } - - @Override - public ConfigItem doGetConfigItem(String path) { - String content; - Stat stat; - try { - stat = new Stat(); - byte[] dataBytes = client.getData().storingStatIn(stat).forPath(path); - content = (dataBytes == null || dataBytes.length == 0) ? null : new String(dataBytes, CHARSET); - } catch (NoNodeException e) { - return new ConfigItem(); - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - return new ConfigItem(content, stat); - } - - @Override - public void doClose() { - super.close(); - client.close(); - CuratorWatcherImpl.closed = true; - synchronized (CuratorWatcherImpl.class) { - if (CuratorWatcherImpl.CURATOR_WATCHER_EXECUTOR_SERVICE != null) { - CuratorWatcherImpl.CURATOR_WATCHER_EXECUTOR_SERVICE.shutdown(); - CuratorWatcherImpl.CURATOR_WATCHER_EXECUTOR_SERVICE = null; - } - } - } - - @Override - public CuratorZookeeperClient.CuratorWatcherImpl createTargetChildListener(String path, ChildListener listener) { - return new CuratorZookeeperClient.CuratorWatcherImpl(client, listener, path); - } - - @Override - public List addTargetChildListener(String path, CuratorWatcherImpl listener) { - try { - return client.getChildren().usingWatcher(listener).forPath(path); - } catch (NoNodeException e) { - return null; - } catch (Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - @Override - protected CuratorZookeeperClient.NodeCacheListenerImpl createTargetDataListener( - String path, DataListener listener) { - return new NodeCacheListenerImpl(listener, path); - } - - @Override - protected void addTargetDataListener(String path, CuratorZookeeperClient.NodeCacheListenerImpl nodeCacheListener) { - this.addTargetDataListener(path, nodeCacheListener, null); - } - - @Override - protected void addTargetDataListener( - String path, CuratorZookeeperClient.NodeCacheListenerImpl nodeCacheListener, Executor executor) { - try { - NodeCache nodeCache = new NodeCache(client, path); - if (nodeCacheMap.putIfAbsent(path, nodeCache) != null) { - return; - } - if (executor == null) { - nodeCache.getListenable().addListener(nodeCacheListener); - } else { - nodeCache.getListenable().addListener(nodeCacheListener, executor); - } - - nodeCache.start(); - } catch (Exception e) { - throw new IllegalStateException("Add nodeCache listener for path:" + path, e); - } - } - - @Override - protected void removeTargetDataListener( - String path, CuratorZookeeperClient.NodeCacheListenerImpl nodeCacheListener) { - NodeCache nodeCache = nodeCacheMap.get(path); - if (nodeCache != null) { - nodeCache.getListenable().removeListener(nodeCacheListener); - } - nodeCacheListener.dataListener = null; - } - - @Override - public void removeTargetChildListener(String path, CuratorWatcherImpl listener) { - listener.unwatch(); - } - - static class NodeCacheListenerImpl implements NodeCacheListener { - - private volatile DataListener dataListener; - - private String path; - - protected NodeCacheListenerImpl() {} - - public NodeCacheListenerImpl(DataListener dataListener, String path) { - this.dataListener = dataListener; - this.path = path; - } - - @Override - public void nodeChanged() throws Exception { - ChildData childData = nodeCacheMap.get(path).getCurrentData(); - String content = null; - EventType eventType; - if (childData == null) { - eventType = EventType.NodeDeleted; - } else if (childData.getStat().getVersion() == 0) { - content = new String(childData.getData(), CHARSET); - eventType = EventType.NodeCreated; - } else { - content = new String(childData.getData(), CHARSET); - eventType = EventType.NodeDataChanged; - } - dataListener.dataChanged(path, content, eventType); - } - } - - static class CuratorWatcherImpl implements CuratorWatcher { - - private static volatile ExecutorService CURATOR_WATCHER_EXECUTOR_SERVICE; - - private static volatile boolean closed = false; - - private CuratorFramework client; - private volatile ChildListener childListener; - private String path; - - private static void initExecutorIfNecessary() { - if (!closed && CURATOR_WATCHER_EXECUTOR_SERVICE == null) { - synchronized (CuratorWatcherImpl.class) { - if (!closed && CURATOR_WATCHER_EXECUTOR_SERVICE == null) { - CURATOR_WATCHER_EXECUTOR_SERVICE = - Executors.newSingleThreadExecutor(new NamedThreadFactory("Dubbo-CuratorWatcher")); - } - } - } - } - - public CuratorWatcherImpl(CuratorFramework client, ChildListener listener, String path) { - this.client = client; - this.childListener = listener; - this.path = path; - } - - protected CuratorWatcherImpl() {} - - public void unwatch() { - this.childListener = null; - } - - @Override - public void process(WatchedEvent event) throws Exception { - // if client connect or disconnect to server, zookeeper will queue - // watched event(Watcher.Event.EventType.None, .., path = null). - if (event.getType() == Watcher.Event.EventType.None) { - return; - } - - if (childListener != null) { - Runnable task = () -> Optional.ofNullable(childListener).ifPresent(c -> { - try { - c.childChanged( - path, - client.getChildren() - .usingWatcher(CuratorWatcherImpl.this) - .forPath(path)); - } catch (Exception e) { - logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "client get children error", e); - } - }); - initExecutorIfNecessary(); - if (!closed && CURATOR_WATCHER_EXECUTOR_SERVICE != null) { - CURATOR_WATCHER_EXECUTOR_SERVICE.execute(task); - } - } - } - } - - private class CuratorConnectionStateListener implements ConnectionStateListener { - private final long UNKNOWN_SESSION_ID = -1L; - private long lastSessionId; - private int timeout; - private int sessionExpireMs; - - public CuratorConnectionStateListener(URL url) { - this.timeout = url.getParameter(TIMEOUT_KEY, DEFAULT_CONNECTION_TIMEOUT_MS); - this.sessionExpireMs = url.getParameter(SESSION_KEY, DEFAULT_SESSION_TIMEOUT_MS); - } - - @Override - public void stateChanged(CuratorFramework client, ConnectionState state) { - long sessionId = UNKNOWN_SESSION_ID; - try { - sessionId = client.getZookeeperClient().getZooKeeper().getSessionId(); - } catch (Exception e) { - logger.warn( - REGISTRY_ZOOKEEPER_EXCEPTION, - "", - "", - "Curator client state changed, but failed to get the related zk session instance."); - } - - if (state == ConnectionState.LOST) { - logger.warn( - REGISTRY_ZOOKEEPER_EXCEPTION, - "", - "", - "Curator zookeeper session " + Long.toHexString(lastSessionId) + " expired."); - CuratorZookeeperClient.this.stateChanged(StateListener.SESSION_LOST); - } else if (state == ConnectionState.SUSPENDED) { - logger.warn( - REGISTRY_ZOOKEEPER_EXCEPTION, - "", - "", - "Curator zookeeper connection of session " + Long.toHexString(sessionId) + " timed out. " - + "connection timeout value is " + timeout + ", session expire timeout value is " - + sessionExpireMs); - CuratorZookeeperClient.this.stateChanged(StateListener.SUSPENDED); - } else if (state == ConnectionState.CONNECTED) { - lastSessionId = sessionId; - logger.info("Curator zookeeper client instance initiated successfully, session id is " - + Long.toHexString(sessionId)); - CuratorZookeeperClient.this.stateChanged(StateListener.CONNECTED); - } else if (state == ConnectionState.RECONNECTED) { - if (lastSessionId == sessionId && sessionId != UNKNOWN_SESSION_ID) { - logger.warn( - REGISTRY_ZOOKEEPER_EXCEPTION, - "", - "", - "Curator zookeeper connection recovered from connection lose, " + "reuse the old session " - + Long.toHexString(sessionId)); - CuratorZookeeperClient.this.stateChanged(StateListener.RECONNECTED); - } else { - logger.warn( - REGISTRY_ZOOKEEPER_EXCEPTION, - "", - "", - "New session created after old session lost, " + "old session " - + Long.toHexString(lastSessionId) + ", new session " + Long.toHexString(sessionId)); - lastSessionId = sessionId; - CuratorZookeeperClient.this.stateChanged(StateListener.NEW_SESSION_CREATED); - } - } - } - } - - /** - * just for unit test - * - * @return - */ - CuratorFramework getClient() { - return client; - } -} diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperTransporter.java deleted file mode 100644 index c69ab90368e..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperTransporter.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.dubbo.remoting.zookeeper.curator; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.remoting.zookeeper.AbstractZookeeperTransporter; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; - -public class CuratorZookeeperTransporter extends AbstractZookeeperTransporter { - @Override - public ZookeeperClient createZookeeperClient(URL url) { - return new CuratorZookeeperClient(url); - } -} diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/aot/CuratorZookeeperReflectionTypeDescriberRegistrar.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/aot/CuratorZookeeperReflectionTypeDescriberRegistrar.java deleted file mode 100644 index 7e37b47590c..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/aot/CuratorZookeeperReflectionTypeDescriberRegistrar.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.dubbo.remoting.zookeeper.curator.aot; - -import org.apache.dubbo.aot.api.MemberCategory; -import org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar; -import org.apache.dubbo.aot.api.TypeDescriber; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.zookeeper.ClientCnxnSocketNIO; - -public class CuratorZookeeperReflectionTypeDescriberRegistrar implements ReflectionTypeDescriberRegistrar { - - @Override - public List getTypeDescribers() { - List typeDescribers = new ArrayList<>(); - typeDescribers.add(buildTypeDescriberWithDeclaredConstructors(ClientCnxnSocketNIO.class)); - return typeDescribers; - } - - private TypeDescriber buildTypeDescriberWithDeclaredMethods(Class c) { - Set memberCategories = new HashSet<>(); - memberCategories.add(MemberCategory.INVOKE_DECLARED_METHODS); - return new TypeDescriber( - c.getName(), null, new HashSet<>(), new HashSet<>(), new HashSet<>(), memberCategories); - } - - private TypeDescriber buildTypeDescriberWithDeclaredConstructors(Class c) { - Set memberCategories = new HashSet<>(); - memberCategories.add(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); - return new TypeDescriber( - c.getName(), null, new HashSet<>(), new HashSet<>(), new HashSet<>(), memberCategories); - } -} diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar deleted file mode 100644 index 5312e63a093..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar +++ /dev/null @@ -1 +0,0 @@ -curatorZookeeper=org.apache.dubbo.remoting.zookeeper.curator.aot.CuratorZookeeperReflectionTypeDescriberRegistrar diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter deleted file mode 100644 index 44f9374cd15..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter +++ /dev/null @@ -1 +0,0 @@ -curator=org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperTransporter diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClientTest.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClientTest.java deleted file mode 100644 index 818b3f95550..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClientTest.java +++ /dev/null @@ -1,515 +0,0 @@ -/* - * 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.dubbo.remoting.zookeeper.curator; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.config.configcenter.ConfigItem; -import org.apache.dubbo.remoting.zookeeper.ChildListener; - -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; - -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.CuratorFrameworkFactory; -import org.apache.curator.retry.ExponentialBackoffRetry; -import org.apache.zookeeper.WatchedEvent; -import org.apache.zookeeper.data.Stat; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledForJreRange; -import org.junit.jupiter.api.condition.JRE; - -import static org.awaitility.Awaitility.await; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.mockito.Mockito.mock; - -@DisabledForJreRange(min = JRE.JAVA_16) -class CuratorZookeeperClientTest { - private CuratorZookeeperClient curatorClient; - CuratorFramework client = null; - - private static int zookeeperServerPort1; - private static String zookeeperConnectionAddress1; - - @BeforeAll - public static void beforeAll() { - zookeeperConnectionAddress1 = System.getProperty("zookeeper.connection.address.1"); - zookeeperServerPort1 = Integer.parseInt( - zookeeperConnectionAddress1.substring(zookeeperConnectionAddress1.lastIndexOf(":") + 1)); - } - - @BeforeEach - public void setUp() throws Exception { - curatorClient = new CuratorZookeeperClient( - URL.valueOf(zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService")); - client = CuratorFrameworkFactory.newClient( - "127.0.0.1:" + zookeeperServerPort1, new ExponentialBackoffRetry(1000, 3)); - client.start(); - } - - @Test - void testCheckExists() { - String path = "/dubbo/org.apache.dubbo.demo.DemoService/providers"; - curatorClient.create(path, false, true); - assertThat(curatorClient.checkExists(path), is(true)); - assertThat(curatorClient.checkExists(path + "/noneexits"), is(false)); - } - - @Test - void testChildrenPath() { - String path = "/dubbo/org.apache.dubbo.demo.DemoService/providers"; - curatorClient.create(path, false, true); - curatorClient.create(path + "/provider1", false, true); - curatorClient.create(path + "/provider2", false, true); - - List children = curatorClient.getChildren(path); - assertThat(children.size(), is(2)); - } - - @Test - @Disabled("Global registry center") - public void testChildrenListener() throws InterruptedException { - String path = "/dubbo/org.apache.dubbo.demo.DemoService/providers"; - curatorClient.create(path, false, true); - final CountDownLatch countDownLatch = new CountDownLatch(1); - curatorClient.addTargetChildListener(path, new CuratorZookeeperClient.CuratorWatcherImpl() { - - @Override - public void process(WatchedEvent watchedEvent) { - countDownLatch.countDown(); - } - }); - curatorClient.createPersistent(path + "/provider1", true); - countDownLatch.await(); - } - - @Test - void testWithInvalidServer() { - Assertions.assertThrows(IllegalStateException.class, () -> { - curatorClient = new CuratorZookeeperClient(URL.valueOf("zookeeper://127.0.0.1:1/service")); - curatorClient.create("/testPath", true, true); - }); - } - - @Test - @Disabled("Global registry center cannot stop") - public void testWithStoppedServer() { - Assertions.assertThrows(IllegalStateException.class, () -> { - curatorClient.create("/testPath", true, true); - curatorClient.delete("/testPath"); - }); - } - - @Test - void testRemoveChildrenListener() { - ChildListener childListener = mock(ChildListener.class); - curatorClient.addChildListener("/children", childListener); - curatorClient.removeChildListener("/children", childListener); - } - - @Test - void testCreateExistingPath() { - curatorClient.create("/pathOne", false, true); - curatorClient.create("/pathOne", false, true); - } - - @Test - void testConnectedStatus() { - curatorClient.createEphemeral("/testPath", true); - boolean connected = curatorClient.isConnected(); - assertThat(connected, is(true)); - } - - @Test - void testCreateContent4Persistent() { - String path = "/curatorTest4CrContent/content.data"; - String content = "createContentTest"; - curatorClient.delete(path); - assertThat(curatorClient.checkExists(path), is(false)); - assertNull(curatorClient.getContent(path)); - - curatorClient.createOrUpdate(path, content, false); - assertThat(curatorClient.checkExists(path), is(true)); - assertEquals(curatorClient.getContent(path), content); - } - - @Test - void testCreateContent4Temp() { - String path = "/curatorTest4CrContent/content.data"; - String content = "createContentTest"; - curatorClient.delete(path); - assertThat(curatorClient.checkExists(path), is(false)); - assertNull(curatorClient.getContent(path)); - - curatorClient.createOrUpdate(path, content, true); - assertThat(curatorClient.checkExists(path), is(true)); - assertEquals(curatorClient.getContent(path), content); - } - - @Test - void testCreatePersistentFailed() { - String path = "/dubbo/test/path"; - curatorClient.delete(path); - curatorClient.create(path, false, true); - Assertions.assertTrue(curatorClient.checkExists(path)); - - curatorClient.createPersistent(path, true); - Assertions.assertTrue(curatorClient.checkExists(path)); - - curatorClient.createPersistent(path, true); - Assertions.assertTrue(curatorClient.checkExists(path)); - - Assertions.assertThrows(IllegalStateException.class, () -> { - curatorClient.createPersistent(path, false); - }); - Assertions.assertTrue(curatorClient.checkExists(path)); - } - - @Test - void testCreateEphemeralFailed() { - String path = "/dubbo/test/path"; - curatorClient.delete(path); - curatorClient.create(path, true, true); - Assertions.assertTrue(curatorClient.checkExists(path)); - - curatorClient.createEphemeral(path, true); - Assertions.assertTrue(curatorClient.checkExists(path)); - - curatorClient.createEphemeral(path, true); - Assertions.assertTrue(curatorClient.checkExists(path)); - - Assertions.assertThrows(IllegalStateException.class, () -> { - curatorClient.createEphemeral(path, false); - }); - Assertions.assertTrue(curatorClient.checkExists(path)); - } - - @AfterEach - public void tearDown() throws Exception { - curatorClient.close(); - } - - @Test - void testAddTargetDataListener() throws Exception { - String listenerPath = "/dubbo/service.name/configuration"; - String path = listenerPath + "/dat/data"; - String value = "vav"; - - curatorClient.createOrUpdate(path + "/d.json", value, true); - String valueFromCache = curatorClient.getContent(path + "/d.json"); - Assertions.assertEquals(value, valueFromCache); - final AtomicInteger atomicInteger = new AtomicInteger(0); - curatorClient.addTargetDataListener(path + "/d.json", new CuratorZookeeperClient.NodeCacheListenerImpl() { - - @Override - public void nodeChanged() { - atomicInteger.incrementAndGet(); - } - }); - - valueFromCache = curatorClient.getContent(path + "/d.json"); - Assertions.assertNotNull(valueFromCache); - - int currentCount1 = atomicInteger.get(); - curatorClient.getClient().setData().forPath(path + "/d.json", "foo".getBytes()); - await().until(() -> atomicInteger.get() > currentCount1); - int currentCount2 = atomicInteger.get(); - curatorClient.getClient().setData().forPath(path + "/d.json", "bar".getBytes()); - await().until(() -> atomicInteger.get() > currentCount2); - int currentCount3 = atomicInteger.get(); - curatorClient.delete(path + "/d.json"); - valueFromCache = curatorClient.getContent(path + "/d.json"); - Assertions.assertNull(valueFromCache); - await().until(() -> atomicInteger.get() > currentCount3); - } - - @Test - void testPersistentCas1() throws Exception { - // test create failed when others create success - String path = "/dubbo/mapping/org.apache.dubbo.demo.DemoService"; - AtomicReference runnable = new AtomicReference<>(); - CuratorZookeeperClient curatorClient = - new CuratorZookeeperClient( - URL.valueOf(zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService")) { - @Override - protected void createPersistent(String path, String data, boolean faultTolerant) { - if (runnable.get() != null) { - runnable.get().run(); - } - super.createPersistent(path, data, faultTolerant); - } - - @Override - protected void update(String path, String data, int version) { - if (runnable.get() != null) { - runnable.get().run(); - } - super.update(path, data, version); - } - }; - curatorClient.delete(path); - - runnable.set(() -> { - try { - client.create().forPath(path, "version x".getBytes(StandardCharsets.UTF_8)); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - Assertions.assertThrows( - IllegalStateException.class, () -> curatorClient.createOrUpdate(path, "version 1", false, 0)); - Assertions.assertEquals("version x", curatorClient.getContent(path)); - - client.setData().forPath(path, "version 1".getBytes(StandardCharsets.UTF_8)); - - ConfigItem configItem = curatorClient.getConfigItem(path); - runnable.set(() -> { - try { - client.setData().forPath(path, "version x".getBytes(StandardCharsets.UTF_8)); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - int version1 = ((Stat) configItem.getTicket()).getVersion(); - Assertions.assertThrows( - IllegalStateException.class, () -> curatorClient.createOrUpdate(path, "version 2", false, version1)); - Assertions.assertEquals("version x", curatorClient.getContent(path)); - - runnable.set(null); - configItem = curatorClient.getConfigItem(path); - int version2 = ((Stat) configItem.getTicket()).getVersion(); - curatorClient.createOrUpdate(path, "version 2", false, version2); - Assertions.assertEquals("version 2", curatorClient.getContent(path)); - - curatorClient.close(); - } - - @Test - void testPersistentCas2() { - // test update failed when others create success - String path = "/dubbo/mapping/org.apache.dubbo.demo.DemoService"; - CuratorZookeeperClient curatorClient = new CuratorZookeeperClient( - URL.valueOf(zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService")); - curatorClient.delete(path); - - curatorClient.createOrUpdate(path, "version x", false); - Assertions.assertThrows( - IllegalStateException.class, () -> curatorClient.createOrUpdate(path, "version 1", false, null)); - Assertions.assertEquals("version x", curatorClient.getContent(path)); - - curatorClient.close(); - } - - @Test - void testPersistentNonVersion() { - String path = "/dubbo/metadata/org.apache.dubbo.demo.DemoService"; - AtomicReference runnable = new AtomicReference<>(); - CuratorZookeeperClient curatorClient = - new CuratorZookeeperClient( - URL.valueOf(zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService")) { - @Override - protected void createPersistent(String path, String data, boolean faultTolerant) { - if (runnable.get() != null) { - runnable.get().run(); - } - super.createPersistent(path, data, faultTolerant); - } - - @Override - protected void update(String path, String data, int version) { - if (runnable.get() != null) { - runnable.get().run(); - } - super.update(path, data, version); - } - }; - curatorClient.delete(path); - - curatorClient.createOrUpdate(path, "version 0", false); - Assertions.assertEquals("version 0", curatorClient.getContent(path)); - curatorClient.delete(path); - - runnable.set(() -> { - try { - client.create().forPath(path, "version x".getBytes(StandardCharsets.UTF_8)); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - curatorClient.createOrUpdate(path, "version 1", false); - Assertions.assertEquals("version 1", curatorClient.getContent(path)); - - runnable.set(() -> { - try { - client.setData().forPath(path, "version x".getBytes(StandardCharsets.UTF_8)); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - curatorClient.createOrUpdate(path, "version 2", false); - Assertions.assertEquals("version 2", curatorClient.getContent(path)); - - runnable.set(null); - curatorClient.createOrUpdate(path, "version 3", false); - Assertions.assertEquals("version 3", curatorClient.getContent(path)); - - curatorClient.close(); - } - - @Test - void testEphemeralCas1() throws Exception { - // test create failed when others create success - String path = "/dubbo/mapping/org.apache.dubbo.demo.DemoService"; - AtomicReference runnable = new AtomicReference<>(); - CuratorZookeeperClient curatorClient = - new CuratorZookeeperClient( - URL.valueOf(zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService")) { - @Override - protected void createEphemeral(String path, String data, boolean faultTolerant) { - if (runnable.get() != null) { - runnable.get().run(); - } - super.createPersistent(path, data, faultTolerant); - } - - @Override - protected void update(String path, String data, int version) { - if (runnable.get() != null) { - runnable.get().run(); - } - super.update(path, data, version); - } - }; - curatorClient.delete(path); - - runnable.set(() -> { - try { - client.create().forPath(path, "version x".getBytes(StandardCharsets.UTF_8)); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - Assertions.assertThrows( - IllegalStateException.class, () -> curatorClient.createOrUpdate(path, "version 1", true, 0)); - Assertions.assertEquals("version x", curatorClient.getContent(path)); - - client.setData().forPath(path, "version 1".getBytes(StandardCharsets.UTF_8)); - - ConfigItem configItem = curatorClient.getConfigItem(path); - runnable.set(() -> { - try { - client.setData().forPath(path, "version x".getBytes(StandardCharsets.UTF_8)); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - int version1 = ((Stat) configItem.getTicket()).getVersion(); - Assertions.assertThrows( - IllegalStateException.class, () -> curatorClient.createOrUpdate(path, "version 2", true, version1)); - Assertions.assertEquals("version x", curatorClient.getContent(path)); - - runnable.set(null); - configItem = curatorClient.getConfigItem(path); - int version2 = ((Stat) configItem.getTicket()).getVersion(); - curatorClient.createOrUpdate(path, "version 2", true, version2); - Assertions.assertEquals("version 2", curatorClient.getContent(path)); - - curatorClient.close(); - } - - @Test - void testEphemeralCas2() { - // test update failed when others create success - String path = "/dubbo/mapping/org.apache.dubbo.demo.DemoService"; - CuratorZookeeperClient curatorClient = new CuratorZookeeperClient( - URL.valueOf(zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService")); - curatorClient.delete(path); - - curatorClient.createOrUpdate(path, "version x", true); - Assertions.assertThrows( - IllegalStateException.class, () -> curatorClient.createOrUpdate(path, "version 1", true, null)); - Assertions.assertEquals("version x", curatorClient.getContent(path)); - - curatorClient.close(); - } - - @Test - void testEphemeralNonVersion() { - String path = "/dubbo/metadata/org.apache.dubbo.demo.DemoService"; - AtomicReference runnable = new AtomicReference<>(); - CuratorZookeeperClient curatorClient = - new CuratorZookeeperClient( - URL.valueOf(zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService")) { - @Override - protected void createPersistent(String path, String data, boolean faultTolerant) { - if (runnable.get() != null) { - runnable.get().run(); - } - super.createPersistent(path, data, faultTolerant); - } - - @Override - protected void update(String path, String data, int version) { - if (runnable.get() != null) { - runnable.get().run(); - } - super.update(path, data, version); - } - }; - curatorClient.delete(path); - - curatorClient.createOrUpdate(path, "version 0", true); - Assertions.assertEquals("version 0", curatorClient.getContent(path)); - curatorClient.delete(path); - - runnable.set(() -> { - try { - client.create().forPath(path, "version x".getBytes(StandardCharsets.UTF_8)); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - curatorClient.createOrUpdate(path, "version 1", true); - Assertions.assertEquals("version 1", curatorClient.getContent(path)); - - runnable.set(() -> { - try { - client.setData().forPath(path, "version x".getBytes(StandardCharsets.UTF_8)); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - curatorClient.createOrUpdate(path, "version 2", true); - Assertions.assertEquals("version 2", curatorClient.getContent(path)); - - runnable.set(null); - curatorClient.createOrUpdate(path, "version 3", true); - Assertions.assertEquals("version 3", curatorClient.getContent(path)); - - curatorClient.close(); - } -} diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperTransporterTest.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperTransporterTest.java deleted file mode 100644 index 328107ae13a..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperTransporterTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.dubbo.remoting.zookeeper.curator; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledForJreRange; -import org.junit.jupiter.api.condition.JRE; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsNot.not; -import static org.hamcrest.core.IsNull.nullValue; - -@DisabledForJreRange(min = JRE.JAVA_16) -class CuratorZookeeperTransporterTest { - private ZookeeperClient zookeeperClient; - private CuratorZookeeperTransporter curatorZookeeperTransporter; - private static String zookeeperConnectionAddress1; - - @BeforeAll - public static void beforeAll() { - zookeeperConnectionAddress1 = System.getProperty("zookeeper.connection.address.1"); - } - - @BeforeEach - public void setUp() throws Exception { - zookeeperClient = - new CuratorZookeeperTransporter().connect(URL.valueOf(zookeeperConnectionAddress1 + "/service")); - curatorZookeeperTransporter = new CuratorZookeeperTransporter(); - } - - @Test - void testZookeeperClient() { - assertThat(zookeeperClient, not(nullValue())); - zookeeperClient.close(); - } -} diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/curator/support/AbstractZookeeperTransporterTest.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/curator/support/AbstractZookeeperTransporterTest.java deleted file mode 100644 index 37cc93c0f28..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/test/java/org/apache/dubbo/remoting/zookeeper/curator/support/AbstractZookeeperTransporterTest.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * 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.dubbo.remoting.zookeeper.curator.support; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.remoting.zookeeper.AbstractZookeeperTransporter; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperTransporter; - -import java.util.List; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledForJreRange; -import org.junit.jupiter.api.condition.JRE; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsNot.not; -import static org.hamcrest.core.IsNull.nullValue; - -/** - * AbstractZookeeperTransporterTest - */ -@DisabledForJreRange(min = JRE.JAVA_16) -class AbstractZookeeperTransporterTest { - private ZookeeperClient zookeeperClient; - private AbstractZookeeperTransporter abstractZookeeperTransporter; - - private static int zookeeperServerPort1, zookeeperServerPort2; - private static String zookeeperConnectionAddress1, zookeeperConnectionAddress2; - - @BeforeAll - public static void beforeAll() { - zookeeperConnectionAddress1 = System.getProperty("zookeeper.connection.address.1"); - zookeeperConnectionAddress2 = System.getProperty("zookeeper.connection.address.2"); - zookeeperServerPort1 = Integer.parseInt( - zookeeperConnectionAddress1.substring(zookeeperConnectionAddress1.lastIndexOf(":") + 1)); - zookeeperServerPort2 = Integer.parseInt( - zookeeperConnectionAddress2.substring(zookeeperConnectionAddress2.lastIndexOf(":") + 1)); - } - - @BeforeEach - public void setUp() throws Exception { - zookeeperClient = new CuratorZookeeperTransporter() - .connect(URL.valueOf("zookeeper://127.0.0.1:" + zookeeperServerPort1 + "/service")); - abstractZookeeperTransporter = new CuratorZookeeperTransporter(); - } - - @Test - void testZookeeperClient() { - assertThat(zookeeperClient, not(nullValue())); - zookeeperClient.close(); - } - - @Test - void testGetURLBackupAddress() { - URL url = URL.valueOf( - zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService?backup=127.0.0.1:" + 9099 - + "&application=metadatareport-local-xml-provider2&dubbo=2.0.2&interface=org.apache.dubbo.registry.RegistryService&pid=47418&specVersion=2.7.0-SNAPSHOT×tamp=1547102428828"); - List stringList = abstractZookeeperTransporter.getURLBackupAddress(url); - Assertions.assertEquals(stringList.size(), 2); - Assertions.assertEquals(stringList.get(0), "127.0.0.1:" + zookeeperServerPort1); - Assertions.assertEquals(stringList.get(1), "127.0.0.1:9099"); - } - - @Test - void testGetURLBackupAddressNoBack() { - URL url = URL.valueOf( - zookeeperConnectionAddress1 - + "/org.apache.dubbo.registry.RegistryService?application=metadatareport-local-xml-provider2&dubbo=2.0.2&interface=org.apache.dubbo.registry.RegistryService&pid=47418&specVersion=2.7.0-SNAPSHOT×tamp=1547102428828"); - List stringList = abstractZookeeperTransporter.getURLBackupAddress(url); - Assertions.assertEquals(stringList.size(), 1); - Assertions.assertEquals(stringList.get(0), "127.0.0.1:" + zookeeperServerPort1); - } - - @Test - void testFetchAndUpdateZookeeperClientCache() { - URL url = URL.valueOf( - zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService?backup=127.0.0.1:" - + zookeeperServerPort1 + ",127.0.0.1:" + zookeeperServerPort2 - + "&application=metadatareport-local-xml-provider2&dubbo=2.0.2&interface=org.apache.dubbo.registry.RegistryService&pid=47418&specVersion=2.7.0-SNAPSHOT×tamp=1547102428828"); - ZookeeperClient newZookeeperClient = abstractZookeeperTransporter.connect(url); - // just for connected - newZookeeperClient.getContent("/dubbo/test"); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 2); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), - newZookeeperClient); - - URL url2 = URL.valueOf( - "zookeeper://127.0.0.1:" + zookeeperServerPort1 - + "/org.apache.dubbo.metadata.store.MetadataReport?address=zookeeper://127.0.0.1:2181&application=metadatareport-local-xml-provider2&cycle-report=false&interface=org.apache.dubbo.metadata.store.MetadataReport&retry-period=4590&retry-times=23&sync-report=true"); - checkFetchAndUpdateCacheNotNull(url2); - URL url3 = URL.valueOf( - "zookeeper://127.0.0.1:8778/org.apache.dubbo.metadata.store.MetadataReport?backup=127.0.0.1:" - + zookeeperServerPort2 - + "&address=zookeeper://127.0.0.1:2181&application=metadatareport-local-xml-provider2&cycle-report=false&interface=org.apache.dubbo.metadata.store.MetadataReport&retry-period=4590&retry-times=23&sync-report=true"); - checkFetchAndUpdateCacheNotNull(url3); - } - - private void checkFetchAndUpdateCacheNotNull(URL url) { - List addressList = abstractZookeeperTransporter.getURLBackupAddress(url); - ZookeeperClient zookeeperClient = abstractZookeeperTransporter.fetchAndUpdateZookeeperClientCache(addressList); - Assertions.assertNotNull(zookeeperClient); - } - - @Test - void testRepeatConnect() { - URL url = URL.valueOf( - zookeeperConnectionAddress1 - + "/org.apache.dubbo.registry.RegistryService?application=metadatareport-local-xml-provider2&dubbo=2.0.2&interface=org.apache.dubbo.registry.RegistryService&pid=47418&specVersion=2.7.0-SNAPSHOT×tamp=1547102428828"); - URL url2 = URL.valueOf( - zookeeperConnectionAddress1 - + "/org.apache.dubbo.metadata.store.MetadataReport?address=zookeeper://127.0.0.1:2181&application=metadatareport-local-xml-provider2&cycle-report=false&interface=org.apache.dubbo.metadata.store.MetadataReport&retry-period=4590&retry-times=23&sync-report=true"); - ZookeeperClient newZookeeperClient = abstractZookeeperTransporter.connect(url); - // just for connected - newZookeeperClient.getContent("/dubbo/test"); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 1); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), - newZookeeperClient); - Assertions.assertTrue(newZookeeperClient.isConnected()); - - ZookeeperClient newZookeeperClient2 = abstractZookeeperTransporter.connect(url2); - // just for connected - newZookeeperClient2.getContent("/dubbo/test"); - Assertions.assertEquals(newZookeeperClient, newZookeeperClient2); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 1); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), - newZookeeperClient); - } - - @Test - void testNotRepeatConnect() { - URL url = URL.valueOf( - zookeeperConnectionAddress1 - + "/org.apache.dubbo.registry.RegistryService?application=metadatareport-local-xml-provider2&dubbo=2.0.2&interface=org.apache.dubbo.registry.RegistryService&pid=47418&specVersion=2.7.0-SNAPSHOT×tamp=1547102428828"); - URL url2 = URL.valueOf( - zookeeperConnectionAddress2 - + "/org.apache.dubbo.metadata.store.MetadataReport?address=zookeeper://127.0.0.1:2181&application=metadatareport-local-xml-provider2&cycle-report=false&interface=org.apache.dubbo.metadata.store.MetadataReport&retry-period=4590&retry-times=23&sync-report=true"); - ZookeeperClient newZookeeperClient = abstractZookeeperTransporter.connect(url); - // just for connected - newZookeeperClient.getContent("/dubbo/test"); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 1); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), - newZookeeperClient); - - ZookeeperClient newZookeeperClient2 = abstractZookeeperTransporter.connect(url2); - // just for connected - newZookeeperClient2.getContent("/dubbo/test"); - Assertions.assertNotEquals(newZookeeperClient, newZookeeperClient2); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 2); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort2), - newZookeeperClient2); - } - - @Test - void testRepeatConnectForBackUpAdd() { - - URL url = URL.valueOf( - zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService?backup=127.0.0.1:" - + zookeeperServerPort1 - + "&application=metadatareport-local-xml-provider2&dubbo=2.0.2&interface=org.apache.dubbo.registry.RegistryService&pid=47418&specVersion=2.7.0-SNAPSHOT×tamp=1547102428828"); - URL url2 = URL.valueOf( - zookeeperConnectionAddress1 + "/org.apache.dubbo.metadata.store.MetadataReport?backup=127.0.0.1:" - + zookeeperServerPort2 - + "&address=zookeeper://127.0.0.1:2181&application=metadatareport-local-xml-provider2&cycle-report=false&interface=org.apache.dubbo.metadata.store.MetadataReport&retry-period=4590&retry-times=23&sync-report=true"); - ZookeeperClient newZookeeperClient = abstractZookeeperTransporter.connect(url); - // just for connected - newZookeeperClient.getContent("/dubbo/test"); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 1); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), - newZookeeperClient); - - ZookeeperClient newZookeeperClient2 = abstractZookeeperTransporter.connect(url2); - // just for connected - newZookeeperClient2.getContent("/dubbo/test"); - Assertions.assertEquals(newZookeeperClient, newZookeeperClient2); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 2); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort2), - newZookeeperClient2); - } - - @Test - void testRepeatConnectForNoMatchBackUpAdd() { - - URL url = URL.valueOf( - zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService?backup=127.0.0.1:" - + zookeeperServerPort1 - + "&application=metadatareport-local-xml-provider2&dubbo=2.0.2&interface=org.apache.dubbo.registry.RegistryService&pid=47418&specVersion=2.7.0-SNAPSHOT×tamp=1547102428828"); - URL url2 = URL.valueOf( - zookeeperConnectionAddress2 - + "/org.apache.dubbo.metadata.store.MetadataReport?address=zookeeper://127.0.0.1:2181&application=metadatareport-local-xml-provider2&cycle-report=false&interface=org.apache.dubbo.metadata.store.MetadataReport&retry-period=4590&retry-times=23&sync-report=true"); - ZookeeperClient newZookeeperClient = abstractZookeeperTransporter.connect(url); - // just for connected - newZookeeperClient.getContent("/dubbo/test"); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 1); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), - newZookeeperClient); - - ZookeeperClient newZookeeperClient2 = abstractZookeeperTransporter.connect(url2); - // just for connected - newZookeeperClient2.getContent("/dubbo/test"); - Assertions.assertNotEquals(newZookeeperClient, newZookeeperClient2); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 2); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort2), - newZookeeperClient2); - } - - @Test - void testSameHostWithDifferentUser() { - URL url1 = URL.valueOf("zookeeper://us1:pw1@127.0.0.1:" + zookeeperServerPort1 + "/path1"); - URL url2 = URL.valueOf("zookeeper://us2:pw2@127.0.0.1:" + zookeeperServerPort1 + "/path2"); - ZookeeperClient client1 = abstractZookeeperTransporter.connect(url1); - ZookeeperClient client2 = abstractZookeeperTransporter.connect(url2); - assertThat(client1, not(client2)); - } -} diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/test/resources/dubbo.properties b/dubbo-remoting/dubbo-remoting-zookeeper/src/test/resources/dubbo.properties deleted file mode 100644 index 1aade88a561..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/test/resources/dubbo.properties +++ /dev/null @@ -1,2 +0,0 @@ -dubbo.application.enable-file-cache=false -dubbo.service.shutdown.wait=200 diff --git a/dubbo-remoting/pom.xml b/dubbo-remoting/pom.xml index 1a1d0cd0c40..9128721309b 100644 --- a/dubbo-remoting/pom.xml +++ b/dubbo-remoting/pom.xml @@ -32,7 +32,6 @@ dubbo-remoting-http dubbo-remoting-netty dubbo-remoting-zookeeper-api - dubbo-remoting-zookeeper dubbo-remoting-zookeeper-curator5 dubbo-remoting-netty4 dubbo-remoting-http12 diff --git a/dubbo-test/dubbo-dependencies-all/pom.xml b/dubbo-test/dubbo-dependencies-all/pom.xml index 8bfc74434b3..eb1195d5a1f 100644 --- a/dubbo-test/dubbo-dependencies-all/pom.xml +++ b/dubbo-test/dubbo-dependencies-all/pom.xml @@ -325,11 +325,6 @@ dubbo-remoting-zookeeper-api ${project.version} - - org.apache.dubbo - dubbo-remoting-zookeeper - ${project.version} - org.apache.dubbo dubbo-remoting-zookeeper-curator5 From 2d2ad8553e3ab80ace30f23b22aa00644b1a2afc Mon Sep 17 00:00:00 2001 From: stellar Date: Mon, 8 Apr 2024 10:39:31 +0800 Subject: [PATCH 2/4] feat:remove ZookeeperTransporter SPI (#13960) --- CHANGES.md | 2 +- .../zookeeper/ZookeeperTransporter.java | 2 +- .../ZookeeperDynamicConfiguration.java | 4 +- .../ZookeeperDynamicConfigurationFactory.java | 4 +- dubbo-distribution/dubbo-all-shaded/pom.xml | 3 - dubbo-distribution/dubbo-all/pom.xml | 3 - dubbo-distribution/dubbo-core-spi/pom.xml | 3 - .../zookeeper/ZookeeperMetadataReport.java | 2 +- .../ZookeeperMetadataReportFactory.java | 7 +- .../registry/zookeeper/ZookeeperRegistry.java | 4 +- .../zookeeper/ZookeeperRegistryFactory.java | 4 +- .../dubbo-remoting-zookeeper-api/pom.xml | 1 + .../RemotingScopeModelInitializer.java | 66 ------------------- .../zookeeper/ZookeeperTransporter.java | 48 -------------- ...ache.dubbo.rpc.model.ScopeModelInitializer | 1 - .../AbstractZookeeperTransporter.java | 5 +- .../Curator5ZookeeperTransporter.java | 1 - .../curator5/ZookeeperTransporter.java | 60 +++++++++++++++++ ...bo.remoting.zookeeper.ZookeeperTransporter | 1 - .../AbstractZookeeperTransporterTest.java | 2 +- 20 files changed, 78 insertions(+), 145 deletions(-) delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/RemotingScopeModelInitializer.java delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperTransporter.java delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.model.ScopeModelInitializer rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5}/AbstractZookeeperTransporter.java (97%) create mode 100644 dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperTransporter.java delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter diff --git a/CHANGES.md b/CHANGES.md index 2983d19539d..bf3021fc627 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -252,7 +252,7 @@ check 2.7.5 milestone for details. ### Notice -'zkclient' extension for 'org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter' is removed from Dubbo 2.7.1, and 'curator' extension becomes the default extension. If you happen to config your application to use 'zkclient' explicitly, pls. switch to use 'curator' instead. +'zkclient' extension for 'org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter' is removed from Dubbo 2.7.1, and 'curator' extension becomes the default extension. If you happen to config your application to use 'zkclient' explicitly, pls. switch to use 'curator' instead. ### New Features diff --git a/dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/zookeeper/ZookeeperTransporter.java b/dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/zookeeper/ZookeeperTransporter.java index 25cabd64ce1..c3cd045def3 100644 --- a/dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/zookeeper/ZookeeperTransporter.java +++ b/dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/zookeeper/ZookeeperTransporter.java @@ -17,4 +17,4 @@ package com.alibaba.dubbo.remoting.zookeeper; @Deprecated -public interface ZookeeperTransporter extends org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter {} +public interface ZookeeperTransporter extends org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter {} diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java index f29671f0c64..65b92064caa 100644 --- a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java +++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java @@ -24,7 +24,7 @@ import org.apache.dubbo.common.utils.CollectionUtils; import org.apache.dubbo.common.utils.NamedThreadFactory; import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter; import org.apache.dubbo.rpc.model.ApplicationModel; import java.util.Collection; @@ -107,7 +107,7 @@ protected void doClose() throws Exception { // zkClient is shared in framework, should not close it here // zkClient.close(); - // See: org.apache.dubbo.remoting.zookeeper.AbstractZookeeperTransporter#destroy() + // See: org.apache.dubbo.remoting.zookeeper.curator5.AbstractZookeeperTransporter#destroy() // All zk clients is created and destroyed in ZookeeperTransporter. zkClient = null; } diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationFactory.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationFactory.java index 1ab74973799..8e893c16c0b 100644 --- a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationFactory.java +++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationFactory.java @@ -19,7 +19,7 @@ import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.configcenter.AbstractDynamicConfigurationFactory; import org.apache.dubbo.common.config.configcenter.DynamicConfiguration; -import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter; import org.apache.dubbo.rpc.model.ApplicationModel; public class ZookeeperDynamicConfigurationFactory extends AbstractDynamicConfigurationFactory { @@ -30,7 +30,7 @@ public class ZookeeperDynamicConfigurationFactory extends AbstractDynamicConfigu public ZookeeperDynamicConfigurationFactory(ApplicationModel applicationModel) { this.applicationModel = applicationModel; - this.zookeeperTransporter = ZookeeperTransporter.getExtension(applicationModel); + this.zookeeperTransporter = ZookeeperTransporter.getInstance(applicationModel); } @Override diff --git a/dubbo-distribution/dubbo-all-shaded/pom.xml b/dubbo-distribution/dubbo-all-shaded/pom.xml index d6fb3e6e0e8..15915c4ac1c 100644 --- a/dubbo-distribution/dubbo-all-shaded/pom.xml +++ b/dubbo-distribution/dubbo-all-shaded/pom.xml @@ -779,9 +779,6 @@ META-INF/dubbo/internal/org.apache.dubbo.remoting.telnet.TelnetHandler - - META-INF/dubbo/internal/org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter - META-INF/dubbo/internal/org.apache.dubbo.rpc.ExporterListener diff --git a/dubbo-distribution/dubbo-all/pom.xml b/dubbo-distribution/dubbo-all/pom.xml index 1f82941d24c..2c76ab79805 100644 --- a/dubbo-distribution/dubbo-all/pom.xml +++ b/dubbo-distribution/dubbo-all/pom.xml @@ -827,9 +827,6 @@ META-INF/dubbo/internal/org.apache.dubbo.remoting.telnet.TelnetHandler - - META-INF/dubbo/internal/org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter - META-INF/dubbo/internal/org.apache.dubbo.rpc.ExporterListener diff --git a/dubbo-distribution/dubbo-core-spi/pom.xml b/dubbo-distribution/dubbo-core-spi/pom.xml index 6ef9c5d928e..d659f120623 100644 --- a/dubbo-distribution/dubbo-core-spi/pom.xml +++ b/dubbo-distribution/dubbo-core-spi/pom.xml @@ -396,9 +396,6 @@ META-INF/dubbo/internal/org.apache.dubbo.remoting.telnet.TelnetHandler - - META-INF/dubbo/internal/org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter - META-INF/dubbo/internal/org.apache.dubbo.rpc.ExporterListener diff --git a/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReport.java b/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReport.java index ce01bf0d7c8..711119e74dc 100644 --- a/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReport.java +++ b/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReport.java @@ -35,7 +35,7 @@ import org.apache.dubbo.remoting.zookeeper.DataListener; import org.apache.dubbo.remoting.zookeeper.EventType; import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter; import java.util.ArrayList; import java.util.Collections; diff --git a/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportFactory.java b/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportFactory.java index 42270d863e3..b589949769d 100644 --- a/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportFactory.java +++ b/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportFactory.java @@ -20,7 +20,7 @@ import org.apache.dubbo.common.extension.DisableInject; import org.apache.dubbo.metadata.report.MetadataReport; import org.apache.dubbo.metadata.report.support.AbstractMetadataReportFactory; -import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter; import org.apache.dubbo.rpc.model.ApplicationModel; /** @@ -30,11 +30,8 @@ public class ZookeeperMetadataReportFactory extends AbstractMetadataReportFactor private ZookeeperTransporter zookeeperTransporter; - private ApplicationModel applicationModel; - public ZookeeperMetadataReportFactory(ApplicationModel applicationModel) { - this.applicationModel = applicationModel; - this.zookeeperTransporter = ZookeeperTransporter.getExtension(applicationModel); + this.zookeeperTransporter = ZookeeperTransporter.getInstance(applicationModel); } @DisableInject diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java index 4052df8d262..1c00abb26e1 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java +++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java @@ -29,7 +29,7 @@ import org.apache.dubbo.remoting.zookeeper.ChildListener; import org.apache.dubbo.remoting.zookeeper.StateListener; import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter; import org.apache.dubbo.rpc.RpcException; import java.util.ArrayList; @@ -156,7 +156,7 @@ public void destroy() { zkListeners.clear(); // Just release zkClient reference, but can not close zk client here for zk client is shared somewhere else. - // See org.apache.dubbo.remoting.zookeeper.AbstractZookeeperTransporter#destroy() + // See org.apache.dubbo.remoting.zookeeper.curator5.AbstractZookeeperTransporter#destroy() zkClient = null; } diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java index ec4ce4ac342..8f3278e1ed9 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java @@ -20,7 +20,7 @@ import org.apache.dubbo.common.extension.DisableInject; import org.apache.dubbo.registry.Registry; import org.apache.dubbo.registry.support.AbstractRegistryFactory; -import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter; import org.apache.dubbo.rpc.model.ApplicationModel; /** @@ -37,7 +37,7 @@ public ZookeeperRegistryFactory() { public ZookeeperRegistryFactory(ApplicationModel applicationModel) { this.applicationModel = applicationModel; - this.zookeeperTransporter = ZookeeperTransporter.getExtension(applicationModel); + this.zookeeperTransporter = ZookeeperTransporter.getInstance(applicationModel); } @DisableInject diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/pom.xml b/dubbo-remoting/dubbo-remoting-zookeeper-api/pom.xml index 4f140f5f49e..1ea102a6bbb 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/pom.xml +++ b/dubbo-remoting/dubbo-remoting-zookeeper-api/pom.xml @@ -45,5 +45,6 @@ ${project.parent.version} test + diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/RemotingScopeModelInitializer.java b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/RemotingScopeModelInitializer.java deleted file mode 100644 index 820f45e2b85..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/RemotingScopeModelInitializer.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.dubbo.remoting; - -import org.apache.dubbo.common.logger.ErrorTypeAwareLogger; -import org.apache.dubbo.common.logger.LoggerFactory; -import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter; -import org.apache.dubbo.rpc.model.ApplicationModel; -import org.apache.dubbo.rpc.model.FrameworkModel; -import org.apache.dubbo.rpc.model.ModuleModel; -import org.apache.dubbo.rpc.model.ScopeModelInitializer; - -import java.util.List; - -import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_DESTROY_ZOOKEEPER; - -/** - * Scope model initializer for remoting-api - */ -public class RemotingScopeModelInitializer implements ScopeModelInitializer { - - private static final ErrorTypeAwareLogger logger = - LoggerFactory.getErrorTypeAwareLogger(RemotingScopeModelInitializer.class); - - @Override - public void initializeFrameworkModel(FrameworkModel frameworkModel) {} - - @Override - public void initializeApplicationModel(ApplicationModel applicationModel) { - applicationModel.addDestroyListener(m -> { - // destroy zookeeper clients if any - try { - List transporters = applicationModel - .getExtensionLoader(ZookeeperTransporter.class) - .getLoadedExtensionInstances(); - for (ZookeeperTransporter zkTransporter : transporters) { - zkTransporter.destroy(); - } - } catch (Exception e) { - logger.error( - TRANSPORT_FAILED_DESTROY_ZOOKEEPER, - "", - "", - "Error encountered while destroying ZookeeperTransporter: " + e.getMessage(), - e); - } - }); - } - - @Override - public void initializeModuleModel(ModuleModel moduleModel) {} -} diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperTransporter.java deleted file mode 100644 index 89f3dbd4254..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperTransporter.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.dubbo.remoting.zookeeper; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.extension.ExtensionLoader; -import org.apache.dubbo.common.extension.ExtensionScope; -import org.apache.dubbo.common.extension.SPI; -import org.apache.dubbo.rpc.model.ApplicationModel; - -@SPI(scope = ExtensionScope.APPLICATION) -public interface ZookeeperTransporter { - - String CURATOR_5 = "curator5"; - - ZookeeperClient connect(URL url); - - void destroy(); - - static ZookeeperTransporter getExtension(ApplicationModel applicationModel) { - ExtensionLoader extensionLoader = - applicationModel.getExtensionLoader(ZookeeperTransporter.class); - return extensionLoader.getExtension(CURATOR_5); - } - - static boolean isHighVersionCurator() { - try { - Class.forName("org.apache.curator.framework.recipes.cache.CuratorCache"); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } -} diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.model.ScopeModelInitializer b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.model.ScopeModelInitializer deleted file mode 100644 index 1568955be79..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.model.ScopeModelInitializer +++ /dev/null @@ -1 +0,0 @@ -dubbo-remoting-api=org.apache.dubbo.remoting.RemotingScopeModelInitializer diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/AbstractZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/AbstractZookeeperTransporter.java similarity index 97% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/AbstractZookeeperTransporter.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/AbstractZookeeperTransporter.java index 802ec8820c2..4891e1976f0 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/AbstractZookeeperTransporter.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/AbstractZookeeperTransporter.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper; +package org.apache.dubbo.remoting.zookeeper.curator5; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.constants.RemotingConstants; @@ -22,6 +22,7 @@ import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.url.component.ServiceConfigURL; import org.apache.dubbo.common.utils.StringUtils; +import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; import java.util.ArrayList; import java.util.Collections; @@ -78,7 +79,7 @@ public ZookeeperClient connect(URL url) { /** * @param url the url that will create zookeeper connection . * The url in AbstractZookeeperTransporter#connect parameter is rewritten by this one. - * such as: zookeeper://127.0.0.1:2181/org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter + * such as: zookeeper://127.0.0.1:2181/org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter * @return */ protected abstract ZookeeperClient createZookeeperClient(URL url); diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperTransporter.java index 223981a2558..8bc2d9129e1 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperTransporter.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperTransporter.java @@ -17,7 +17,6 @@ package org.apache.dubbo.remoting.zookeeper.curator5; import org.apache.dubbo.common.URL; -import org.apache.dubbo.remoting.zookeeper.AbstractZookeeperTransporter; import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; public class Curator5ZookeeperTransporter extends AbstractZookeeperTransporter { diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperTransporter.java new file mode 100644 index 00000000000..38818752b09 --- /dev/null +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperTransporter.java @@ -0,0 +1,60 @@ +/* + * 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.dubbo.remoting.zookeeper.curator5; + +import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.logger.ErrorTypeAwareLogger; +import org.apache.dubbo.common.logger.LoggerFactory; +import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; +import org.apache.dubbo.rpc.model.ApplicationModel; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_DESTROY_ZOOKEEPER; + +public interface ZookeeperTransporter { + + ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ZookeeperTransporter.class); + + Map transporterMap = new ConcurrentHashMap<>(); + + ZookeeperClient connect(URL url); + + void destroy(); + + static ZookeeperTransporter getInstance(ApplicationModel applicationModel) { + if (!transporterMap.containsKey(applicationModel) || transporterMap.get(applicationModel) == null) { + ZookeeperTransporter transporter = new Curator5ZookeeperTransporter(); + applicationModel.addDestroyListener(m -> { + // destroy zookeeper clients if any + try { + transporter.destroy(); + } catch (Exception e) { + logger.error( + TRANSPORT_FAILED_DESTROY_ZOOKEEPER, + "", + "", + "Error encountered while destroying ZookeeperTransporter: " + e.getMessage(), + e); + } + }); + transporterMap.put(applicationModel, transporter); + } + return transporterMap.get(applicationModel); + } +} diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter deleted file mode 100644 index 5c998c75432..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter +++ /dev/null @@ -1 +0,0 @@ -curator5=org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperTransporter diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/support/AbstractZookeeperTransporterTest.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/support/AbstractZookeeperTransporterTest.java index 5b3eac89683..404d7077614 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/support/AbstractZookeeperTransporterTest.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/support/AbstractZookeeperTransporterTest.java @@ -17,8 +17,8 @@ package org.apache.dubbo.remoting.zookeeper.curator5.support; import org.apache.dubbo.common.URL; -import org.apache.dubbo.remoting.zookeeper.AbstractZookeeperTransporter; import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; +import org.apache.dubbo.remoting.zookeeper.curator5.AbstractZookeeperTransporter; import org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperTransporter; import java.util.List; From 114dad84f6a884575ee4e7e9bbd226a6f618a6b2 Mon Sep 17 00:00:00 2001 From: stellar Date: Tue, 9 Apr 2024 13:44:30 +0800 Subject: [PATCH 3/4] feat:merge dubbo-remoting-zookeeper-curator5 and dubbo-remoting-zookeeper-api (#13960) --- .artifacts | 1 - CHANGES.md | 2 +- dubbo-compatible/pom.xml | 2 +- .../zookeeper/ZookeeperTransporter.java | 20 ---- dubbo-config/dubbo-config-spring/pom.xml | 2 +- .../dubbo-configcenter-zookeeper/pom.xml | 4 +- .../ZookeeperDynamicConfiguration.java | 8 +- .../ZookeeperDynamicConfigurationFactory.java | 8 +- dubbo-distribution/dubbo-all-shaded/pom.xml | 11 +-- dubbo-distribution/dubbo-all/pom.xml | 8 -- dubbo-distribution/dubbo-bom/pom.xml | 5 - .../dubbo-metadata-report-zookeeper/pom.xml | 2 +- .../zookeeper/ZookeeperMetadataReport.java | 6 +- .../ZookeeperMetadataReportFactory.java | 12 +-- .../multiple/MultipleRegistry2S2RTest.java | 2 +- .../dubbo-registry-zookeeper/pom.xml | 3 +- .../registry/zookeeper/ZookeeperRegistry.java | 10 +- .../zookeeper/ZookeeperRegistryFactory.java | 12 +-- .../dubbo-remoting-zookeeper-api/pom.xml | 35 ++++++- .../zookeeper}/Curator5ZookeeperClient.java | 7 +- .../zookeeper/ZookeeperClientManager.java} | 72 +++++++-------- ...eeperReflectionTypeDescriberRegistrar.java | 2 +- ...o.aot.api.ReflectionTypeDescriberRegistrar | 1 + .../Curator5ZookeeperClientManagerTest.java} | 12 +-- .../Curator5ZookeeperClientTest.java | 3 +- .../support/ZookeeperClientManagerTest.java} | 91 ++++++++----------- .../src/test/resources/log4j2-test.xml | 0 .../dubbo-remoting-zookeeper-curator5/pom.xml | 74 --------------- .../Curator5ZookeeperTransporter.java | 28 ------ .../curator5/ZookeeperTransporter.java | 60 ------------ ...o.aot.api.ReflectionTypeDescriberRegistrar | 1 - dubbo-remoting/pom.xml | 1 - dubbo-test/dubbo-dependencies-all/pom.xml | 5 - 33 files changed, 157 insertions(+), 353 deletions(-) delete mode 100644 dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/zookeeper/ZookeeperTransporter.java rename dubbo-remoting/{dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5 => dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper}/Curator5ZookeeperClient.java (98%) rename dubbo-remoting/{dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/AbstractZookeeperTransporter.java => dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperClientManager.java} (77%) rename dubbo-remoting/{dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5 => dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper}/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java (97%) create mode 100644 dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar rename dubbo-remoting/{dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperTransporterTest.java => dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientManagerTest.java} (77%) rename dubbo-remoting/{dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5 => dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper}/Curator5ZookeeperClientTest.java (99%) rename dubbo-remoting/{dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/support/AbstractZookeeperTransporterTest.java => dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/support/ZookeeperClientManagerTest.java} (71%) rename dubbo-remoting/{dubbo-remoting-zookeeper-curator5 => dubbo-remoting-zookeeper-api}/src/test/resources/log4j2-test.xml (100%) delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper-curator5/pom.xml delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperTransporter.java delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperTransporter.java delete mode 100644 dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar diff --git a/.artifacts b/.artifacts index 4b590ccb63b..1411e793082 100644 --- a/.artifacts +++ b/.artifacts @@ -80,7 +80,6 @@ dubbo-remoting-http12 dubbo-remoting-netty dubbo-remoting-netty4 dubbo-remoting-zookeeper-api -dubbo-remoting-zookeeper-curator5 dubbo-rpc dubbo-rpc-api dubbo-rpc-dubbo diff --git a/CHANGES.md b/CHANGES.md index bf3021fc627..2983d19539d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -252,7 +252,7 @@ check 2.7.5 milestone for details. ### Notice -'zkclient' extension for 'org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter' is removed from Dubbo 2.7.1, and 'curator' extension becomes the default extension. If you happen to config your application to use 'zkclient' explicitly, pls. switch to use 'curator' instead. +'zkclient' extension for 'org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter' is removed from Dubbo 2.7.1, and 'curator' extension becomes the default extension. If you happen to config your application to use 'zkclient' explicitly, pls. switch to use 'curator' instead. ### New Features diff --git a/dubbo-compatible/pom.xml b/dubbo-compatible/pom.xml index 999941c6c69..771016b2f7c 100644 --- a/dubbo-compatible/pom.xml +++ b/dubbo-compatible/pom.xml @@ -45,7 +45,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-curator5 + dubbo-remoting-zookeeper-api ${project.parent.version} diff --git a/dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/zookeeper/ZookeeperTransporter.java b/dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/zookeeper/ZookeeperTransporter.java deleted file mode 100644 index c3cd045def3..00000000000 --- a/dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/zookeeper/ZookeeperTransporter.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 com.alibaba.dubbo.remoting.zookeeper; - -@Deprecated -public interface ZookeeperTransporter extends org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter {} diff --git a/dubbo-config/dubbo-config-spring/pom.xml b/dubbo-config/dubbo-config-spring/pom.xml index a09bb6ab894..c455a4a0594 100644 --- a/dubbo-config/dubbo-config-spring/pom.xml +++ b/dubbo-config/dubbo-config-spring/pom.xml @@ -194,7 +194,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-curator5 + dubbo-remoting-zookeeper-api ${project.parent.version} test diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml b/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml index c1deb8c3e5b..e3dc062391b 100644 --- a/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml +++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml @@ -36,7 +36,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-curator5 + dubbo-remoting-zookeeper-api ${project.parent.version} @@ -92,7 +92,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-curator5 + dubbo-remoting-zookeeper-api ${project.parent.version} diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java index 65b92064caa..9ca919a772c 100644 --- a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java +++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java @@ -24,7 +24,7 @@ import org.apache.dubbo.common.utils.CollectionUtils; import org.apache.dubbo.common.utils.NamedThreadFactory; import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; import org.apache.dubbo.rpc.model.ApplicationModel; import java.util.Collection; @@ -51,7 +51,7 @@ public class ZookeeperDynamicConfiguration extends TreePathDynamicConfiguration private final ApplicationModel applicationModel; ZookeeperDynamicConfiguration( - URL url, ZookeeperTransporter zookeeperTransporter, ApplicationModel applicationModel) { + URL url, ZookeeperClientManager zookeeperClientManager, ApplicationModel applicationModel) { super(url); this.cacheListener = new CacheListener(); @@ -67,7 +67,7 @@ public class ZookeeperDynamicConfiguration extends TreePathDynamicConfiguration new NamedThreadFactory(threadName, true), new AbortPolicyWithReport(threadName, url)); - zkClient = zookeeperTransporter.connect(url); + zkClient = zookeeperClientManager.connect(url); boolean isConnected = zkClient.isConnected(); if (!isConnected) { @@ -107,7 +107,7 @@ protected void doClose() throws Exception { // zkClient is shared in framework, should not close it here // zkClient.close(); - // See: org.apache.dubbo.remoting.zookeeper.curator5.AbstractZookeeperTransporter#destroy() + // See: org.apache.dubbo.remoting.zookeeper.AbstractZookeeperTransporter#destroy() // All zk clients is created and destroyed in ZookeeperTransporter. zkClient = null; } diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationFactory.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationFactory.java index 8e893c16c0b..9a90d5fa416 100644 --- a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationFactory.java +++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationFactory.java @@ -19,22 +19,22 @@ import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.configcenter.AbstractDynamicConfigurationFactory; import org.apache.dubbo.common.config.configcenter.DynamicConfiguration; -import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; import org.apache.dubbo.rpc.model.ApplicationModel; public class ZookeeperDynamicConfigurationFactory extends AbstractDynamicConfigurationFactory { - private final ZookeeperTransporter zookeeperTransporter; + private final ZookeeperClientManager zookeeperClientManager; private final ApplicationModel applicationModel; public ZookeeperDynamicConfigurationFactory(ApplicationModel applicationModel) { this.applicationModel = applicationModel; - this.zookeeperTransporter = ZookeeperTransporter.getInstance(applicationModel); + this.zookeeperClientManager = ZookeeperClientManager.getInstance(applicationModel); } @Override protected DynamicConfiguration createDynamicConfiguration(URL url) { - return new ZookeeperDynamicConfiguration(url, zookeeperTransporter, applicationModel); + return new ZookeeperDynamicConfiguration(url, zookeeperClientManager, applicationModel); } } diff --git a/dubbo-distribution/dubbo-all-shaded/pom.xml b/dubbo-distribution/dubbo-all-shaded/pom.xml index 15915c4ac1c..f6f5cb38a8e 100644 --- a/dubbo-distribution/dubbo-all-shaded/pom.xml +++ b/dubbo-distribution/dubbo-all-shaded/pom.xml @@ -328,14 +328,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-curator5 - ${project.version} - compile - true - - - org.apache.dubbo - dubbo-remoting-zookeeper-curator5 + dubbo-remoting-zookeeper-api ${project.version} compile true @@ -502,7 +495,7 @@ org.apache.dubbo:dubbo-remoting-http org.apache.dubbo:dubbo-remoting-netty4 org.apache.dubbo:dubbo-remoting-netty - org.apache.dubbo:dubbo-remoting-zookeeper-curator5 + org.apache.dubbo:dubbo-remoting-zookeeper-api org.apache.dubbo:dubbo-rpc-api org.apache.dubbo:dubbo-rpc-dubbo org.apache.dubbo:dubbo-rpc-injvm diff --git a/dubbo-distribution/dubbo-all/pom.xml b/dubbo-distribution/dubbo-all/pom.xml index 2c76ab79805..ca30dda2fcc 100644 --- a/dubbo-distribution/dubbo-all/pom.xml +++ b/dubbo-distribution/dubbo-all/pom.xml @@ -378,13 +378,6 @@ compile true - - org.apache.dubbo - dubbo-remoting-zookeeper-curator5 - ${project.version} - compile - true - @@ -551,7 +544,6 @@ org.apache.dubbo:dubbo-remoting-netty4 org.apache.dubbo:dubbo-remoting-netty org.apache.dubbo:dubbo-remoting-zookeeper-api - org.apache.dubbo:dubbo-remoting-zookeeper-curator5 org.apache.dubbo:dubbo-rpc-api org.apache.dubbo:dubbo-rpc-dubbo org.apache.dubbo:dubbo-rpc-injvm diff --git a/dubbo-distribution/dubbo-bom/pom.xml b/dubbo-distribution/dubbo-bom/pom.xml index 0b7366af181..7a3d764ec1d 100644 --- a/dubbo-distribution/dubbo-bom/pom.xml +++ b/dubbo-distribution/dubbo-bom/pom.xml @@ -415,11 +415,6 @@ dubbo-remoting-zookeeper-api ${project.version} - - org.apache.dubbo - dubbo-remoting-zookeeper-curator5 - ${project.version} - diff --git a/dubbo-metadata/dubbo-metadata-report-zookeeper/pom.xml b/dubbo-metadata/dubbo-metadata-report-zookeeper/pom.xml index 7a344bdfdde..6c87287df7b 100644 --- a/dubbo-metadata/dubbo-metadata-report-zookeeper/pom.xml +++ b/dubbo-metadata/dubbo-metadata-report-zookeeper/pom.xml @@ -70,7 +70,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-curator5 + dubbo-remoting-zookeeper-api ${project.parent.version} diff --git a/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReport.java b/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReport.java index 711119e74dc..f3fefaa5aad 100644 --- a/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReport.java +++ b/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReport.java @@ -35,7 +35,7 @@ import org.apache.dubbo.remoting.zookeeper.DataListener; import org.apache.dubbo.remoting.zookeeper.EventType; import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; import java.util.ArrayList; import java.util.Collections; @@ -67,7 +67,7 @@ public class ZookeeperMetadataReport extends AbstractMetadataReport { private ConcurrentMap casListenerMap = new ConcurrentHashMap<>(); - public ZookeeperMetadataReport(URL url, ZookeeperTransporter zookeeperTransporter) { + public ZookeeperMetadataReport(URL url, ZookeeperClientManager zookeeperClientManager) { super(url); if (url.isAnyHost()) { throw new IllegalStateException("registry address == null"); @@ -77,7 +77,7 @@ public ZookeeperMetadataReport(URL url, ZookeeperTransporter zookeeperTransporte group = PATH_SEPARATOR + group; } this.root = group; - zkClient = zookeeperTransporter.connect(url); + zkClient = zookeeperClientManager.connect(url); } protected String toRootDir() { diff --git a/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportFactory.java b/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportFactory.java index b589949769d..3ff78904f84 100644 --- a/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportFactory.java +++ b/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportFactory.java @@ -20,7 +20,7 @@ import org.apache.dubbo.common.extension.DisableInject; import org.apache.dubbo.metadata.report.MetadataReport; import org.apache.dubbo.metadata.report.support.AbstractMetadataReportFactory; -import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; import org.apache.dubbo.rpc.model.ApplicationModel; /** @@ -28,19 +28,19 @@ */ public class ZookeeperMetadataReportFactory extends AbstractMetadataReportFactory { - private ZookeeperTransporter zookeeperTransporter; + private ZookeeperClientManager zookeeperClientManager; public ZookeeperMetadataReportFactory(ApplicationModel applicationModel) { - this.zookeeperTransporter = ZookeeperTransporter.getInstance(applicationModel); + this.zookeeperClientManager = ZookeeperClientManager.getInstance(applicationModel); } @DisableInject - public void setZookeeperTransporter(ZookeeperTransporter zookeeperTransporter) { - this.zookeeperTransporter = zookeeperTransporter; + public void setZookeeperTransporter(ZookeeperClientManager zookeeperClientManager) { + this.zookeeperClientManager = zookeeperClientManager; } @Override public MetadataReport createMetadataReport(URL url) { - return new ZookeeperMetadataReport(url, zookeeperTransporter); + return new ZookeeperMetadataReport(url, zookeeperClientManager); } } diff --git a/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistry2S2RTest.java b/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistry2S2RTest.java index cb83155ff7d..e90a40769b4 100644 --- a/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistry2S2RTest.java +++ b/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistry2S2RTest.java @@ -20,8 +20,8 @@ import org.apache.dubbo.registry.NotifyListener; import org.apache.dubbo.registry.Registry; import org.apache.dubbo.registry.zookeeper.ZookeeperRegistry; +import org.apache.dubbo.remoting.zookeeper.Curator5ZookeeperClient; import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperClient; import java.util.ArrayList; import java.util.List; diff --git a/dubbo-registry/dubbo-registry-zookeeper/pom.xml b/dubbo-registry/dubbo-registry-zookeeper/pom.xml index f4ccf4f23a5..f545effa0c5 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/pom.xml +++ b/dubbo-registry/dubbo-registry-zookeeper/pom.xml @@ -38,9 +38,10 @@ org.apache.dubbo - dubbo-remoting-zookeeper-curator5 + dubbo-remoting-zookeeper-api ${project.parent.version} + org.apache.curator curator-x-discovery diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java index 1c00abb26e1..a68a27a3aa9 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java +++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java @@ -29,7 +29,7 @@ import org.apache.dubbo.remoting.zookeeper.ChildListener; import org.apache.dubbo.remoting.zookeeper.StateListener; import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; import org.apache.dubbo.rpc.RpcException; import java.util.ArrayList; @@ -72,7 +72,7 @@ public class ZookeeperRegistry extends CacheableFailbackRegistry { private ZookeeperClient zkClient; - public ZookeeperRegistry(URL url, ZookeeperTransporter zookeeperTransporter) { + public ZookeeperRegistry(URL url, ZookeeperClientManager zookeeperClientManager) { super(url); if (url.isAnyHost()) { @@ -85,7 +85,7 @@ public ZookeeperRegistry(URL url, ZookeeperTransporter zookeeperTransporter) { } this.root = group; - this.zkClient = zookeeperTransporter.connect(url); + this.zkClient = zookeeperClientManager.connect(url); this.zkClient.addStateListener((state) -> { if (state == StateListener.RECONNECTED) { @@ -156,7 +156,7 @@ public void destroy() { zkListeners.clear(); // Just release zkClient reference, but can not close zk client here for zk client is shared somewhere else. - // See org.apache.dubbo.remoting.zookeeper.curator5.AbstractZookeeperTransporter#destroy() + // See org.apache.dubbo.remoting.zookeeper.AbstractZookeeperTransporter#destroy() zkClient = null; } @@ -393,7 +393,7 @@ protected boolean isMatch(URL subscribeUrl, URL providerUrl) { /** * Triggered when children get changed. It will be invoked by implementation of CuratorWatcher. *

- * 'org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperClient.CuratorWatcherImpl' (Curator 5) + * 'org.apache.dubbo.remoting.zookeeper.Curator5ZookeeperClient.CuratorWatcherImpl' (Curator 5) */ private class RegistryChildListenerImpl implements ChildListener { private final ZookeeperRegistryNotifier notifier; diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java index 8f3278e1ed9..6aada64b11b 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java @@ -20,7 +20,7 @@ import org.apache.dubbo.common.extension.DisableInject; import org.apache.dubbo.registry.Registry; import org.apache.dubbo.registry.support.AbstractRegistryFactory; -import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; import org.apache.dubbo.rpc.model.ApplicationModel; /** @@ -28,7 +28,7 @@ */ public class ZookeeperRegistryFactory extends AbstractRegistryFactory { - private ZookeeperTransporter zookeeperTransporter; + private ZookeeperClientManager zookeeperClientManager; // for compatible usage public ZookeeperRegistryFactory() { @@ -37,16 +37,16 @@ public ZookeeperRegistryFactory() { public ZookeeperRegistryFactory(ApplicationModel applicationModel) { this.applicationModel = applicationModel; - this.zookeeperTransporter = ZookeeperTransporter.getInstance(applicationModel); + this.zookeeperClientManager = ZookeeperClientManager.getInstance(applicationModel); } @DisableInject - public void setZookeeperTransporter(ZookeeperTransporter zookeeperTransporter) { - this.zookeeperTransporter = zookeeperTransporter; + public void setZookeeperTransporter(ZookeeperClientManager zookeeperClientManager) { + this.zookeeperClientManager = zookeeperClientManager; } @Override public Registry createRegistry(URL url) { - return new ZookeeperRegistry(url, zookeeperTransporter); + return new ZookeeperRegistry(url, zookeeperClientManager); } } diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/pom.xml b/dubbo-remoting/dubbo-remoting-zookeeper-api/pom.xml index 1ea102a6bbb..4c397767bed 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/pom.xml +++ b/dubbo-remoting/dubbo-remoting-zookeeper-api/pom.xml @@ -29,8 +29,8 @@ The zookeeper remoting module of dubbo project false - 3.4.14 - 4.3.0 + 3.7.2 + 5.1.0 @@ -46,5 +46,36 @@ test + + org.apache.dubbo + dubbo-common + ${project.parent.version} + + + org.apache.curator + curator-framework + ${curator5_version} + + + org.apache.curator + curator-recipes + ${curator5_version} + + + org.apache.zookeeper + zookeeper + ${zookeeper_version} + + + + org.apache.dubbo + dubbo-native + ${project.parent.version} + + + org.apache.logging.log4j + log4j-slf4j-impl + test + diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClient.java similarity index 98% rename from dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClient.java rename to dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClient.java index 65b6bd67975..fa0dab5638b 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClient.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClient.java @@ -14,17 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper.curator5; +package org.apache.dubbo.remoting.zookeeper; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.configcenter.ConfigItem; import org.apache.dubbo.common.logger.ErrorTypeAwareLogger; import org.apache.dubbo.common.logger.LoggerFactory; -import org.apache.dubbo.remoting.zookeeper.AbstractZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.ChildListener; -import org.apache.dubbo.remoting.zookeeper.DataListener; -import org.apache.dubbo.remoting.zookeeper.EventType; -import org.apache.dubbo.remoting.zookeeper.StateListener; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/AbstractZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperClientManager.java similarity index 77% rename from dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/AbstractZookeeperTransporter.java rename to dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperClientManager.java index 4891e1976f0..77332a16be1 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/AbstractZookeeperTransporter.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperClientManager.java @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper.curator5; +package org.apache.dubbo.remoting.zookeeper; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.constants.RemotingConstants; -import org.apache.dubbo.common.logger.Logger; +import org.apache.dubbo.common.logger.ErrorTypeAwareLogger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.url.component.ServiceConfigURL; import org.apache.dubbo.common.utils.StringUtils; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; +import org.apache.dubbo.rpc.model.ApplicationModel; import java.util.ArrayList; import java.util.Collections; @@ -32,25 +32,42 @@ import java.util.concurrent.ConcurrentHashMap; import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY; +import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_DESTROY_ZOOKEEPER; -/** - * AbstractZookeeperTransporter is abstract implements of ZookeeperTransporter. - *

- * If you want to extend this, implements createZookeeperClient. - */ -public abstract class AbstractZookeeperTransporter implements ZookeeperTransporter { - private static final Logger logger = LoggerFactory.getLogger(ZookeeperTransporter.class); +public class ZookeeperClientManager { + + private static final ErrorTypeAwareLogger logger = + LoggerFactory.getErrorTypeAwareLogger(ZookeeperClientManager.class); private final Map zookeeperClientMap = new ConcurrentHashMap<>(); + private static final Map managerMap = new ConcurrentHashMap<>(); /** - * share connect for registry, metadata, etc.. - *

- * Make sure the connection is connected. - * - * @param url - * @return + * Use getInstance instead of get Instance + * This method is made public solely for unit test purposes. */ - @Override + public ZookeeperClientManager() {} + + public static ZookeeperClientManager getInstance(ApplicationModel applicationModel) { + if (!managerMap.containsKey(applicationModel) || managerMap.get(applicationModel) == null) { + ZookeeperClientManager clientManager = new ZookeeperClientManager(); + applicationModel.addDestroyListener(m -> { + // destroy zookeeper clients if any + try { + clientManager.destroy(); + } catch (Exception e) { + logger.error( + TRANSPORT_FAILED_DESTROY_ZOOKEEPER, + "", + "", + "Error encountered while destroying ZookeeperTransporter: " + e.getMessage(), + e); + } + }); + managerMap.put(applicationModel, clientManager); + } + return managerMap.get(applicationModel); + } + public ZookeeperClient connect(URL url) { ZookeeperClient zookeeperClient; // address format: {[username:password@]address} @@ -69,29 +86,13 @@ public ZookeeperClient connect(URL url) { return zookeeperClient; } - zookeeperClient = createZookeeperClient(url); + zookeeperClient = new Curator5ZookeeperClient(url); logger.info("No valid zookeeper client found from cache, therefore create a new client for url. " + url); writeToClientMap(addressList, zookeeperClient); } return zookeeperClient; } - /** - * @param url the url that will create zookeeper connection . - * The url in AbstractZookeeperTransporter#connect parameter is rewritten by this one. - * such as: zookeeper://127.0.0.1:2181/org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperTransporter - * @return - */ - protected abstract ZookeeperClient createZookeeperClient(URL url); - - /** - * get the ZookeeperClient from cache, the ZookeeperClient must be connected. - *

- * It is not private method for unit test. - * - * @param addressList - * @return - */ public ZookeeperClient fetchAndUpdateZookeeperClientCache(List addressList) { ZookeeperClient zookeeperClient = null; for (String address : addressList) { @@ -174,7 +175,7 @@ URL toClientURL(URL url) { url.getPassword(), url.getHost(), url.getPort(), - ZookeeperTransporter.class.getName(), + ZookeeperClientManager.class.getName(), parameterMap); } @@ -187,7 +188,6 @@ public Map getZookeeperClientMap() { return zookeeperClientMap; } - @Override public void destroy() { // only destroy zk clients here for (ZookeeperClient client : zookeeperClientMap.values()) { diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java similarity index 97% rename from dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java rename to dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java index 728dbe819f1..1acbf727f04 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper.curator5.aot; +package org.apache.dubbo.remoting.zookeeper.aot; import org.apache.dubbo.aot.api.MemberCategory; import org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar new file mode 100644 index 00000000000..fbf8d18b8d4 --- /dev/null +++ b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar @@ -0,0 +1 @@ +curator5Zookeeper=org.apache.dubbo.remoting.zookeeper.aot.Curator5ZookeeperReflectionTypeDescriberRegistrar diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperTransporterTest.java b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientManagerTest.java similarity index 77% rename from dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperTransporterTest.java rename to dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientManagerTest.java index f94f4e0053e..e02f4061942 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperTransporterTest.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientManagerTest.java @@ -14,10 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper.curator5; +package org.apache.dubbo.remoting.zookeeper; import org.apache.dubbo.common.URL; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -27,9 +26,9 @@ import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.nullValue; -class Curator5ZookeeperTransporterTest { +class Curator5ZookeeperClientManagerTest { private ZookeeperClient zookeeperClient; - private Curator5ZookeeperTransporter curatorZookeeperTransporter; + private ZookeeperClientManager zookeeperClientManager; private static String zookeeperConnectionAddress1; @BeforeAll @@ -39,9 +38,8 @@ public static void beforeAll() { @BeforeEach public void setUp() { - zookeeperClient = - new Curator5ZookeeperTransporter().connect(URL.valueOf(zookeeperConnectionAddress1 + "/service")); - curatorZookeeperTransporter = new Curator5ZookeeperTransporter(); + zookeeperClient = new ZookeeperClientManager().connect(URL.valueOf(zookeeperConnectionAddress1 + "/service")); + zookeeperClientManager = new ZookeeperClientManager(); } @Test diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClientTest.java b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientTest.java similarity index 99% rename from dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClientTest.java rename to dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientTest.java index 50e96f93543..59ca2df8c41 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClientTest.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientTest.java @@ -14,11 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper.curator5; +package org.apache.dubbo.remoting.zookeeper; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.configcenter.ConfigItem; -import org.apache.dubbo.remoting.zookeeper.ChildListener; import java.nio.charset.StandardCharsets; import java.util.List; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/support/AbstractZookeeperTransporterTest.java b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/support/ZookeeperClientManagerTest.java similarity index 71% rename from dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/support/AbstractZookeeperTransporterTest.java rename to dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/support/ZookeeperClientManagerTest.java index 404d7077614..7ad0e487bc8 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/support/AbstractZookeeperTransporterTest.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/support/ZookeeperClientManagerTest.java @@ -14,12 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper.curator5.support; +package org.apache.dubbo.remoting.zookeeper.support; import org.apache.dubbo.common.URL; import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.curator5.AbstractZookeeperTransporter; -import org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperTransporter; +import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; import java.util.List; @@ -33,11 +32,11 @@ import static org.hamcrest.core.IsNull.nullValue; /** - * AbstractZookeeperTransporterTest + * ZookeeperManagerTest */ -class AbstractZookeeperTransporterTest { +class ZookeeperClientManagerTest { private ZookeeperClient zookeeperClient; - private AbstractZookeeperTransporter abstractZookeeperTransporter; + private ZookeeperClientManager zookeeperClientManager; private static int zookeeperServerPort1, zookeeperServerPort2; private static String zookeeperConnectionAddress1, zookeeperConnectionAddress2; @@ -54,9 +53,8 @@ public static void beforeAll() { @BeforeEach public void setUp() throws Exception { - zookeeperClient = - new Curator5ZookeeperTransporter().connect(URL.valueOf(zookeeperConnectionAddress1 + "/service")); - abstractZookeeperTransporter = new Curator5ZookeeperTransporter(); + zookeeperClient = new ZookeeperClientManager().connect(URL.valueOf(zookeeperConnectionAddress1 + "/service")); + zookeeperClientManager = new ZookeeperClientManager(); } @Test @@ -70,7 +68,7 @@ void testGetURLBackupAddress() { URL url = URL.valueOf( zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService?backup=127.0.0.1:" + 9099 + "&application=metadatareport-local-xml-provider2&dubbo=2.0.2&interface=org.apache.dubbo.registry.RegistryService&pid=47418&specVersion=2.7.0-SNAPSHOT×tamp=1547102428828"); - List stringList = abstractZookeeperTransporter.getURLBackupAddress(url); + List stringList = zookeeperClientManager.getURLBackupAddress(url); Assertions.assertEquals(stringList.size(), 2); Assertions.assertEquals(stringList.get(0), "127.0.0.1:" + zookeeperServerPort1); Assertions.assertEquals(stringList.get(1), "127.0.0.1:9099"); @@ -81,7 +79,7 @@ void testGetURLBackupAddressNoBack() { URL url = URL.valueOf( zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService?application=metadatareport-local-xml-provider2&dubbo=2.0.2&interface=org.apache.dubbo.registry.RegistryService&pid=47418&specVersion=2.7.0-SNAPSHOT×tamp=1547102428828"); - List stringList = abstractZookeeperTransporter.getURLBackupAddress(url); + List stringList = zookeeperClientManager.getURLBackupAddress(url); Assertions.assertEquals(stringList.size(), 1); Assertions.assertEquals(stringList.get(0), "127.0.0.1:" + zookeeperServerPort1); } @@ -92,13 +90,12 @@ void testFetchAndUpdateZookeeperClientCache() { zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService?backup=127.0.0.1:" + zookeeperServerPort1 + ",127.0.0.1:" + zookeeperServerPort2 + "&application=metadatareport-local-xml-provider2&dubbo=2.0.2&interface=org.apache.dubbo.registry.RegistryService&pid=47418&specVersion=2.7.0-SNAPSHOT×tamp=1547102428828"); - ZookeeperClient newZookeeperClient = abstractZookeeperTransporter.connect(url); + ZookeeperClient newZookeeperClient = zookeeperClientManager.connect(url); // just for connected newZookeeperClient.getContent("/dubbo/test"); + Assertions.assertEquals(zookeeperClientManager.getZookeeperClientMap().size(), 2); Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 2); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), + zookeeperClientManager.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), newZookeeperClient); URL url2 = URL.valueOf( @@ -113,8 +110,8 @@ void testFetchAndUpdateZookeeperClientCache() { } private void checkFetchAndUpdateCacheNotNull(URL url) { - List addressList = abstractZookeeperTransporter.getURLBackupAddress(url); - ZookeeperClient zookeeperClient = abstractZookeeperTransporter.fetchAndUpdateZookeeperClientCache(addressList); + List addressList = zookeeperClientManager.getURLBackupAddress(url); + ZookeeperClient zookeeperClient = zookeeperClientManager.fetchAndUpdateZookeeperClientCache(addressList); Assertions.assertNotNull(zookeeperClient); } @@ -126,24 +123,22 @@ void testRepeatConnect() { URL url2 = URL.valueOf( zookeeperConnectionAddress1 + "/org.apache.dubbo.metadata.store.MetadataReport?address=zookeeper://127.0.0.1:2181&application=metadatareport-local-xml-provider2&cycle-report=false&interface=org.apache.dubbo.metadata.store.MetadataReport&retry-period=4590&retry-times=23&sync-report=true"); - ZookeeperClient newZookeeperClient = abstractZookeeperTransporter.connect(url); + ZookeeperClient newZookeeperClient = zookeeperClientManager.connect(url); // just for connected newZookeeperClient.getContent("/dubbo/test"); + Assertions.assertEquals(zookeeperClientManager.getZookeeperClientMap().size(), 1); Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 1); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), + zookeeperClientManager.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), newZookeeperClient); Assertions.assertTrue(newZookeeperClient.isConnected()); - ZookeeperClient newZookeeperClient2 = abstractZookeeperTransporter.connect(url2); + ZookeeperClient newZookeeperClient2 = zookeeperClientManager.connect(url2); // just for connected newZookeeperClient2.getContent("/dubbo/test"); Assertions.assertEquals(newZookeeperClient, newZookeeperClient2); + Assertions.assertEquals(zookeeperClientManager.getZookeeperClientMap().size(), 1); Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 1); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), + zookeeperClientManager.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), newZookeeperClient); } @@ -155,23 +150,21 @@ void testNotRepeatConnect() { URL url2 = URL.valueOf( zookeeperConnectionAddress2 + "/org.apache.dubbo.metadata.store.MetadataReport?address=zookeeper://127.0.0.1:2181&application=metadatareport-local-xml-provider2&cycle-report=false&interface=org.apache.dubbo.metadata.store.MetadataReport&retry-period=4590&retry-times=23&sync-report=true"); - ZookeeperClient newZookeeperClient = abstractZookeeperTransporter.connect(url); + ZookeeperClient newZookeeperClient = zookeeperClientManager.connect(url); // just for connected newZookeeperClient.getContent("/dubbo/test"); + Assertions.assertEquals(zookeeperClientManager.getZookeeperClientMap().size(), 1); Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 1); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), + zookeeperClientManager.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), newZookeeperClient); - ZookeeperClient newZookeeperClient2 = abstractZookeeperTransporter.connect(url2); + ZookeeperClient newZookeeperClient2 = zookeeperClientManager.connect(url2); // just for connected newZookeeperClient2.getContent("/dubbo/test"); Assertions.assertNotEquals(newZookeeperClient, newZookeeperClient2); + Assertions.assertEquals(zookeeperClientManager.getZookeeperClientMap().size(), 2); Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 2); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort2), + zookeeperClientManager.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort2), newZookeeperClient2); } @@ -186,23 +179,21 @@ void testRepeatConnectForBackUpAdd() { zookeeperConnectionAddress1 + "/org.apache.dubbo.metadata.store.MetadataReport?backup=127.0.0.1:" + zookeeperServerPort2 + "&address=zookeeper://127.0.0.1:2181&application=metadatareport-local-xml-provider2&cycle-report=false&interface=org.apache.dubbo.metadata.store.MetadataReport&retry-period=4590&retry-times=23&sync-report=true"); - ZookeeperClient newZookeeperClient = abstractZookeeperTransporter.connect(url); + ZookeeperClient newZookeeperClient = zookeeperClientManager.connect(url); // just for connected newZookeeperClient.getContent("/dubbo/test"); + Assertions.assertEquals(zookeeperClientManager.getZookeeperClientMap().size(), 1); Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 1); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), + zookeeperClientManager.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), newZookeeperClient); - ZookeeperClient newZookeeperClient2 = abstractZookeeperTransporter.connect(url2); + ZookeeperClient newZookeeperClient2 = zookeeperClientManager.connect(url2); // just for connected newZookeeperClient2.getContent("/dubbo/test"); Assertions.assertEquals(newZookeeperClient, newZookeeperClient2); + Assertions.assertEquals(zookeeperClientManager.getZookeeperClientMap().size(), 2); Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 2); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort2), + zookeeperClientManager.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort2), newZookeeperClient2); } @@ -216,23 +207,21 @@ void testRepeatConnectForNoMatchBackUpAdd() { URL url2 = URL.valueOf( zookeeperConnectionAddress2 + "/org.apache.dubbo.metadata.store.MetadataReport?address=zookeeper://127.0.0.1:2181&application=metadatareport-local-xml-provider2&cycle-report=false&interface=org.apache.dubbo.metadata.store.MetadataReport&retry-period=4590&retry-times=23&sync-report=true"); - ZookeeperClient newZookeeperClient = abstractZookeeperTransporter.connect(url); + ZookeeperClient newZookeeperClient = zookeeperClientManager.connect(url); // just for connected newZookeeperClient.getContent("/dubbo/test"); + Assertions.assertEquals(zookeeperClientManager.getZookeeperClientMap().size(), 1); Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 1); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), + zookeeperClientManager.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort1), newZookeeperClient); - ZookeeperClient newZookeeperClient2 = abstractZookeeperTransporter.connect(url2); + ZookeeperClient newZookeeperClient2 = zookeeperClientManager.connect(url2); // just for connected newZookeeperClient2.getContent("/dubbo/test"); Assertions.assertNotEquals(newZookeeperClient, newZookeeperClient2); + Assertions.assertEquals(zookeeperClientManager.getZookeeperClientMap().size(), 2); Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().size(), 2); - Assertions.assertEquals( - abstractZookeeperTransporter.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort2), + zookeeperClientManager.getZookeeperClientMap().get("127.0.0.1:" + zookeeperServerPort2), newZookeeperClient2); } @@ -240,8 +229,8 @@ void testRepeatConnectForNoMatchBackUpAdd() { void testSameHostWithDifferentUser() { URL url1 = URL.valueOf("zookeeper://us1:pw1@127.0.0.1:" + zookeeperServerPort1 + "/path1"); URL url2 = URL.valueOf("zookeeper://us2:pw2@127.0.0.1:" + zookeeperServerPort1 + "/path2"); - ZookeeperClient client1 = abstractZookeeperTransporter.connect(url1); - ZookeeperClient client2 = abstractZookeeperTransporter.connect(url2); + ZookeeperClient client1 = zookeeperClientManager.connect(url1); + ZookeeperClient client2 = zookeeperClientManager.connect(url2); assertThat(client1, not(client2)); } } diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/resources/log4j2-test.xml b/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/resources/log4j2-test.xml similarity index 100% rename from dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/resources/log4j2-test.xml rename to dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/resources/log4j2-test.xml diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/pom.xml b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/pom.xml deleted file mode 100644 index 9015bb26eea..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/pom.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - 4.0.0 - - org.apache.dubbo - dubbo-remoting - ${revision} - ../pom.xml - - dubbo-remoting-zookeeper-curator5 - jar - ${project.artifactId} - The zookeeper curator5 remoting module of dubbo project - - false - 5.1.0 - 3.7.2 - - - - - org.apache.dubbo - dubbo-remoting-zookeeper-api - ${project.parent.version} - - - org.apache.dubbo - dubbo-common - ${project.parent.version} - - - org.apache.curator - curator-framework - ${curator5_version} - - - org.apache.curator - curator-recipes - ${curator5_version} - - - org.apache.zookeeper - zookeeper - ${zookeeper_version} - - - - org.apache.dubbo - dubbo-native - ${project.parent.version} - - - org.apache.logging.log4j - log4j-slf4j-impl - test - - - diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperTransporter.java deleted file mode 100644 index 8bc2d9129e1..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperTransporter.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.dubbo.remoting.zookeeper.curator5; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; - -public class Curator5ZookeeperTransporter extends AbstractZookeeperTransporter { - - @Override - public ZookeeperClient createZookeeperClient(URL url) { - return new Curator5ZookeeperClient(url); - } -} diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperTransporter.java deleted file mode 100644 index 38818752b09..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperTransporter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.dubbo.remoting.zookeeper.curator5; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.logger.ErrorTypeAwareLogger; -import org.apache.dubbo.common.logger.LoggerFactory; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.rpc.model.ApplicationModel; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_DESTROY_ZOOKEEPER; - -public interface ZookeeperTransporter { - - ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ZookeeperTransporter.class); - - Map transporterMap = new ConcurrentHashMap<>(); - - ZookeeperClient connect(URL url); - - void destroy(); - - static ZookeeperTransporter getInstance(ApplicationModel applicationModel) { - if (!transporterMap.containsKey(applicationModel) || transporterMap.get(applicationModel) == null) { - ZookeeperTransporter transporter = new Curator5ZookeeperTransporter(); - applicationModel.addDestroyListener(m -> { - // destroy zookeeper clients if any - try { - transporter.destroy(); - } catch (Exception e) { - logger.error( - TRANSPORT_FAILED_DESTROY_ZOOKEEPER, - "", - "", - "Error encountered while destroying ZookeeperTransporter: " + e.getMessage(), - e); - } - }); - transporterMap.put(applicationModel, transporter); - } - return transporterMap.get(applicationModel); - } -} diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar deleted file mode 100644 index ed05e185646..00000000000 --- a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar +++ /dev/null @@ -1 +0,0 @@ -curator5Zookeeper=org.apache.dubbo.remoting.zookeeper.curator5.aot.Curator5ZookeeperReflectionTypeDescriberRegistrar diff --git a/dubbo-remoting/pom.xml b/dubbo-remoting/pom.xml index 9128721309b..35de0e0bf7d 100644 --- a/dubbo-remoting/pom.xml +++ b/dubbo-remoting/pom.xml @@ -32,7 +32,6 @@ dubbo-remoting-http dubbo-remoting-netty dubbo-remoting-zookeeper-api - dubbo-remoting-zookeeper-curator5 dubbo-remoting-netty4 dubbo-remoting-http12 diff --git a/dubbo-test/dubbo-dependencies-all/pom.xml b/dubbo-test/dubbo-dependencies-all/pom.xml index eb1195d5a1f..8ad9677d38e 100644 --- a/dubbo-test/dubbo-dependencies-all/pom.xml +++ b/dubbo-test/dubbo-dependencies-all/pom.xml @@ -325,11 +325,6 @@ dubbo-remoting-zookeeper-api ${project.version} - - org.apache.dubbo - dubbo-remoting-zookeeper-curator5 - ${project.version} - From 7fa4b7f9d2e200eb844d3e0ee5495ab44d036bd8 Mon Sep 17 00:00:00 2001 From: stellar Date: Thu, 11 Apr 2024 17:35:16 +0800 Subject: [PATCH 4/4] feat:merge dubbo-remoting-zookeeper-curator5 and dubbo-remoting-zookeeper-api (#13960) --- .artifacts | 2 +- dubbo-compatible/pom.xml | 2 +- dubbo-config/dubbo-config-spring/pom.xml | 2 +- .../dubbo-configcenter-zookeeper/pom.xml | 4 ++-- .../support/zookeeper/ZookeeperDataListener.java | 4 ++-- .../zookeeper/ZookeeperDynamicConfiguration.java | 4 ++-- .../ZookeeperDynamicConfigurationFactory.java | 2 +- dubbo-distribution/dubbo-all-shaded/pom.xml | 4 ++-- dubbo-distribution/dubbo-all/pom.xml | 4 ++-- dubbo-distribution/dubbo-bom/pom.xml | 2 +- dubbo-metadata/dubbo-metadata-report-zookeeper/pom.xml | 2 +- .../store/zookeeper/ZookeeperMetadataReport.java | 8 ++++---- .../zookeeper/ZookeeperMetadataReportFactory.java | 2 +- .../registry/multiple/MultipleRegistry2S2RTest.java | 4 ++-- dubbo-registry/dubbo-registry-zookeeper/pom.xml | 2 +- .../dubbo/registry/zookeeper/ZookeeperRegistry.java | 10 +++++----- .../registry/zookeeper/ZookeeperRegistryFactory.java | 2 +- .../pom.xml | 2 +- .../zookeeper/curator5}/AbstractZookeeperClient.java | 2 +- .../remoting/zookeeper/curator5}/ChildListener.java | 2 +- .../zookeeper/curator5}/Curator5ZookeeperClient.java | 2 +- .../remoting/zookeeper/curator5}/DataListener.java | 2 +- .../dubbo/remoting/zookeeper/curator5}/EventType.java | 2 +- .../remoting/zookeeper/curator5}/StateListener.java | 2 +- .../remoting/zookeeper/curator5}/ZookeeperClient.java | 2 +- .../zookeeper/curator5}/ZookeeperClientManager.java | 2 +- ...ator5ZookeeperReflectionTypeDescriberRegistrar.java | 2 +- ...ache.dubbo.aot.api.ReflectionTypeDescriberRegistrar | 0 .../curator5}/Curator5ZookeeperClientManagerTest.java | 2 +- .../curator5}/Curator5ZookeeperClientTest.java | 2 +- .../curator5}/support/ZookeeperClientManagerTest.java | 6 +++--- .../src/test/resources/log4j2-test.xml | 0 dubbo-remoting/pom.xml | 2 +- dubbo-test/dubbo-dependencies-all/pom.xml | 2 +- 34 files changed, 47 insertions(+), 47 deletions(-) rename dubbo-remoting/{dubbo-remoting-zookeeper-api => dubbo-remoting-zookeeper-curator5}/pom.xml (98%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5}/AbstractZookeeperClient.java (99%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5}/ChildListener.java (94%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5}/Curator5ZookeeperClient.java (99%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5}/DataListener.java (94%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5}/EventType.java (96%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5}/StateListener.java (94%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5}/ZookeeperClient.java (98%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5}/ZookeeperClientManager.java (99%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5}/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java (97%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api => dubbo-remoting-zookeeper-curator5}/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar (100%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5}/Curator5ZookeeperClientManagerTest.java (97%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5}/Curator5ZookeeperClientTest.java (99%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper => dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5}/support/ZookeeperClientManagerTest.java (98%) rename dubbo-remoting/{dubbo-remoting-zookeeper-api => dubbo-remoting-zookeeper-curator5}/src/test/resources/log4j2-test.xml (100%) diff --git a/.artifacts b/.artifacts index 1411e793082..6a500ca04fd 100644 --- a/.artifacts +++ b/.artifacts @@ -79,7 +79,7 @@ dubbo-remoting-http dubbo-remoting-http12 dubbo-remoting-netty dubbo-remoting-netty4 -dubbo-remoting-zookeeper-api +dubbo-remoting-zookeeper-curator5 dubbo-rpc dubbo-rpc-api dubbo-rpc-dubbo diff --git a/dubbo-compatible/pom.xml b/dubbo-compatible/pom.xml index 771016b2f7c..999941c6c69 100644 --- a/dubbo-compatible/pom.xml +++ b/dubbo-compatible/pom.xml @@ -45,7 +45,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-api + dubbo-remoting-zookeeper-curator5 ${project.parent.version} diff --git a/dubbo-config/dubbo-config-spring/pom.xml b/dubbo-config/dubbo-config-spring/pom.xml index c455a4a0594..a09bb6ab894 100644 --- a/dubbo-config/dubbo-config-spring/pom.xml +++ b/dubbo-config/dubbo-config-spring/pom.xml @@ -194,7 +194,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-api + dubbo-remoting-zookeeper-curator5 ${project.parent.version} test diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml b/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml index e3dc062391b..c1deb8c3e5b 100644 --- a/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml +++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml @@ -36,7 +36,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-api + dubbo-remoting-zookeeper-curator5 ${project.parent.version} @@ -92,7 +92,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-api + dubbo-remoting-zookeeper-curator5 ${project.parent.version} diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDataListener.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDataListener.java index 5ec5a3cd574..508b9430a87 100644 --- a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDataListener.java +++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDataListener.java @@ -22,8 +22,8 @@ import org.apache.dubbo.common.utils.CollectionUtils; import org.apache.dubbo.metrics.config.event.ConfigCenterEvent; import org.apache.dubbo.metrics.event.MetricsEventBus; -import org.apache.dubbo.remoting.zookeeper.DataListener; -import org.apache.dubbo.remoting.zookeeper.EventType; +import org.apache.dubbo.remoting.zookeeper.curator5.DataListener; +import org.apache.dubbo.remoting.zookeeper.curator5.EventType; import org.apache.dubbo.rpc.model.ApplicationModel; import java.util.Set; diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java index 9ca919a772c..1dee56fb636 100644 --- a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java +++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java @@ -23,8 +23,8 @@ import org.apache.dubbo.common.threadpool.support.AbortPolicyWithReport; import org.apache.dubbo.common.utils.CollectionUtils; import org.apache.dubbo.common.utils.NamedThreadFactory; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClient; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClientManager; import org.apache.dubbo.rpc.model.ApplicationModel; import java.util.Collection; diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationFactory.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationFactory.java index 9a90d5fa416..542d0c48d27 100644 --- a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationFactory.java +++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationFactory.java @@ -19,7 +19,7 @@ import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.configcenter.AbstractDynamicConfigurationFactory; import org.apache.dubbo.common.config.configcenter.DynamicConfiguration; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClientManager; import org.apache.dubbo.rpc.model.ApplicationModel; public class ZookeeperDynamicConfigurationFactory extends AbstractDynamicConfigurationFactory { diff --git a/dubbo-distribution/dubbo-all-shaded/pom.xml b/dubbo-distribution/dubbo-all-shaded/pom.xml index f6f5cb38a8e..cf41c2bb2b1 100644 --- a/dubbo-distribution/dubbo-all-shaded/pom.xml +++ b/dubbo-distribution/dubbo-all-shaded/pom.xml @@ -328,7 +328,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-api + dubbo-remoting-zookeeper-curator5 ${project.version} compile true @@ -495,7 +495,7 @@ org.apache.dubbo:dubbo-remoting-http org.apache.dubbo:dubbo-remoting-netty4 org.apache.dubbo:dubbo-remoting-netty - org.apache.dubbo:dubbo-remoting-zookeeper-api + org.apache.dubbo:dubbo-remoting-zookeeper-curator5 org.apache.dubbo:dubbo-rpc-api org.apache.dubbo:dubbo-rpc-dubbo org.apache.dubbo:dubbo-rpc-injvm diff --git a/dubbo-distribution/dubbo-all/pom.xml b/dubbo-distribution/dubbo-all/pom.xml index ca30dda2fcc..48725092bac 100644 --- a/dubbo-distribution/dubbo-all/pom.xml +++ b/dubbo-distribution/dubbo-all/pom.xml @@ -373,7 +373,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-api + dubbo-remoting-zookeeper-curator5 ${project.version} compile true @@ -543,7 +543,7 @@ org.apache.dubbo:dubbo-remoting-http12 org.apache.dubbo:dubbo-remoting-netty4 org.apache.dubbo:dubbo-remoting-netty - org.apache.dubbo:dubbo-remoting-zookeeper-api + org.apache.dubbo:dubbo-remoting-zookeeper-curator5 org.apache.dubbo:dubbo-rpc-api org.apache.dubbo:dubbo-rpc-dubbo org.apache.dubbo:dubbo-rpc-injvm diff --git a/dubbo-distribution/dubbo-bom/pom.xml b/dubbo-distribution/dubbo-bom/pom.xml index 7a3d764ec1d..80335d6743b 100644 --- a/dubbo-distribution/dubbo-bom/pom.xml +++ b/dubbo-distribution/dubbo-bom/pom.xml @@ -412,7 +412,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-api + dubbo-remoting-zookeeper-curator5 ${project.version} diff --git a/dubbo-metadata/dubbo-metadata-report-zookeeper/pom.xml b/dubbo-metadata/dubbo-metadata-report-zookeeper/pom.xml index 6c87287df7b..7a344bdfdde 100644 --- a/dubbo-metadata/dubbo-metadata-report-zookeeper/pom.xml +++ b/dubbo-metadata/dubbo-metadata-report-zookeeper/pom.xml @@ -70,7 +70,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-api + dubbo-remoting-zookeeper-curator5 ${project.parent.version} diff --git a/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReport.java b/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReport.java index f3fefaa5aad..205138cf472 100644 --- a/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReport.java +++ b/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReport.java @@ -32,10 +32,10 @@ import org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier; import org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier; import org.apache.dubbo.metadata.report.support.AbstractMetadataReport; -import org.apache.dubbo.remoting.zookeeper.DataListener; -import org.apache.dubbo.remoting.zookeeper.EventType; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; +import org.apache.dubbo.remoting.zookeeper.curator5.DataListener; +import org.apache.dubbo.remoting.zookeeper.curator5.EventType; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClient; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClientManager; import java.util.ArrayList; import java.util.Collections; diff --git a/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportFactory.java b/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportFactory.java index 3ff78904f84..568eacf6d43 100644 --- a/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportFactory.java +++ b/dubbo-metadata/dubbo-metadata-report-zookeeper/src/main/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportFactory.java @@ -20,7 +20,7 @@ import org.apache.dubbo.common.extension.DisableInject; import org.apache.dubbo.metadata.report.MetadataReport; import org.apache.dubbo.metadata.report.support.AbstractMetadataReportFactory; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClientManager; import org.apache.dubbo.rpc.model.ApplicationModel; /** diff --git a/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistry2S2RTest.java b/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistry2S2RTest.java index e90a40769b4..7a258f7ff5b 100644 --- a/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistry2S2RTest.java +++ b/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistry2S2RTest.java @@ -20,8 +20,8 @@ import org.apache.dubbo.registry.NotifyListener; import org.apache.dubbo.registry.Registry; import org.apache.dubbo.registry.zookeeper.ZookeeperRegistry; -import org.apache.dubbo.remoting.zookeeper.Curator5ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; +import org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperClient; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClient; import java.util.ArrayList; import java.util.List; diff --git a/dubbo-registry/dubbo-registry-zookeeper/pom.xml b/dubbo-registry/dubbo-registry-zookeeper/pom.xml index f545effa0c5..f9228eb8786 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/pom.xml +++ b/dubbo-registry/dubbo-registry-zookeeper/pom.xml @@ -38,7 +38,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-api + dubbo-remoting-zookeeper-curator5 ${project.parent.version} diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java index a68a27a3aa9..7ac6e69d5b5 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java +++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java @@ -26,10 +26,10 @@ import org.apache.dubbo.registry.NotifyListener; import org.apache.dubbo.registry.support.CacheableFailbackRegistry; import org.apache.dubbo.remoting.Constants; -import org.apache.dubbo.remoting.zookeeper.ChildListener; -import org.apache.dubbo.remoting.zookeeper.StateListener; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; +import org.apache.dubbo.remoting.zookeeper.curator5.ChildListener; +import org.apache.dubbo.remoting.zookeeper.curator5.StateListener; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClient; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClientManager; import org.apache.dubbo.rpc.RpcException; import java.util.ArrayList; @@ -393,7 +393,7 @@ protected boolean isMatch(URL subscribeUrl, URL providerUrl) { /** * Triggered when children get changed. It will be invoked by implementation of CuratorWatcher. *

- * 'org.apache.dubbo.remoting.zookeeper.Curator5ZookeeperClient.CuratorWatcherImpl' (Curator 5) + * 'org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperClient.CuratorWatcherImpl' (Curator 5) */ private class RegistryChildListenerImpl implements ChildListener { private final ZookeeperRegistryNotifier notifier; diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java index 6aada64b11b..c830c557a3e 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java @@ -20,7 +20,7 @@ import org.apache.dubbo.common.extension.DisableInject; import org.apache.dubbo.registry.Registry; import org.apache.dubbo.registry.support.AbstractRegistryFactory; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClientManager; import org.apache.dubbo.rpc.model.ApplicationModel; /** diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/pom.xml b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/pom.xml similarity index 98% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/pom.xml rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/pom.xml index 4c397767bed..5f57672cedb 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/pom.xml +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/pom.xml @@ -23,7 +23,7 @@ ${revision} ../pom.xml - dubbo-remoting-zookeeper-api + dubbo-remoting-zookeeper-curator5 jar ${project.artifactId} The zookeeper remoting module of dubbo project diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/AbstractZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/AbstractZookeeperClient.java similarity index 99% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/AbstractZookeeperClient.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/AbstractZookeeperClient.java index e830246617a..fe7a9b6015f 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/AbstractZookeeperClient.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/AbstractZookeeperClient.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper; +package org.apache.dubbo.remoting.zookeeper.curator5; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.configcenter.ConfigItem; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ChildListener.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ChildListener.java similarity index 94% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ChildListener.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ChildListener.java index 5ada2815a87..4586f23d9c3 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ChildListener.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ChildListener.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper; +package org.apache.dubbo.remoting.zookeeper.curator5; import java.util.List; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClient.java similarity index 99% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClient.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClient.java index fa0dab5638b..fd51c9f0488 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClient.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClient.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper; +package org.apache.dubbo.remoting.zookeeper.curator5; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.configcenter.ConfigItem; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/DataListener.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/DataListener.java similarity index 94% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/DataListener.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/DataListener.java index 95b948adafa..483c9d63acd 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/DataListener.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/DataListener.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper; +package org.apache.dubbo.remoting.zookeeper.curator5; /** * 2019-02-26 diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/EventType.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/EventType.java similarity index 96% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/EventType.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/EventType.java index 9e288036472..25e844fb40f 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/EventType.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/EventType.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper; +package org.apache.dubbo.remoting.zookeeper.curator5; /** * 2019-02-26 diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/StateListener.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/StateListener.java similarity index 94% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/StateListener.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/StateListener.java index 202b6cc63bf..432db95eb35 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/StateListener.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/StateListener.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper; +package org.apache.dubbo.remoting.zookeeper.curator5; public interface StateListener { diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperClient.java similarity index 98% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperClient.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperClient.java index b2877cd2598..5371f393fd1 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperClient.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperClient.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper; +package org.apache.dubbo.remoting.zookeeper.curator5; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.configcenter.ConfigItem; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperClientManager.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperClientManager.java similarity index 99% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperClientManager.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperClientManager.java index 77332a16be1..53c63a889e8 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperClientManager.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/ZookeeperClientManager.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper; +package org.apache.dubbo.remoting.zookeeper.curator5; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.constants.RemotingConstants; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java similarity index 97% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java index 1acbf727f04..728dbe819f1 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/java/org/apache/dubbo/remoting/zookeeper/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/aot/Curator5ZookeeperReflectionTypeDescriberRegistrar.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper.aot; +package org.apache.dubbo.remoting.zookeeper.curator5.aot; import org.apache.dubbo.aot.api.MemberCategory; import org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar similarity index 100% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientManagerTest.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClientManagerTest.java similarity index 97% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientManagerTest.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClientManagerTest.java index e02f4061942..e256e4557b6 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientManagerTest.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClientManagerTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper; +package org.apache.dubbo.remoting.zookeeper.curator5; import org.apache.dubbo.common.URL; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientTest.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClientTest.java similarity index 99% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientTest.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClientTest.java index 59ca2df8c41..e515fc6504b 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/Curator5ZookeeperClientTest.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClientTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper; +package org.apache.dubbo.remoting.zookeeper.curator5; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.configcenter.ConfigItem; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/support/ZookeeperClientManagerTest.java b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/support/ZookeeperClientManagerTest.java similarity index 98% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/support/ZookeeperClientManagerTest.java rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/support/ZookeeperClientManagerTest.java index 7ad0e487bc8..a66d94b0edd 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/java/org/apache/dubbo/remoting/zookeeper/support/ZookeeperClientManagerTest.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/java/org/apache/dubbo/remoting/zookeeper/curator5/support/ZookeeperClientManagerTest.java @@ -14,11 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.remoting.zookeeper.support; +package org.apache.dubbo.remoting.zookeeper.curator5.support; import org.apache.dubbo.common.URL; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; -import org.apache.dubbo.remoting.zookeeper.ZookeeperClientManager; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClient; +import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClientManager; import java.util.List; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/resources/log4j2-test.xml b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/resources/log4j2-test.xml similarity index 100% rename from dubbo-remoting/dubbo-remoting-zookeeper-api/src/test/resources/log4j2-test.xml rename to dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/test/resources/log4j2-test.xml diff --git a/dubbo-remoting/pom.xml b/dubbo-remoting/pom.xml index 35de0e0bf7d..5e4ec226cf5 100644 --- a/dubbo-remoting/pom.xml +++ b/dubbo-remoting/pom.xml @@ -31,7 +31,7 @@ dubbo-remoting-api dubbo-remoting-http dubbo-remoting-netty - dubbo-remoting-zookeeper-api + dubbo-remoting-zookeeper-curator5 dubbo-remoting-netty4 dubbo-remoting-http12 diff --git a/dubbo-test/dubbo-dependencies-all/pom.xml b/dubbo-test/dubbo-dependencies-all/pom.xml index 8ad9677d38e..b5c2a75abab 100644 --- a/dubbo-test/dubbo-dependencies-all/pom.xml +++ b/dubbo-test/dubbo-dependencies-all/pom.xml @@ -322,7 +322,7 @@ org.apache.dubbo - dubbo-remoting-zookeeper-api + dubbo-remoting-zookeeper-curator5 ${project.version}