Skip to content

Commit

Permalink
feat:merge dubbo-remoting-zookeeper-curator5 and dubbo-remoting-zooke…
Browse files Browse the repository at this point in the history
…eper-api (#13960)
  • Loading branch information
Stellar1999 committed Apr 9, 2024
1 parent 2d2ad85 commit 114dad8
Show file tree
Hide file tree
Showing 33 changed files with 157 additions and 353 deletions.
1 change: 0 additions & 1 deletion .artifacts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion dubbo-compatible/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
<artifactId>dubbo-remoting-zookeeper-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion dubbo-config/dubbo-config-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
<artifactId>dubbo-remoting-zookeeper-api</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
<artifactId>dubbo-remoting-zookeeper-api</artifactId>
<version>${project.parent.version}</version>
</dependency>

Expand Down Expand Up @@ -92,7 +92,7 @@
<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
<artifactId>dubbo-remoting-zookeeper-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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) {

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
11 changes: 2 additions & 9 deletions dubbo-distribution/dubbo-all-shaded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,7 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
<artifactId>dubbo-remoting-zookeeper-api</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
Expand Down Expand Up @@ -502,7 +495,7 @@
<include>org.apache.dubbo:dubbo-remoting-http</include>
<include>org.apache.dubbo:dubbo-remoting-netty4</include>
<include>org.apache.dubbo:dubbo-remoting-netty</include>
<include>org.apache.dubbo:dubbo-remoting-zookeeper-curator5</include>
<include>org.apache.dubbo:dubbo-remoting-zookeeper-api</include>
<include>org.apache.dubbo:dubbo-rpc-api</include>
<include>org.apache.dubbo:dubbo-rpc-dubbo</include>
<include>org.apache.dubbo:dubbo-rpc-injvm</include>
Expand Down
8 changes: 0 additions & 8 deletions dubbo-distribution/dubbo-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,6 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

<!-- rpc -->
<dependency>
Expand Down Expand Up @@ -551,7 +544,6 @@
<include>org.apache.dubbo:dubbo-remoting-netty4</include>
<include>org.apache.dubbo:dubbo-remoting-netty</include>
<include>org.apache.dubbo:dubbo-remoting-zookeeper-api</include>
<include>org.apache.dubbo:dubbo-remoting-zookeeper-curator5</include>
<include>org.apache.dubbo:dubbo-rpc-api</include>
<include>org.apache.dubbo:dubbo-rpc-dubbo</include>
<include>org.apache.dubbo:dubbo-rpc-injvm</include>
Expand Down
5 changes: 0 additions & 5 deletions dubbo-distribution/dubbo-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,6 @@
<artifactId>dubbo-remoting-zookeeper-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
<version>${project.version}</version>
</dependency>

<!-- rpc -->
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion dubbo-metadata/dubbo-metadata-report-zookeeper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
<artifactId>dubbo-remoting-zookeeper-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,7 +67,7 @@ public class ZookeeperMetadataReport extends AbstractMetadataReport {

private ConcurrentMap<String, MappingDataListener> 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");
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@
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;

/**
* ZookeeperRegistryFactory.
*/
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion dubbo-registry/dubbo-registry-zookeeper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
<artifactId>dubbo-remoting-zookeeper-api</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-x-discovery</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -393,7 +393,7 @@ protected boolean isMatch(URL subscribeUrl, URL providerUrl) {
/**
* Triggered when children get changed. It will be invoked by implementation of CuratorWatcher.
* <p>
* '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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
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;

/**
* ZookeeperRegistryFactory.
*/
public class ZookeeperRegistryFactory extends AbstractRegistryFactory {

private ZookeeperTransporter zookeeperTransporter;
private ZookeeperClientManager zookeeperClientManager;

// for compatible usage
public ZookeeperRegistryFactory() {
Expand All @@ -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);
}
}
Loading

0 comments on commit 114dad8

Please sign in to comment.