You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2018/11/27 11:09:15 UTC
[incubator-dubbo] 06/06: save one zookeeper implementation as
default
This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch dev-metadata
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
commit d9e0b6464bd86aa3b916f894d53865f78671012b
Author: ken.lj <ke...@gmail.com>
AuthorDate: Tue Nov 27 19:07:42 2018 +0800
save one zookeeper implementation as default
---
.../dubbo-configcenter-archaius/pom.xml | 53 ----
.../zookeeper/ArchaiusDynamicConfiguration.java | 163 -------------
.../sources/ZooKeeperConfigurationSource.java | 268 ---------------------
....apache.dubbo.configcenter.DynamicConfiguration | 1 -
.../dubbo-configcenter-zookeeper-cache/pom.xml | 53 ----
....apache.dubbo.configcenter.DynamicConfiguration | 1 -
.../ZookeeperDynamicConfigurationTest.java | 150 ------------
.../dubbo-configcenter-zookeeper/pom.xml | 19 +-
.../support/zookeeper/CacheListener.java | 1 -
.../zookeeper/ZookeeperDynamicConfiguration.java | 0
dubbo-configcenter/pom.xml | 2 -
dubbo-dependencies-bom/pom.xml | 12 -
12 files changed, 3 insertions(+), 720 deletions(-)
diff --git a/dubbo-configcenter/dubbo-configcenter-archaius/pom.xml b/dubbo-configcenter/dubbo-configcenter-archaius/pom.xml
deleted file mode 100644
index a122d72..0000000
--- a/dubbo-configcenter/dubbo-configcenter-archaius/pom.xml
+++ /dev/null
@@ -1,53 +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.
- -->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-configcenter</artifactId>
- <version>2.7.0-SNAPSHOT</version>
- </parent>
- <artifactId>dubbo-configcenter-archaius</artifactId>
- <packaging>jar</packaging>
- <name>${project.artifactId}</name>
- <description>The archaius implementation of the config-center api</description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-configcenter-api</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>com.netflix.archaius</groupId>
- <artifactId>archaius-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-recipes</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-configuration</groupId>
- <artifactId>commons-configuration</artifactId>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
diff --git a/dubbo-configcenter/dubbo-configcenter-archaius/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ArchaiusDynamicConfiguration.java b/dubbo-configcenter/dubbo-configcenter-archaius/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ArchaiusDynamicConfiguration.java
deleted file mode 100644
index e0c64e3..0000000
--- a/dubbo-configcenter/dubbo-configcenter-archaius/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ArchaiusDynamicConfiguration.java
+++ /dev/null
@@ -1,163 +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.configcenter.support.zookeeper;
-
-import com.netflix.config.ConfigurationManager;
-import com.netflix.config.DynamicPropertyFactory;
-import com.netflix.config.DynamicStringProperty;
-import com.netflix.config.DynamicWatchedConfiguration;
-import org.apache.dubbo.common.Constants;
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.logger.Logger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.common.utils.ConcurrentHashSet;
-import org.apache.dubbo.common.utils.StringUtils;
-import org.apache.dubbo.configcenter.AbstractDynamicConfiguration;
-import org.apache.dubbo.configcenter.ConfigChangeEvent;
-import org.apache.dubbo.configcenter.ConfigChangeType;
-import org.apache.dubbo.configcenter.ConfigType;
-import org.apache.dubbo.configcenter.ConfigurationListener;
-import org.apache.dubbo.configcenter.support.zookeeper.sources.ZooKeeperConfigurationSource;
-
-import java.util.Set;
-
-import static org.apache.dubbo.common.Constants.CONFIG_NAMESPACE_KEY;
-import static org.apache.dubbo.configcenter.support.zookeeper.sources.ZooKeeperConfigurationSource.ARCHAIUS_CONFIG_CHECK_KEY;
-import static org.apache.dubbo.configcenter.support.zookeeper.sources.ZooKeeperConfigurationSource.ARCHAIUS_CONFIG_ROOT_PATH_KEY;
-import static org.apache.dubbo.configcenter.support.zookeeper.sources.ZooKeeperConfigurationSource.ARCHAIUS_SOURCE_ADDRESS_KEY;
-import static org.apache.dubbo.configcenter.support.zookeeper.sources.ZooKeeperConfigurationSource.DEFAULT_CONFIG_ROOT_PATH;
-
-/**
- * Archaius supports various sources and it's extensiable: JDBC, ZK, Properties, ..., so should we make it extensiable?
- * FIXME: we should get rid of Archaius or move it to eco system since Archaius is out of maintenance, instead, we
- * should rely on curator-x-async which looks quite promising.
- */
-public class ArchaiusDynamicConfiguration extends AbstractDynamicConfiguration<ArchaiusDynamicConfiguration.ArchaiusListener> {
- private static final Logger logger = LoggerFactory.getLogger(ArchaiusDynamicConfiguration.class);
-
- public ArchaiusDynamicConfiguration() {
- }
-
- @Override
- public void initWith(URL url) {
- super.initWith(url);
-
- // String address = env.getCompositeConf().getString(ADDRESS_KEY);
- // String app = env.getCompositeConf().getString(APP_KEY);
-
- String address = url.getBackupAddress();
- if (!address.equals(Constants.ANYHOST_VALUE)) {
- System.setProperty(ARCHAIUS_SOURCE_ADDRESS_KEY, address);
- }
- System.setProperty(ARCHAIUS_CONFIG_ROOT_PATH_KEY, url.getParameter(CONFIG_NAMESPACE_KEY, DEFAULT_CONFIG_ROOT_PATH));
- System.setProperty(ARCHAIUS_CONFIG_CHECK_KEY, url.getParameter(Constants.CONFIG_CHECK_KEY, "false"));
-
- try {
- ZooKeeperConfigurationSource zkConfigSource = new ZooKeeperConfigurationSource(url);
- zkConfigSource.start();
- /*if (!zkConfigSource.isConnected()) {
- // we can check the status of config center here, and decide to fail or continue if we cannot reach the config server.
- }*/
- DynamicWatchedConfiguration zkDynamicConfig = new DynamicWatchedConfiguration(zkConfigSource);
- ConfigurationManager.install(zkDynamicConfig);
- } catch (Exception e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
-
- /**
- * The hierarchy of configuration properties is:
- * 1. /{namespace}/config/dubbo/dubbo.properties
- * 2. /{namespace}/config/{applicationname}/dubbo.properties
- * <p>
- * To make the API compatible with other configuration systems, the key doesn't has group as prefix, so we should
- * add the group prefix before try to get value. If being used for dubbo router rules, the key must already
- * contains group prefix.
- */
- @Override
- protected String getTargetConfig(String key, String group, long timeout) {
- if (StringUtils.isNotEmpty(group)) {
- key = group + "." + key;
- }
-
- return DynamicPropertyFactory.getInstance()
- .getStringProperty(key, null)
- .get();
- }
-
- /**
- * First, get app level configuration. If there's no value in app level, try to get global dubbo level.
- */
- @Override
- protected Object getInternalProperty(String key) {
- return DynamicPropertyFactory.getInstance()
- .getStringProperty(key, null)
- .get();
- }
-
- @Override
- protected void addConfigurationListener(String key, ArchaiusListener targetListener, ConfigurationListener configurationListener) {
- targetListener.addListener(configurationListener);
- }
-
- @Override
- protected ArchaiusListener createTargetListener(String key) {
- ArchaiusListener archaiusListener = new ArchaiusListener(key);
- DynamicStringProperty prop = DynamicPropertyFactory.getInstance()
- .getStringProperty(key, null);
- prop.addCallback(archaiusListener);
- return archaiusListener;
- }
-
- @Override
- protected void recover() {
- // FIXME will Archaius recover automatically?
- }
-
- public class ArchaiusListener implements Runnable {
- private Set<ConfigurationListener> listeners = new ConcurrentHashSet<>();
- private String key;
- private ConfigType type;
-
- public ArchaiusListener(String key) {
- this.key = key;
- }
-
- public void addListener(ConfigurationListener listener) {
- this.listeners.add(listener);
- }
-
- @Override
- public void run() {
- DynamicStringProperty prop = DynamicPropertyFactory.getInstance()
- .getStringProperty(key, null);
- String newValue = prop.get();
- ConfigChangeEvent event = new ConfigChangeEvent(key, newValue);
- if (newValue == null) {
- event.setChangeType(ConfigChangeType.DELETED);
- } else {
- if (newValue.equals("")) {
- logger.warn("an empty rule is received for " + key + ", the current working rule is unknown, " +
- "the empty rule will not take effect.");
- return;
- }
- event.setChangeType(ConfigChangeType.MODIFIED);
- }
- listeners.forEach(listener -> listener.process(event));
- }
- }
-}
diff --git a/dubbo-configcenter/dubbo-configcenter-archaius/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/sources/ZooKeeperConfigurationSource.java b/dubbo-configcenter/dubbo-configcenter-archaius/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/sources/ZooKeeperConfigurationSource.java
deleted file mode 100644
index e77e434..0000000
--- a/dubbo-configcenter/dubbo-configcenter-archaius/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/sources/ZooKeeperConfigurationSource.java
+++ /dev/null
@@ -1,268 +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.configcenter.support.zookeeper.sources;
-
-import com.google.common.io.Closeables;
-import com.netflix.config.WatchedConfigurationSource;
-import com.netflix.config.WatchedUpdateListener;
-import com.netflix.config.WatchedUpdateResult;
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.framework.recipes.cache.ChildData;
-import org.apache.curator.framework.recipes.cache.TreeCache;
-import org.apache.curator.framework.recipes.cache.TreeCacheEvent;
-import org.apache.curator.framework.recipes.cache.TreeCacheListener;
-import org.apache.curator.retry.ExponentialBackoffRetry;
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.utils.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-/**
- * zookeeper archaius source.
- */
-public class ZooKeeperConfigurationSource implements WatchedConfigurationSource, Closeable {
- public static final String ARCHAIUS_SOURCE_ADDRESS_KEY = "archaius.zk.address";
- public static final String ARCHAIUS_CONFIG_ROOT_PATH_KEY = "archaius.zk.rootpath";
- public static final String ARCHAIUS_CONFIG_CHECK_KEY = "archaius.zk.check";
- public static final String DEFAULT_CONFIG_ROOT_PATH = "/dubbo";
-
- private static final Logger logger = LoggerFactory.getLogger(ZooKeeperConfigurationSource.class);
- private Executor executor = Executors.newFixedThreadPool(1);
- private final CuratorFramework client;
-
- // The final root path would be: /configRootPath/"config"
- private final String configRootPath;
- private final TreeCache treeCache;
- private CountDownLatch initializedLatch = new CountDownLatch(1);
-
- private final Charset charset = Charset.forName("UTF-8");
-
- private List<WatchedUpdateListener> listeners = new CopyOnWriteArrayList<WatchedUpdateListener>();
-
- private URL url;
-
- public ZooKeeperConfigurationSource(URL url) {
- this(System.getProperty(ARCHAIUS_SOURCE_ADDRESS_KEY), 60 * 1000, 10000,
- System.getProperty(ARCHAIUS_CONFIG_ROOT_PATH_KEY, DEFAULT_CONFIG_ROOT_PATH));
- this.url = url;
- }
-
- public ZooKeeperConfigurationSource(int sessionTimeout, int connectTimeout, String configRootPath) {
- this(System.getProperty(ARCHAIUS_SOURCE_ADDRESS_KEY), sessionTimeout, connectTimeout, configRootPath);
- }
-
-
- /**
- * @param connectString, the zookeeper address
- * @param sessionTimeout, timeout for session
- * @param connectTimeout, timeout to wait before build a connection
- * @param configRootPath, the final path would be: configRootPath/"config"
- */
- public ZooKeeperConfigurationSource(String connectString, int sessionTimeout, int connectTimeout, String configRootPath) {
- if (connectString == null) {
- throw new IllegalArgumentException("connectString is null, must specify the address to connect for " +
- "zookeeper archaius source.");
- }
-
- if (!configRootPath.startsWith("/")) {
- configRootPath = "/" + configRootPath + "/config";
- }
-
- CuratorFramework client = CuratorFrameworkFactory.newClient(connectString, sessionTimeout, connectTimeout,
- new ExponentialBackoffRetry(1000, 3));
- client.start();
- try {
- boolean connected = client.blockUntilConnected(connectTimeout, TimeUnit.MILLISECONDS);
- if (!connected) {
- boolean check = Boolean.parseBoolean(System.getProperty(ARCHAIUS_CONFIG_CHECK_KEY, "false"));
- if (check) {
- throw new IllegalStateException("Failed to connect to config center (zookeeper): "
- + connectString + " in " + connectTimeout + "ms.");
- } else {
- logger.warn("Cannot connect to config center (zookeeper) " + connectString
- + " in " + connectTimeout + "ms");
- }
- }
- } catch (InterruptedException e) {
- throw new IllegalStateException("The thread was interrupted unexpectedly when try connecting to zookeeper "
- + connectString + " config center, ", e);
- }
- this.client = client;
- this.configRootPath = configRootPath;
- this.treeCache = new TreeCache(client, configRootPath);
- }
-
- /**
- * Creates the pathChildrenCache using the CuratorFramework client and ZK root path node for the config
- *
- * @param client zookeeper client
- * @param configRootPath path to ZK root parent node for the rest of the configuration properties (ie. /<my-app>/config)
- */
- public ZooKeeperConfigurationSource(CuratorFramework client, String configRootPath) {
- this.client = client;
- this.configRootPath = configRootPath;
- this.treeCache = new TreeCache(client, configRootPath);
- }
-
- /**
- * Adds a listener to the pathChildrenCache, initializes the cache, then starts the cache-management background
- * thread
- */
- public void start() throws Exception {
- // create the watcher for future configuration updates
- treeCache.getListenable().addListener(new TreeCacheListener() {
- public void childEvent(CuratorFramework aClient, TreeCacheEvent event) throws Exception {
-
- TreeCacheEvent.Type type = event.getType();
- ChildData data = event.getData();
- if (type == TreeCacheEvent.Type.INITIALIZED) {
- initializedLatch.countDown();
- }
-
- // TODO, ignore other event types
- if (data == null) {
- return;
- }
-
- // TODO We limit the notification of config changes to a specific path level, for example
- // /dubbo/config/service/configurators, other config changes not in this level will not get notified,
- // say /dubbo/config/dubbo.properties
- if (data.getPath().split("/").length == 5) {
- byte[] value = data.getData();
- String stringValue = new String(value, charset);
-
- // fire event to all listeners
- Map<String, Object> added = null;
- Map<String, Object> changed = null;
- Map<String, Object> deleted = null;
-
- switch (type) {
- case NODE_ADDED:
- added = new HashMap<>(1);
- added.put(pathToKey(data.getPath()), stringValue);
- break;
- case NODE_REMOVED:
- deleted = new HashMap<>(1);
- deleted.put(pathToKey(data.getPath()), stringValue);
- break;
- case NODE_UPDATED:
- changed = new HashMap<>(1);
- changed.put(pathToKey(data.getPath()), stringValue);
- }
-
- WatchedUpdateResult result = WatchedUpdateResult.createIncremental(added,
- changed, deleted);
-
- fireEvent(result);
- }
- }
- }, executor);
-
- // it's not blocking, so we use an extra latch 'initializedLatch' to make sure cache fully initialized before use.
- treeCache.start();
- }
-
- /**
- * This is used to convert a configuration nodePath into a key
- *
- * @param path
- * @return key (nodePath less the config root path)
- */
- private String pathToKey(String path) {
- if (StringUtils.isEmpty(path)) {
- return path;
- }
- return path.replace(configRootPath + "/", "").replaceAll("/", ".");
- }
-
- @Override
- public Map<String, Object> getCurrentData() throws Exception {
- logger.debug("getCurrentData() retrieving current data.");
-
- Map<String, Object> all = new HashMap<>();
-
- try {
- initializedLatch.await();
- } catch (InterruptedException e) {
- logger.error("Being interrupted unexpectedly when waiting zookeeper to initialize, the config data " +
- "may not ready yet, be careful!");
- }
-
- Map<String, ChildData> dataMap = treeCache.getCurrentChildren(configRootPath);
- if (dataMap != null && dataMap.size() > 0) {
- dataMap.forEach((childPath, childData) -> {
- String fullChildPath = configRootPath + "/" + childPath;
- /*// special treatment for /dubbo/config/dubbo.properties, it's the only config item need to store in cache in this level.
- if (childPath.equals(url.getParameter(Constants.CONFIG_DATAID_KEY))) {
- all.put(pathToKey(fullChildPath), new String(childData.getData(), charset));
- }*/
- treeCache.getCurrentChildren(fullChildPath).forEach((subChildPath, subChildData) -> {
- all.put(pathToKey(fullChildPath + "/" + subChildPath), new String(subChildData.getData(), charset));
- });
- });
- }
-
- logger.debug("getCurrentData() retrieved [{}] config elements.", all.size());
-
- return all;
- }
-
- @Override
- public void addUpdateListener(WatchedUpdateListener l) {
- if (l != null) {
- listeners.add(l);
- }
- }
-
- @Override
- public void removeUpdateListener(WatchedUpdateListener l) {
- if (l != null) {
- listeners.remove(l);
- }
- }
-
- protected void fireEvent(WatchedUpdateResult result) {
- for (WatchedUpdateListener l : listeners) {
- try {
- l.updateConfiguration(result);
- } catch (Throwable ex) {
- logger.error("Error in invoking WatchedUpdateListener", ex);
- }
- }
- }
-
- public void close() {
- try {
- Closeables.close(treeCache, true);
- } catch (IOException exc) {
- logger.error("IOException should not have been thrown.", exc);
- }
- }
-}
diff --git a/dubbo-configcenter/dubbo-configcenter-archaius/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.configcenter.DynamicConfiguration b/dubbo-configcenter/dubbo-configcenter-archaius/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.configcenter.DynamicConfiguration
deleted file mode 100644
index d271f16..0000000
--- a/dubbo-configcenter/dubbo-configcenter-archaius/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.configcenter.DynamicConfiguration
+++ /dev/null
@@ -1 +0,0 @@
-archaius=org.apache.dubbo.configcenter.support.archaius.ArchaiusDynamicConfiguration
\ No newline at end of file
diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper-cache/pom.xml b/dubbo-configcenter/dubbo-configcenter-zookeeper-cache/pom.xml
deleted file mode 100644
index 191b4ae..0000000
--- a/dubbo-configcenter/dubbo-configcenter-zookeeper-cache/pom.xml
+++ /dev/null
@@ -1,53 +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.
- -->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-configcenter</artifactId>
- <version>2.7.0-SNAPSHOT</version>
- </parent>
- <artifactId>dubbo-configcenter-zookeeper-cache</artifactId>
- <packaging>jar</packaging>
- <name>${project.artifactId}</name>
- <description>The zookeeper implementation of the config-center api</description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-configcenter-api</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <version>2.12.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-recipes</artifactId>
- <version>2.12.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-test</artifactId>
- <version>2.12.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper-cache/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.configcenter.DynamicConfiguration b/dubbo-configcenter/dubbo-configcenter-zookeeper-cache/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.configcenter.DynamicConfiguration
deleted file mode 100644
index 0379c0e..0000000
--- a/dubbo-configcenter/dubbo-configcenter-zookeeper-cache/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.configcenter.DynamicConfiguration
+++ /dev/null
@@ -1 +0,0 @@
-zookeeper=org.apache.dubbo.configcenter.support.zookeeper.ZookeeperDynamicConfiguration
\ No newline at end of file
diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper-cache/src/test/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationTest.java b/dubbo-configcenter/dubbo-configcenter-zookeeper-cache/src/test/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationTest.java
deleted file mode 100644
index 382e77d..0000000
--- a/dubbo-configcenter/dubbo-configcenter-zookeeper-cache/src/test/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationTest.java
+++ /dev/null
@@ -1,150 +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.configcenter.support.zookeeper;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.retry.ExponentialBackoffRetry;
-import org.apache.curator.test.TestingServer;
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.extension.ExtensionLoader;
-import org.apache.dubbo.common.utils.NetUtils;
-import org.apache.dubbo.configcenter.ConfigChangeEvent;
-import org.apache.dubbo.configcenter.ConfigurationListener;
-import org.apache.dubbo.configcenter.DynamicConfiguration;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-
-/**
- *
- */
-public class ZookeeperDynamicConfigurationTest {
- private static CuratorFramework client;
-
- private static URL configUrl;
- private static int zkServerPort = NetUtils.getAvailablePort();
- private static TestingServer zkServer;
- private static DynamicConfiguration configuration;
-
- @BeforeClass
- public static void setUp() throws Exception {
- zkServer = new TestingServer(zkServerPort, true);
-
- client = CuratorFrameworkFactory.newClient("localhost:" + zkServerPort, 60 * 1000, 60 * 1000,
- new ExponentialBackoffRetry(1000, 3));
- client.start();
-
- try {
- setData("/dubbo/config/dubbo/dubbo.properties", "The content from dubbo.properties");
- setData("/dubbo/config/group*service:version/configurators", "The content from configurators");
- setData("/dubbo/config/appname", "The content from higer level node");
- setData("/dubbo/config/appname/tagrouters", "The content from appname tagrouters");
- } catch (Exception e) {
- e.printStackTrace();
- }
-
-
- configUrl = URL.valueOf("zookeeper://localhost:" + zkServerPort);
-
- configuration = ExtensionLoader.getExtensionLoader(DynamicConfiguration.class).getExtension(configUrl.getProtocol());
- configuration.initWith(configUrl);
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
- zkServer.stop();
- }
-
- @Test
- public void testGetConfig() throws Exception {
- Assert.assertEquals("The content from dubbo.properties", configuration.getConfig("dubbo.dubbo.properties"));
- Assert.assertEquals("The content from dubbo.properties", configuration.getConfig("dubbo.properties", "dubbo"));
- }
-
- @Test
- public void testAddListener() throws Exception {
- CountDownLatch latch = new CountDownLatch(4);
- TestListener listener1 = new TestListener(latch);
- TestListener listener2 = new TestListener(latch);
- TestListener listener3 = new TestListener(latch);
- TestListener listener4 = new TestListener(latch);
- configuration.addListener("group*service:version.configurators", listener1);
- configuration.addListener("group*service:version.configurators", listener2);
- configuration.addListener("appname.tagrouters", listener3);
- configuration.addListener("appname.tagrouters", listener4);
-
- setData("/dubbo/config/group*service:version/configurators", "new value1");
- Thread.sleep(100);
- setData("/dubbo/config/appname/tagrouters", "new value2");
- Thread.sleep(100);
- setData("/dubbo/config/appname", "new value3");
-
- Thread.sleep(5000);
-
- latch.await();
- Assert.assertEquals(1, listener1.getCount("group*service:version.configurators"));
- Assert.assertEquals(1, listener2.getCount("group*service:version.configurators"));
- Assert.assertEquals(1, listener3.getCount("appname.tagrouters"));
- Assert.assertEquals(1, listener4.getCount("appname.tagrouters"));
-
- Assert.assertEquals("new value1", listener1.getValue());
- Assert.assertEquals("new value1", listener2.getValue());
- Assert.assertEquals("new value2", listener3.getValue());
- Assert.assertEquals("new value2", listener4.getValue());
- }
-
- private static void setData(String path, String data) throws Exception {
- if (client.checkExists().forPath(path) == null) {
- client.create().creatingParentsIfNeeded().forPath(path);
- }
- client.setData().forPath(path, data.getBytes());
- }
-
- private class TestListener implements ConfigurationListener {
- private CountDownLatch latch;
- private String value;
- private Map<String, Integer> countMap = new HashMap<>();
-
- public TestListener(CountDownLatch latch) {
- this.latch = latch;
- }
-
- @Override
- public void process(ConfigChangeEvent event) {
- Integer count = countMap.computeIfAbsent(event.getKey(), k -> new Integer(0));
- countMap.put(event.getKey(), ++count);
-
- value = event.getNewValue();
- latch.countDown();
- }
-
- public int getCount(String key) {
- return countMap.get(key);
- }
-
- public String getValue() {
- return value;
- }
- }
-
-}
diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml b/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml
index 717f5ef..c672933 100644
--- a/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml
+++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml
@@ -33,31 +33,18 @@
<artifactId>dubbo-configcenter-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
- <!--<dependency>-->
- <!--<groupId>org.apache.curator</groupId>-->
- <!--<artifactId>curator-framework</artifactId>-->
- <!--</dependency>-->
<dependency>
<groupId>org.apache.curator</groupId>
- <artifactId>curator-recipes</artifactId>
+ <artifactId>curator-framework</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
- <artifactId>curator-x-async</artifactId>
- <version>4.0.1</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </exclusion>
- </exclusions>
+ <artifactId>curator-recipes</artifactId>
</dependency>
-
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
- <version>2.12.0</version>
<scope>test</scope>
</dependency>
</dependencies>
-</project>
+</project>
\ No newline at end of file
diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper-cache/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java
similarity index 98%
rename from dubbo-configcenter/dubbo-configcenter-zookeeper-cache/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java
rename to dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java
index bbfa057..b91e76e 100644
--- a/dubbo-configcenter/dubbo-configcenter-zookeeper-cache/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java
+++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java
@@ -20,7 +20,6 @@ import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.curator.framework.recipes.cache.TreeCacheEvent;
import org.apache.curator.framework.recipes.cache.TreeCacheListener;
-import org.apache.dubbo.common.config.Configuration;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.configcenter.ConfigChangeEvent;
import org.apache.dubbo.configcenter.ConfigChangeType;
diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper-cache/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
similarity index 100%
rename from dubbo-configcenter/dubbo-configcenter-zookeeper-cache/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java
rename to dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java
diff --git a/dubbo-configcenter/pom.xml b/dubbo-configcenter/pom.xml
index 4d7dd84..e969c04 100644
--- a/dubbo-configcenter/pom.xml
+++ b/dubbo-configcenter/pom.xml
@@ -33,8 +33,6 @@
<modules>
<module>dubbo-configcenter-api</module>
<module>dubbo-configcenter-zookeeper</module>
- <!--<module>dubbo-configcenter-zookeeper-cache</module>-->
<module>dubbo-configcenter-apollo</module>
- <module>dubbo-configcenter-archaius</module>
</modules>
</project>
\ No newline at end of file
diff --git a/dubbo-dependencies-bom/pom.xml b/dubbo-dependencies-bom/pom.xml
index 16a9d98..43ad512 100644
--- a/dubbo-dependencies-bom/pom.xml
+++ b/dubbo-dependencies-bom/pom.xml
@@ -99,9 +99,7 @@
<kryo_serializers_version>0.42</kryo_serializers_version>
<fst_version>2.48-jdk-6</fst_version>
<apollo_client_version>1.1.1</apollo_client_version>
- <archaius_version>0.7.6</archaius_version>
<snakeyaml_version>1.20</snakeyaml_version>
- <commons_configuration_version>1.8</commons_configuration_version>
<commons_lang3_version>3.8.1</commons_lang3_version>
<protostuff_version>1.5.9</protostuff_version>
@@ -372,11 +370,6 @@
<version>${apollo_client_version}</version>
</dependency>
<dependency>
- <groupId>com.netflix.archaius</groupId>
- <artifactId>archaius-core</artifactId>
- <version>${archaius_version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>${curator_version}</version>
@@ -387,11 +380,6 @@
<version>${snakeyaml_version}</version>
</dependency>
<dependency>
- <groupId>commons-configuration</groupId>
- <artifactId>commons-configuration</artifactId>
- <version>${commons_configuration_version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons_lang3_version}</version>