parent
58f25ebdc2
commit
970964a012
|
|
@ -61,4 +61,20 @@
|
|||
<artifactId>zookeeper</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>curator5</id>
|
||||
<activation>
|
||||
<jdk>[17,)</jdk>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -87,6 +87,13 @@
|
|||
<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>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-rpc-api</artifactId>
|
||||
|
|
@ -411,6 +418,7 @@
|
|||
<include>org.apache.dubbo:dubbo-remoting-netty4</include>
|
||||
<include>org.apache.dubbo:dubbo-remoting-netty</include>
|
||||
<include>org.apache.dubbo:dubbo-remoting-zookeeper</include>
|
||||
<include>org.apache.dubbo:dubbo-remoting-zookeeper-curator5</include>
|
||||
<include>org.apache.dubbo:dubbo-remoting</include>
|
||||
<include>org.apache.dubbo:dubbo-rpc-api</include>
|
||||
<include>org.apache.dubbo:dubbo-rpc-dubbo</include>
|
||||
|
|
|
|||
|
|
@ -93,6 +93,11 @@
|
|||
<artifactId>dubbo-remoting-zookeeper</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-rpc-api</artifactId>
|
||||
|
|
|
|||
|
|
@ -60,4 +60,20 @@
|
|||
<artifactId>zookeeper</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>curator5</id>
|
||||
<activation>
|
||||
<jdk>[17,)</jdk>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -45,4 +45,20 @@
|
|||
<artifactId>curator-x-discovery</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>curator5</id>
|
||||
<activation>
|
||||
<jdk>[17,)</jdk>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-remoting</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>${project.artifactId}</name>
|
||||
<description>The zookeeper curator5 remoting module of dubbo project</description>
|
||||
<properties>
|
||||
<skip_maven_deploy>false</skip_maven_deploy>
|
||||
<curator5_version>5.1.0</curator5_version>
|
||||
<zookeeper_version>3.7.0</zookeeper_version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-remoting-api</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-common</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
<artifactId>curator-framework</artifactId>
|
||||
<version>${curator5_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
<artifactId>curator-recipes</artifactId>
|
||||
<version>${curator5_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.zookeeper</groupId>
|
||||
<artifactId>zookeeper</artifactId>
|
||||
<version>${zookeeper_version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.remoting.zookeeper.curator;
|
||||
package org.apache.dubbo.remoting.zookeeper.curator5;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.config.configcenter.ConfigItem;
|
||||
|
|
@ -257,8 +257,8 @@ public class Curator5ZookeeperClient extends AbstractZookeeperClient<Curator5Zoo
|
|||
}
|
||||
|
||||
@Override
|
||||
public CuratorWatcherImpl createTargetChildListener(String path, ChildListener listener) {
|
||||
return new CuratorWatcherImpl(client, listener, path);
|
||||
public Curator5ZookeeperClient.CuratorWatcherImpl createTargetChildListener(String path, ChildListener listener) {
|
||||
return new Curator5ZookeeperClient.CuratorWatcherImpl(client, listener, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -273,17 +273,17 @@ public class Curator5ZookeeperClient extends AbstractZookeeperClient<Curator5Zoo
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NodeCacheListenerImpl createTargetDataListener(String path, DataListener listener) {
|
||||
protected Curator5ZookeeperClient.NodeCacheListenerImpl createTargetDataListener(String path, DataListener listener) {
|
||||
return new NodeCacheListenerImpl(client, listener, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTargetDataListener(String path, NodeCacheListenerImpl nodeCacheListener) {
|
||||
protected void addTargetDataListener(String path, Curator5ZookeeperClient.NodeCacheListenerImpl nodeCacheListener) {
|
||||
this.addTargetDataListener(path, nodeCacheListener, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTargetDataListener(String path, NodeCacheListenerImpl nodeCacheListener, Executor executor) {
|
||||
protected void addTargetDataListener(String path, Curator5ZookeeperClient.NodeCacheListenerImpl nodeCacheListener, Executor executor) {
|
||||
try {
|
||||
NodeCache nodeCache = new NodeCache(client, path);
|
||||
if (nodeCacheMap.putIfAbsent(path, nodeCache) != null) {
|
||||
|
|
@ -302,7 +302,7 @@ public class Curator5ZookeeperClient extends AbstractZookeeperClient<Curator5Zoo
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void removeTargetDataListener(String path, NodeCacheListenerImpl nodeCacheListener) {
|
||||
protected void removeTargetDataListener(String path, Curator5ZookeeperClient.NodeCacheListenerImpl nodeCacheListener) {
|
||||
NodeCache nodeCache = nodeCacheMap.get(path);
|
||||
if (nodeCache != null) {
|
||||
nodeCache.getListenable().removeListener(nodeCacheListener);
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.remoting.zookeeper.curator;
|
||||
package org.apache.dubbo.remoting.zookeeper.curator5;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.remoting.zookeeper.AbstractZookeeperTransporter;
|
||||
|
|
@ -0,0 +1 @@
|
|||
curator5=org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperTransporter
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.remoting.zookeeper.curator;
|
||||
package org.apache.dubbo.remoting.zookeeper.curator5;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.remoting.zookeeper.ChildListener;
|
||||
|
|
@ -28,8 +28,6 @@ import org.junit.jupiter.api.Assertions;
|
|||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.condition.DisabledForJreRange;
|
||||
import org.junit.jupiter.api.condition.JRE;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
|
@ -41,7 +39,6 @@ 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)
|
||||
public class Curator5ZookeeperClientTest {
|
||||
private static Curator5ZookeeperClient curatorClient;
|
||||
private static CuratorFramework client = null;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.remoting.zookeeper.curator;
|
||||
package org.apache.dubbo.remoting.zookeeper.curator5;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.remoting.zookeeper.ZookeeperClient;
|
||||
|
|
@ -22,14 +22,11 @@ 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)
|
||||
public class Curator5ZookeeperTransporterTest {
|
||||
private ZookeeperClient zookeeperClient;
|
||||
private Curator5ZookeeperTransporter curatorZookeeperTransporter;
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
/*
|
||||
* 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.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.Curator5ZookeeperTransporter;
|
||||
|
||||
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 java.util.List;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.hamcrest.core.IsNull.nullValue;
|
||||
|
||||
/**
|
||||
* AbstractZookeeperTransporterTest
|
||||
*/
|
||||
public 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 Curator5ZookeeperTransporter().connect(URL.valueOf(zookeeperConnectionAddress1 + "/service"));
|
||||
abstractZookeeperTransporter = new Curator5ZookeeperTransporter();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZookeeperClient() {
|
||||
assertThat(zookeeperClient, not(nullValue()));
|
||||
zookeeperClient.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public 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<String> 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
|
||||
public 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<String> stringList = abstractZookeeperTransporter.getURLBackupAddress(url);
|
||||
Assertions.assertEquals(stringList.size(), 1);
|
||||
Assertions.assertEquals(stringList.get(0), "127.0.0.1:" + zookeeperServerPort1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchAndUpdateZookeeperClientCache() throws Exception {
|
||||
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<String> addressList = abstractZookeeperTransporter.getURLBackupAddress(url);
|
||||
ZookeeperClient zookeeperClient = abstractZookeeperTransporter.fetchAndUpdateZookeeperClientCache(addressList);
|
||||
Assertions.assertNotNull(zookeeperClient);
|
||||
}
|
||||
|
||||
@Test
|
||||
public 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
|
||||
public void testNotRepeatConnect() throws Exception {
|
||||
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
|
||||
public void testRepeatConnectForBackUpAdd() throws Exception {
|
||||
|
||||
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
|
||||
public void testRepeatConnectForNoMatchBackUpAdd() throws Exception {
|
||||
|
||||
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
|
||||
public void testSameHostWithDifferentUser() throws Exception {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +1 @@
|
|||
curator=org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperTransporter
|
||||
curator5=org.apache.dubbo.remoting.zookeeper.curator.Curator5ZookeeperTransporter
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
<module>dubbo-remoting-http</module>
|
||||
<module>dubbo-remoting-netty</module>
|
||||
<module>dubbo-remoting-zookeeper</module>
|
||||
<module>dubbo-remoting-zookeeper-curator5</module>
|
||||
<module>dubbo-remoting-netty4</module>
|
||||
</modules>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue