[Feature] Support the global registry center in unit tests (#9138)
This commit is contained in:
parent
57ab318ee8
commit
b06e5c2fdb
|
|
@ -21,6 +21,7 @@ package org.apache.dubbo.config;
|
|||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -60,11 +61,11 @@ public class ConfigCenterConfigTest {
|
|||
ConfigCenterConfig config = new ConfigCenterConfig();
|
||||
config.setNamespace("namespace");
|
||||
config.setGroup("group");
|
||||
config.setAddress("zookeeper://127.0.0.1:2181");
|
||||
config.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress());
|
||||
config.setHighestPriority(null);
|
||||
config.refresh();
|
||||
|
||||
Assertions.assertEquals("zookeeper://127.0.0.1:2181/ConfigCenterConfig?check=true&" +
|
||||
Assertions.assertEquals(ZookeeperRegistryCenterConfig.getConnectionAddress()+"/ConfigCenterConfig?check=true&" +
|
||||
"config-file=dubbo.properties&group=group&" +
|
||||
"namespace=namespace&timeout=3000",
|
||||
config.toUrl().toFullString()
|
||||
|
|
@ -74,7 +75,7 @@ public class ConfigCenterConfigTest {
|
|||
@Test
|
||||
public void testOverrideConfig() {
|
||||
|
||||
String zkAddr = "zookeeper://127.0.0.1:2181";
|
||||
String zkAddr = ZookeeperRegistryCenterConfig.getConnectionAddress();
|
||||
// sysprops has no id
|
||||
SysProps.setProperty("dubbo.config-center.check", "false");
|
||||
SysProps.setProperty("dubbo.config-center.address", zkAddr);
|
||||
|
|
@ -116,7 +117,7 @@ public class ConfigCenterConfigTest {
|
|||
try {
|
||||
//No id but has address
|
||||
ConfigCenterConfig configCenter = new ConfigCenterConfig();
|
||||
configCenter.setAddress("zookeeper://127.0.0.1:2181");
|
||||
configCenter.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress());
|
||||
|
||||
DubboBootstrap.getInstance()
|
||||
.application("demo-app")
|
||||
|
|
@ -277,7 +278,7 @@ public class ConfigCenterConfigTest {
|
|||
@Test
|
||||
public void testAttributes() {
|
||||
ConfigCenterConfig cc = new ConfigCenterConfig();
|
||||
cc.setAddress("zookeeper://127.0.0.1:2181");
|
||||
cc.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress());
|
||||
Map<String, String> attributes = new LinkedHashMap<>();
|
||||
ConfigCenterConfig.appendAttributes(attributes, cc);
|
||||
|
||||
|
|
@ -291,7 +292,7 @@ public class ConfigCenterConfigTest {
|
|||
|
||||
@Test
|
||||
public void testSetAddress() {
|
||||
String address = "zookeeper://127.0.0.1:2181";
|
||||
String address = ZookeeperRegistryCenterConfig.getConnectionAddress();
|
||||
ConfigCenterConfig cc = new ConfigCenterConfig();
|
||||
cc.setUsername("user123"); // set username first
|
||||
cc.setPassword("pass123");
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
|||
import org.apache.dubbo.config.context.ModuleConfigManager;
|
||||
import org.apache.dubbo.config.provider.impl.DemoServiceImpl;
|
||||
import org.apache.dubbo.registry.client.migration.MigrationInvoker;
|
||||
import org.apache.dubbo.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.rpc.Exporter;
|
||||
import org.apache.dubbo.rpc.Invoker;
|
||||
import org.apache.dubbo.rpc.ProxyFactory;
|
||||
|
|
@ -54,7 +52,6 @@ import demo.MultiClassLoaderServiceResult;
|
|||
import javassist.CannotCompileException;
|
||||
import javassist.CtClass;
|
||||
import javassist.NotFoundException;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -127,17 +124,11 @@ public class ReferenceConfigTest {
|
|||
private static String zkUrl1;
|
||||
private static String zkUrl2;
|
||||
private static String registryUrl1;
|
||||
private static RegistryCenter registryCenter1;
|
||||
private static RegistryCenter registryCenter2;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
int zkServerPort1 = NetUtils.getAvailablePort(NetUtils.getRandomPort());
|
||||
registryCenter1 = new ZookeeperSingleRegistryCenter(zkServerPort1);
|
||||
registryCenter1.startup();
|
||||
int zkServerPort2 = NetUtils.getAvailablePort(NetUtils.getRandomPort());
|
||||
registryCenter2 = new ZookeeperSingleRegistryCenter(zkServerPort2);
|
||||
registryCenter2.startup();
|
||||
int zkServerPort1 = 2181;
|
||||
int zkServerPort2 = 2182;
|
||||
zkUrl1 = "zookeeper://localhost:" + zkServerPort1;
|
||||
zkUrl2 = "zookeeper://localhost:" + zkServerPort2;
|
||||
registryUrl1 = "registry://localhost:" + zkServerPort1 + "?registry=zookeeper";
|
||||
|
|
@ -156,12 +147,6 @@ public class ReferenceConfigTest {
|
|||
Mockito.framework().clearInlineMocks();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
registryCenter1.shutdown();
|
||||
registryCenter2.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the configuration required for the aggregation service reference meets expectations
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import org.apache.dubbo.common.utils.UrlUtils;
|
|||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -202,7 +203,7 @@ public class RegistryConfigTest {
|
|||
public void testEquals() throws Exception {
|
||||
RegistryConfig registry1 = new RegistryConfig();
|
||||
RegistryConfig registry2 = new RegistryConfig();
|
||||
registry1.setAddress("zookeeper://127.0.0.1:2182");
|
||||
registry1.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress2());
|
||||
registry2.setAddress("zookeeper://127.0.0.1:2183");
|
||||
Assertions.assertNotEquals(registry1, registry2);
|
||||
}
|
||||
|
|
@ -241,7 +242,7 @@ public class RegistryConfigTest {
|
|||
// process Parameter annotation
|
||||
AbstractConfig.appendParameters(map, registry);
|
||||
// Simulate the check that ZoneAwareClusterInvoker#doInvoke do
|
||||
URL url = UrlUtils.parseURL("zookeeper://127.0.0.1:2181", map);
|
||||
URL url = UrlUtils.parseURL(ZookeeperRegistryCenterConfig.getConnectionAddress1(), map);
|
||||
Assertions.assertTrue(url.getParameter(PREFERRED_KEY, false));
|
||||
}
|
||||
|
||||
|
|
@ -253,7 +254,7 @@ public class RegistryConfigTest {
|
|||
// Process Parameter annotation
|
||||
AbstractConfig.appendParameters(map, registry);
|
||||
// Simulate the check that ZoneAwareClusterInvoker#doInvoke do
|
||||
URL url = UrlUtils.parseURL("zookeeper://127.0.0.1:2181", map);
|
||||
URL url = UrlUtils.parseURL(ZookeeperRegistryCenterConfig.getConnectionAddress1(), map);
|
||||
Assertions.assertFalse(url.getParameter(PREFERRED_KEY, false));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import org.apache.dubbo.rpc.model.ApplicationModel;
|
|||
import org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol;
|
||||
|
||||
import org.apache.curator.test.TestingServer;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
|
@ -192,7 +193,7 @@ public class DubboBootstrapTest {
|
|||
MonitorConfig monitorConfig = new MonitorConfig();
|
||||
monitorConfig.setProtocol("registry");
|
||||
|
||||
URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf("zookeeper://127.0.0.1:2181"));
|
||||
URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf(ZookeeperRegistryCenterConfig.getConnectionAddress()));
|
||||
Assertions.assertEquals("dubbo", url.getProtocol());
|
||||
Assertions.assertEquals("registry", url.getParameter("protocol"));
|
||||
}
|
||||
|
|
@ -203,14 +204,14 @@ public class DubboBootstrapTest {
|
|||
MonitorConfig monitorConfig = new MonitorConfig();
|
||||
monitorConfig.setProtocol("service-discovery-registry");
|
||||
|
||||
URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf("zookeeper://127.0.0.1:2181"));
|
||||
URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf(ZookeeperRegistryCenterConfig.getConnectionAddress()));
|
||||
Assertions.assertEquals("dubbo", url.getProtocol());
|
||||
Assertions.assertEquals("service-discovery-registry", url.getParameter("protocol"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadUserMonitor_no_monitor() {
|
||||
URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(null), URL.valueOf("zookeeper://127.0.0.1:2181"));
|
||||
URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(null), URL.valueOf(ZookeeperRegistryCenterConfig.getConnectionAddress()));
|
||||
Assertions.assertNull(url);
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +221,7 @@ public class DubboBootstrapTest {
|
|||
MonitorConfig monitorConfig = new MonitorConfig();
|
||||
monitorConfig.setProtocol("user");
|
||||
|
||||
URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf("zookeeper://127.0.0.1:2181"));
|
||||
URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf(ZookeeperRegistryCenterConfig.getConnectionAddress()));
|
||||
Assertions.assertEquals("user", url.getProtocol());
|
||||
}
|
||||
|
||||
|
|
@ -229,7 +230,7 @@ public class DubboBootstrapTest {
|
|||
// dubbo.monitor.address=user://1.2.3.4:5678?k=v
|
||||
MonitorConfig monitorConfig = new MonitorConfig();
|
||||
monitorConfig.setAddress("user://1.2.3.4:5678?param1=value1");
|
||||
URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf("zookeeper://127.0.0.1:2181"));
|
||||
URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf(ZookeeperRegistryCenterConfig.getConnectionAddress()));
|
||||
Assertions.assertEquals("user", url.getProtocol());
|
||||
Assertions.assertEquals("1.2.3.4:5678", url.getAddress());
|
||||
Assertions.assertEquals("value1", url.getParameter("param1"));
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package org.apache.dubbo.config.bootstrap;
|
|||
|
||||
import org.apache.dubbo.config.MetadataReportConfig;
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserService;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
|
||||
/**
|
||||
* Dubbo Provider Bootstrap
|
||||
|
|
@ -35,8 +36,8 @@ public class DubboServiceConsumerBootstrap {
|
|||
// .registry(builder -> builder.address("eureka://127.0.0.1:8761?registry-type=service&subscribed-services=dubbo-provider-demo"))
|
||||
|
||||
// Zookeeper
|
||||
.registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry-type=service&subscribed-services=dubbo-provider-demo"))
|
||||
.metadataReport(new MetadataReportConfig("zookeeper://127.0.0.1:2181"))
|
||||
.registry("zookeeper", builder -> builder.address(ZookeeperRegistryCenterConfig.getConnectionAddress()+"?registry-type=service&subscribed-services=dubbo-provider-demo"))
|
||||
.metadataReport(new MetadataReportConfig(ZookeeperRegistryCenterConfig.getConnectionAddress()))
|
||||
|
||||
// Nacos
|
||||
// .registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry.type=service&subscribed.services=dubbo-provider-demo"))
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import org.apache.dubbo.config.RegistryConfig;
|
|||
import org.apache.dubbo.config.ServiceConfig;
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserService;
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserServiceImpl;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
|
@ -45,11 +46,11 @@ public class DubboServiceProviderBootstrap {
|
|||
|
||||
RegistryConfig interfaceRegistry = new RegistryConfig();
|
||||
interfaceRegistry.setId("interfaceRegistry");
|
||||
interfaceRegistry.setAddress("zookeeper://127.0.0.1:2181");
|
||||
interfaceRegistry.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress());
|
||||
|
||||
RegistryConfig serviceRegistry = new RegistryConfig();
|
||||
serviceRegistry.setId("serviceRegistry");
|
||||
serviceRegistry.setAddress("zookeeper://127.0.0.1:2181?registry-type=service");
|
||||
serviceRegistry.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress()+"?registry-type=service");
|
||||
|
||||
ServiceConfig<EchoService> echoService = new ServiceConfig<>();
|
||||
echoService.setInterface(EchoService.class.getName());
|
||||
|
|
@ -73,7 +74,7 @@ public class DubboServiceProviderBootstrap {
|
|||
.registries(Arrays.asList(interfaceRegistry, serviceRegistry))
|
||||
// .registry(RegistryBuilder.newBuilder().address("consul://127.0.0.1:8500?registry.type=service").build())
|
||||
.protocol(builder -> builder.port(-1).name("dubbo"))
|
||||
.metadataReport(new MetadataReportConfig("zookeeper://127.0.0.1:2181"))
|
||||
.metadataReport(new MetadataReportConfig(ZookeeperRegistryCenterConfig.getConnectionAddress()))
|
||||
.service(echoService)
|
||||
.service(userService)
|
||||
.start()
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package org.apache.dubbo.config.bootstrap;
|
|||
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserService;
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserServiceImpl;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
|
|
@ -27,7 +28,7 @@ public class DubboServiceProviderMinimumBootstrap {
|
|||
public static void main(String[] args) {
|
||||
DubboBootstrap.getInstance()
|
||||
.application("dubbo-provider-demo")
|
||||
.registry(builder -> builder.address("zookeeper://127.0.0.1:2181?registry-type=service"))
|
||||
.registry(builder -> builder.address(ZookeeperRegistryCenterConfig.getConnectionAddress()+"?registry-type=service"))
|
||||
// .registry(builder -> builder.address("eureka://127.0.0.1:8761?registry-type=service"))
|
||||
.protocol(builder -> builder.port(-1).name("dubbo"))
|
||||
.service("echo", builder -> builder.interfaceClass(EchoService.class).ref(new EchoServiceImpl()))
|
||||
|
|
|
|||
|
|
@ -34,14 +34,13 @@ import org.apache.dubbo.config.api.DemoService;
|
|||
import org.apache.dubbo.config.api.Greeting;
|
||||
import org.apache.dubbo.config.mock.GreetingLocal2;
|
||||
import org.apache.dubbo.config.provider.impl.DemoServiceImpl;
|
||||
import org.apache.dubbo.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
import org.apache.dubbo.rpc.model.FrameworkModel;
|
||||
import org.apache.dubbo.rpc.model.FrameworkServiceRepository;
|
||||
import org.apache.dubbo.rpc.model.ModuleModel;
|
||||
import org.apache.dubbo.rpc.model.ServiceDescriptor;
|
||||
import org.apache.dubbo.test.check.DubboTestChecker;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
|
@ -63,8 +62,6 @@ public class MultiInstanceTest {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MultiInstanceTest.class);
|
||||
|
||||
private static ZookeeperSingleRegistryCenter registryCenter;
|
||||
|
||||
private static RegistryConfig registryConfig;
|
||||
|
||||
private static DubboTestChecker testChecker;
|
||||
|
|
@ -73,13 +70,7 @@ public class MultiInstanceTest {
|
|||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
FrameworkModel.destroyAll();
|
||||
registryCenter = new ZookeeperSingleRegistryCenter(NetUtils.getAvailablePort());
|
||||
registryCenter.startup();
|
||||
RegistryCenter.Instance instance = registryCenter.getRegistryCenterInstance().get(0);
|
||||
registryConfig = new RegistryConfig(String.format("%s://%s:%s",
|
||||
instance.getType(),
|
||||
instance.getHostname(),
|
||||
instance.getPort()));
|
||||
registryConfig = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress1());
|
||||
|
||||
// pre-check threads
|
||||
//precheckUnclosedThreads();
|
||||
|
|
@ -87,7 +78,6 @@ public class MultiInstanceTest {
|
|||
|
||||
@AfterAll
|
||||
public static void afterAll() throws Exception {
|
||||
registryCenter.shutdown();
|
||||
FrameworkModel.destroyAll();
|
||||
|
||||
// check threads
|
||||
|
|
@ -321,7 +311,6 @@ public class MultiInstanceTest {
|
|||
|
||||
DubboBootstrap providerBootstrap1 = null;
|
||||
DubboBootstrap providerBootstrap2 = null;
|
||||
ZookeeperSingleRegistryCenter registryCenter2 = null;
|
||||
|
||||
try {
|
||||
|
||||
|
|
@ -349,13 +338,7 @@ public class MultiInstanceTest {
|
|||
Assertions.assertTrue(stackTraces1.size() > 0, "Get threads of provider app 1 failed");
|
||||
|
||||
// start zk server 2
|
||||
registryCenter2 = new ZookeeperSingleRegistryCenter(NetUtils.getAvailablePort());
|
||||
registryCenter2.startup();
|
||||
RegistryCenter.Instance instance = registryCenter2.getRegistryCenterInstance().get(0);
|
||||
RegistryConfig registryConfig2 = new RegistryConfig(String.format("%s://%s:%s",
|
||||
instance.getType(),
|
||||
instance.getHostname(),
|
||||
instance.getPort()));
|
||||
RegistryConfig registryConfig2 = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress2());
|
||||
|
||||
// start provider app 2 use a difference zk server 2
|
||||
ServiceConfig serviceConfig2 = new ServiceConfig();
|
||||
|
|
@ -388,7 +371,6 @@ public class MultiInstanceTest {
|
|||
// stop provider app 2 and check threads
|
||||
providerBootstrap2.stop();
|
||||
// shutdown register center after dubbo application to avoid unregister services blocking
|
||||
registryCenter2.shutdown();
|
||||
checkUnclosedThreadsOfApp(stackTraces2, "Found unclosed threads of app 2: ", null);
|
||||
|
||||
} finally {
|
||||
|
|
@ -398,9 +380,6 @@ public class MultiInstanceTest {
|
|||
if (providerBootstrap2 != null) {
|
||||
providerBootstrap2.stop();
|
||||
}
|
||||
if (registryCenter2 != null) {
|
||||
registryCenter2.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.dubbo.config.bootstrap;
|
||||
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserService;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.COMPOSITE_METADATA_STORAGE_TYPE;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_TYPE_KEY;
|
||||
|
|
@ -33,7 +34,7 @@ public class ZookeeperDubboServiceConsumerBootstrap {
|
|||
|
||||
DubboBootstrap bootstrap = DubboBootstrap.getInstance()
|
||||
.application("zookeeper-dubbo-consumer", app -> app.metadata(COMPOSITE_METADATA_STORAGE_TYPE))
|
||||
.registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181")
|
||||
.registry("zookeeper", builder -> builder.address(ZookeeperRegistryCenterConfig.getConnectionAddress())
|
||||
.parameter(REGISTRY_TYPE_KEY, SERVICE_REGISTRY_TYPE)
|
||||
.useAsConfigCenter(true)
|
||||
.useAsMetadataCenter(true))
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import org.apache.dubbo.config.RegistryConfig;
|
|||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.config.bootstrap.EchoService;
|
||||
import org.apache.dubbo.config.bootstrap.rest.UserService;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
|
||||
/**
|
||||
* Dubbo Provider Bootstrap
|
||||
|
|
@ -31,7 +32,7 @@ public class DubboInterfaceConsumerBootstrap {
|
|||
public static void main(String[] args) throws Exception {
|
||||
RegistryConfig interfaceRegistry = new RegistryConfig();
|
||||
interfaceRegistry.setId("interfaceRegistry");
|
||||
interfaceRegistry.setAddress("zookeeper://127.0.0.1:2181");
|
||||
interfaceRegistry.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress());
|
||||
|
||||
DubboBootstrap bootstrap = DubboBootstrap.getInstance()
|
||||
.application("dubbo-consumer-demo")
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration;
|
||||
package org.apache.dubbo.config.integration;
|
||||
|
||||
import org.apache.dubbo.rpc.Exporter;
|
||||
import org.apache.dubbo.rpc.ExporterListener;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration;
|
||||
package org.apache.dubbo.config.integration;
|
||||
|
||||
import org.apache.dubbo.config.ServiceConfig;
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration;
|
||||
package org.apache.dubbo.config.integration;
|
||||
|
||||
public interface Constants {
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration;
|
||||
package org.apache.dubbo.config.integration;
|
||||
|
||||
/**
|
||||
* The interface for integration testcases.
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple;
|
||||
package org.apache.dubbo.config.integration.multiple;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple;
|
||||
package org.apache.dubbo.config.integration.multiple;
|
||||
|
||||
/**
|
||||
* This interface to store the given type instance in multiple registry center.
|
||||
|
|
@ -14,11 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.exportmetadata;
|
||||
package org.apache.dubbo.config.integration.multiple.exportmetadata;
|
||||
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterExporterListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterExporterListener;
|
||||
import org.apache.dubbo.metadata.MetadataService;
|
||||
|
||||
@Activate(group = CommonConstants.PROVIDER, order = 1000)
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.exportmetadata;
|
||||
package org.apache.dubbo.config.integration.multiple.exportmetadata;
|
||||
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.config.RegistryConfig;
|
||||
|
|
@ -23,13 +23,12 @@ import org.apache.dubbo.config.ApplicationConfig;
|
|||
import org.apache.dubbo.config.ProtocolConfig;
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.integration.IntegrationTest;
|
||||
import org.apache.dubbo.config.integration.IntegrationTest;
|
||||
import org.apache.dubbo.metadata.MetadataService;
|
||||
import org.apache.dubbo.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.registrycenter.ZookeeperMultipleRegistryCenter;
|
||||
import org.apache.dubbo.rpc.Exporter;
|
||||
import org.apache.dubbo.rpc.ExporterListener;
|
||||
import org.apache.dubbo.rpc.Filter;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -77,17 +76,11 @@ public class MultipleRegistryCenterExportMetadataIntegrationTest implements Inte
|
|||
*/
|
||||
private MultipleRegistryCenterExportMetadataExporterListener exporterListener;
|
||||
|
||||
/**
|
||||
* Define a registry center.
|
||||
*/
|
||||
private RegistryCenter registryCenter;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
logger.info(getClass().getSimpleName() + " testcase is beginning...");
|
||||
DubboBootstrap.reset();
|
||||
registryCenter = new ZookeeperMultipleRegistryCenter();
|
||||
registryCenter.startup();
|
||||
// initialize service config
|
||||
serviceConfig = new ServiceConfig<>();
|
||||
serviceConfig.setInterface(MultipleRegistryCenterExportMetadataService.class);
|
||||
|
|
@ -99,13 +92,9 @@ public class MultipleRegistryCenterExportMetadataIntegrationTest implements Inte
|
|||
DubboBootstrap.getInstance()
|
||||
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
|
||||
.protocol(new ProtocolConfig(PROTOCOL_NAME))
|
||||
.service(serviceConfig);
|
||||
for (RegistryCenter.Instance instance : registryCenter.getRegistryCenterInstance()) {
|
||||
DubboBootstrap.getInstance().registry(new RegistryConfig(String.format("%s://%s:%s",
|
||||
instance.getType(),
|
||||
instance.getHostname(),
|
||||
instance.getPort())));
|
||||
}
|
||||
.service(serviceConfig)
|
||||
.registry(new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress1()))
|
||||
.registry(new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress2()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -201,7 +190,5 @@ public class MultipleRegistryCenterExportMetadataIntegrationTest implements Inte
|
|||
Assertions.assertTrue(serviceListener.getExportedServices().isEmpty());
|
||||
serviceListener = null;
|
||||
logger.info(getClass().getSimpleName() + " testcase is ending...");
|
||||
registryCenter.shutdown();
|
||||
registryCenter = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.exportmetadata;
|
||||
package org.apache.dubbo.config.integration.multiple.exportmetadata;
|
||||
|
||||
/**
|
||||
* This interface is used to check if the exported metadata service works well or not in multiple registry center.
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.exportmetadata;
|
||||
package org.apache.dubbo.config.integration.multiple.exportmetadata;
|
||||
|
||||
/**
|
||||
* The simple implementation for {@link MultipleRegistryCenterExportMetadataService}
|
||||
|
|
@ -14,10 +14,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.exportmetadata;
|
||||
package org.apache.dubbo.config.integration.multiple.exportmetadata;
|
||||
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
|
||||
import org.apache.dubbo.metadata.MetadataService;
|
||||
|
||||
/**
|
||||
|
|
@ -14,11 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.exportprovider;
|
||||
package org.apache.dubbo.config.integration.multiple.exportprovider;
|
||||
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterExporterListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterExporterListener;
|
||||
|
||||
@Activate(group = CommonConstants.PROVIDER, order = 1000)
|
||||
public class MultipleRegistryCenterExportProviderExporterListener extends AbstractRegistryCenterExporterListener {
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.exportprovider;
|
||||
package org.apache.dubbo.config.integration.multiple.exportprovider;
|
||||
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.exportprovider;
|
||||
package org.apache.dubbo.config.integration.multiple.exportprovider;
|
||||
|
||||
import org.apache.dubbo.common.config.configcenter.ConfigItem;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
|
|
@ -26,15 +26,14 @@ import org.apache.dubbo.config.RegistryConfig;
|
|||
import org.apache.dubbo.config.ServiceConfig;
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.integration.IntegrationTest;
|
||||
import org.apache.dubbo.config.integration.IntegrationTest;
|
||||
import org.apache.dubbo.metadata.ServiceNameMapping;
|
||||
import org.apache.dubbo.metadata.report.MetadataReportInstance;
|
||||
import org.apache.dubbo.registry.integration.RegistryProtocolListener;
|
||||
import org.apache.dubbo.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.registrycenter.ZookeeperMultipleRegistryCenter;
|
||||
import org.apache.dubbo.rpc.ExporterListener;
|
||||
import org.apache.dubbo.rpc.Filter;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -75,11 +74,6 @@ public class MultipleRegistryCenterExportProviderIntegrationTest implements Inte
|
|||
*/
|
||||
private ServiceConfig<MultipleRegistryCenterExportProviderService> serviceConfig;
|
||||
|
||||
/**
|
||||
* Define a registry center.
|
||||
*/
|
||||
private RegistryCenter registryCenter;
|
||||
|
||||
/**
|
||||
* Define a {@link RegistryProtocolListener} instance.
|
||||
*/
|
||||
|
|
@ -104,8 +98,6 @@ public class MultipleRegistryCenterExportProviderIntegrationTest implements Inte
|
|||
public void setUp() throws Exception {
|
||||
logger.info(getClass().getSimpleName() + " testcase is beginning...");
|
||||
DubboBootstrap.reset();
|
||||
registryCenter = new ZookeeperMultipleRegistryCenter();
|
||||
registryCenter.startup();
|
||||
// initialize service config
|
||||
serviceConfig = new ServiceConfig<>();
|
||||
serviceConfig.setInterface(MultipleRegistryCenterExportProviderService.class);
|
||||
|
|
@ -116,14 +108,9 @@ public class MultipleRegistryCenterExportProviderIntegrationTest implements Inte
|
|||
DubboBootstrap.getInstance()
|
||||
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
|
||||
.protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
|
||||
.service(serviceConfig);
|
||||
for (RegistryCenter.Instance instance : registryCenter.getRegistryCenterInstance()) {
|
||||
RegistryConfig registryConfig = new RegistryConfig(String.format("%s://%s:%s",
|
||||
instance.getType(),
|
||||
instance.getHostname(),
|
||||
instance.getPort()));
|
||||
DubboBootstrap.getInstance().registry(registryConfig);
|
||||
}
|
||||
.service(serviceConfig)
|
||||
.registry(new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress1()))
|
||||
.registry(new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress2()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -254,8 +241,6 @@ public class MultipleRegistryCenterExportProviderIntegrationTest implements Inte
|
|||
// The exported service has been unexported
|
||||
Assertions.assertTrue(serviceListener.getExportedServices().isEmpty());
|
||||
logger.info(getClass().getSimpleName() + " testcase is ending...");
|
||||
registryCenter.shutdown();
|
||||
registryProtocolListener = null;
|
||||
registryCenter = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.exportprovider;
|
||||
package org.apache.dubbo.config.integration.multiple.exportprovider;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.exportprovider;
|
||||
package org.apache.dubbo.config.integration.multiple.exportprovider;
|
||||
|
||||
/**
|
||||
* This interface is used to check if the exported provider works well or not in multiple registry center.
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.exportprovider;
|
||||
package org.apache.dubbo.config.integration.multiple.exportprovider;
|
||||
|
||||
/**
|
||||
* The implementation of {@link MultipleRegistryCenterExportProviderService}
|
||||
|
|
@ -14,10 +14,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.exportprovider;
|
||||
package org.apache.dubbo.config.integration.multiple.exportprovider;
|
||||
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
|
||||
|
||||
/**
|
||||
* This implementation of {@link ServiceListener} is to record exported services with injvm protocol in single registry center.
|
||||
|
|
@ -14,11 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.injvm;
|
||||
package org.apache.dubbo.config.integration.multiple.injvm;
|
||||
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterExporterListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterExporterListener;
|
||||
|
||||
@Activate(group = CommonConstants.PROVIDER, order = 1000)
|
||||
public class MultipleRegistryCenterInjvmExporterListener extends AbstractRegistryCenterExporterListener {
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.injvm;
|
||||
package org.apache.dubbo.config.integration.multiple.injvm;
|
||||
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.injvm;
|
||||
package org.apache.dubbo.config.integration.multiple.injvm;
|
||||
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.config.ApplicationConfig;
|
||||
|
|
@ -24,11 +24,10 @@ import org.apache.dubbo.config.RegistryConfig;
|
|||
import org.apache.dubbo.config.ServiceConfig;
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.integration.IntegrationTest;
|
||||
import org.apache.dubbo.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.registrycenter.ZookeeperMultipleRegistryCenter;
|
||||
import org.apache.dubbo.config.integration.IntegrationTest;
|
||||
import org.apache.dubbo.rpc.ExporterListener;
|
||||
import org.apache.dubbo.rpc.Filter;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -77,18 +76,10 @@ public class MultipleRegistryCenterInjvmIntegrationTest implements IntegrationTe
|
|||
*/
|
||||
private MultipleRegistryCenterInjvmFilter filter;
|
||||
|
||||
/**
|
||||
* Default a registry center.
|
||||
*/
|
||||
private RegistryCenter registryCenter;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
logger.info(getClass().getSimpleName() + " testcase is beginning...");
|
||||
DubboBootstrap.reset();
|
||||
//start all zookeeper services only once
|
||||
registryCenter = new ZookeeperMultipleRegistryCenter();
|
||||
registryCenter.startup();
|
||||
// initialize service config
|
||||
serviceConfig = new ServiceConfig<>();
|
||||
serviceConfig.setInterface(MultipleRegistryCenterInjvmService.class);
|
||||
|
|
@ -96,17 +87,12 @@ public class MultipleRegistryCenterInjvmIntegrationTest implements IntegrationTe
|
|||
serviceConfig.setAsync(false);
|
||||
serviceConfig.setScope(SCOPE_LOCAL);
|
||||
|
||||
// initailize bootstrap
|
||||
for (RegistryCenter.Instance instance : registryCenter.getRegistryCenterInstance()) {
|
||||
DubboBootstrap.getInstance().registry(new RegistryConfig(String.format("%s://%s:%s",
|
||||
instance.getType(),
|
||||
instance.getHostname(),
|
||||
instance.getPort())));
|
||||
}
|
||||
DubboBootstrap.getInstance()
|
||||
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
|
||||
.protocol(new ProtocolConfig("injvm"))
|
||||
.service(serviceConfig);
|
||||
.service(serviceConfig)
|
||||
.registry(new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress1()))
|
||||
.registry(new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress2()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -201,8 +187,5 @@ public class MultipleRegistryCenterInjvmIntegrationTest implements IntegrationTe
|
|||
Assertions.assertTrue(serviceListener.getExportedServices().isEmpty());
|
||||
serviceListener = null;
|
||||
logger.info(getClass().getSimpleName() + " testcase is ending...");
|
||||
// destroy registry center
|
||||
registryCenter.shutdown();
|
||||
registryCenter = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.injvm;
|
||||
package org.apache.dubbo.config.integration.multiple.injvm;
|
||||
/**
|
||||
* This interface is used to check if the exported injvm protocol works well or not.
|
||||
*/
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.injvm;
|
||||
package org.apache.dubbo.config.integration.multiple.injvm;
|
||||
|
||||
/**
|
||||
* The simple implementation for {@link MultipleRegistryCenterInjvmService}
|
||||
|
|
@ -14,10 +14,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.injvm;
|
||||
package org.apache.dubbo.config.integration.multiple.injvm;
|
||||
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
|
||||
|
||||
/**
|
||||
* This implementation of {@link ServiceListener} is to record exported services with injvm protocol in multiple registry center.
|
||||
|
|
@ -19,4 +19,4 @@
|
|||
* The one is single registry center, the other is multiple registry centers.<p>
|
||||
* The purpose of all of testcases in this package is to test for multiple registry center.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple;
|
||||
package org.apache.dubbo.config.integration.multiple;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
|
||||
package org.apache.dubbo.config.integration.multiple.servicediscoveryregistry;
|
||||
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
|
|
@ -24,12 +24,11 @@ import org.apache.dubbo.config.ReferenceConfig;
|
|||
import org.apache.dubbo.config.RegistryConfig;
|
||||
import org.apache.dubbo.config.ServiceConfig;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.integration.IntegrationTest;
|
||||
import org.apache.dubbo.config.integration.IntegrationTest;
|
||||
import org.apache.dubbo.registry.RegistryServiceListener;
|
||||
import org.apache.dubbo.registry.client.metadata.store.InMemoryWritableMetadataService;
|
||||
import org.apache.dubbo.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.registrycenter.ZookeeperMultipleRegistryCenter;
|
||||
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperConfig;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -43,7 +42,7 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.apache.dubbo.integration.Constants.MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY;
|
||||
import static org.apache.dubbo.config.integration.Constants.MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY;
|
||||
|
||||
/**
|
||||
* The testcases are only for checking the process of exporting provider using service-discovery-registry protocol.
|
||||
|
|
@ -71,11 +70,6 @@ public class MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest imple
|
|||
*/
|
||||
private ServiceConfig<MultipleRegistryCenterServiceDiscoveryRegistryService> serviceConfig;
|
||||
|
||||
/**
|
||||
* Default a registry center.
|
||||
*/
|
||||
private RegistryCenter registryCenter;
|
||||
|
||||
/**
|
||||
* Define a {@link RegistryServiceListener} instance.
|
||||
*/
|
||||
|
|
@ -95,27 +89,26 @@ public class MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest imple
|
|||
public void setUp() throws Exception {
|
||||
logger.info(getClass().getSimpleName() + " testcase is beginning...");
|
||||
DubboBootstrap.reset();
|
||||
//start all zookeeper services only once
|
||||
registryCenter = new ZookeeperMultipleRegistryCenter();
|
||||
registryCenter.startup();
|
||||
// initialize service config
|
||||
serviceConfig = new ServiceConfig<>();
|
||||
serviceConfig.setInterface(MultipleRegistryCenterServiceDiscoveryRegistryService.class);
|
||||
serviceConfig.setRef(new MultipleRegistryCenterServiceDiscoveryRegistryServiceImpl());
|
||||
serviceConfig.setAsync(false);
|
||||
|
||||
// initialize bootstrap
|
||||
for (RegistryCenter.Instance instance : registryCenter.getRegistryCenterInstance()) {
|
||||
RegistryConfig registryConfig = new RegistryConfig(String.format("%s://%s:%s",
|
||||
instance.getType(),
|
||||
instance.getHostname(),
|
||||
instance.getPort()));
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put("registry.listeners", MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY);
|
||||
registryConfig.updateParameters(parameters);
|
||||
DubboBootstrap.getInstance().registry(registryConfig);
|
||||
ports.add(instance.getPort());
|
||||
}
|
||||
RegistryConfig registryConfig1 = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress1());
|
||||
Map<String, String> parameters1 = new HashMap<>();
|
||||
parameters1.put("registry.listeners", MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY);
|
||||
registryConfig1.updateParameters(parameters1);
|
||||
DubboBootstrap.getInstance().registry(registryConfig1);
|
||||
ports.add(ZookeeperConfig.DEFAULT_CLIENT_PORT_1);
|
||||
|
||||
RegistryConfig registryConfig2 = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress2());
|
||||
Map<String, String> parameters2 = new HashMap<>();
|
||||
parameters2.put("registry.listeners", MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY);
|
||||
registryConfig2.updateParameters(parameters2);
|
||||
DubboBootstrap.getInstance().registry(registryConfig2);
|
||||
ports.add(ZookeeperConfig.DEFAULT_CLIENT_PORT_2);
|
||||
|
||||
DubboBootstrap.getInstance()
|
||||
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
|
||||
.protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
|
||||
|
|
@ -218,8 +211,5 @@ public class MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest imple
|
|||
registryServiceListener.getStorage().clear();
|
||||
registryServiceListener = null;
|
||||
logger.info(getClass().getSimpleName() + " testcase is ending...");
|
||||
// destroy registry center
|
||||
registryCenter.shutdown();
|
||||
registryCenter = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
|
||||
package org.apache.dubbo.config.integration.multiple.servicediscoveryregistry;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
|
|
@ -24,7 +24,7 @@ import org.apache.dubbo.registry.RegistryServiceListener;
|
|||
import org.apache.dubbo.registry.client.ServiceDiscoveryRegistry;
|
||||
import org.apache.dubbo.registry.client.metadata.store.InMemoryWritableMetadataService;
|
||||
|
||||
import static org.apache.dubbo.integration.Constants.MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY;
|
||||
import static org.apache.dubbo.config.integration.Constants.MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY;
|
||||
|
||||
|
||||
@Activate(value = MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY)
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
|
||||
package org.apache.dubbo.config.integration.multiple.servicediscoveryregistry;
|
||||
/**
|
||||
* This interface is used to check if the exported service-discovery-registry protocol works well or not.
|
||||
*/
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
|
||||
package org.apache.dubbo.config.integration.multiple.servicediscoveryregistry;
|
||||
/**
|
||||
* The simple implementation for {@link MultipleRegistryCenterServiceDiscoveryRegistryService}
|
||||
*/
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
|
||||
package org.apache.dubbo.config.integration.multiple.servicediscoveryregistry;
|
||||
|
||||
import org.apache.dubbo.registry.client.ServiceDiscoveryRegistry;
|
||||
import org.apache.dubbo.registry.client.metadata.store.InMemoryWritableMetadataService;
|
||||
|
|
@ -14,9 +14,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
|
||||
package org.apache.dubbo.config.integration.multiple.servicediscoveryregistry;
|
||||
|
||||
import org.apache.dubbo.integration.multiple.AbstractStorage;
|
||||
import org.apache.dubbo.config.integration.multiple.AbstractStorage;
|
||||
|
||||
/**
|
||||
* The storage to store {@link ServiceDiscoveryRegistryInfoWrapper} instances in multiple registry center.
|
||||
|
|
@ -14,12 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single;
|
||||
package org.apache.dubbo.config.integration.single;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.config.ApplicationConfig;
|
||||
import org.apache.dubbo.config.ProtocolConfig;
|
||||
import org.apache.dubbo.config.ReferenceConfig;
|
||||
|
|
@ -27,7 +26,7 @@ import org.apache.dubbo.config.RegistryConfig;
|
|||
import org.apache.dubbo.config.ServiceConfig;
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.integration.IntegrationTest;
|
||||
import org.apache.dubbo.config.integration.IntegrationTest;
|
||||
import org.apache.dubbo.metadata.MetadataInfo;
|
||||
import org.apache.dubbo.metadata.WritableMetadataService;
|
||||
import org.apache.dubbo.registry.ListenerRegistryWrapper;
|
||||
|
|
@ -38,10 +37,9 @@ import org.apache.dubbo.registry.client.metadata.store.InMemoryWritableMetadataS
|
|||
import org.apache.dubbo.registry.client.migration.MigrationInvoker;
|
||||
import org.apache.dubbo.registry.support.RegistryManager;
|
||||
import org.apache.dubbo.registry.zookeeper.ZookeeperServiceDiscovery;
|
||||
import org.apache.dubbo.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.rpc.cluster.Directory;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -101,17 +99,10 @@ public class SingleRegistryCenterDubboProtocolIntegrationTest implements Integra
|
|||
*/
|
||||
private SingleRegistryCenterExportedServiceListener singleRegistryCenterExportedServiceListener;
|
||||
|
||||
/**
|
||||
* Define a registry center.
|
||||
*/
|
||||
private RegistryCenter registryCenter;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
logger.info(getClass().getSimpleName() + " testcase is beginning...");
|
||||
DubboBootstrap.reset();
|
||||
registryCenter = new ZookeeperSingleRegistryCenter(NetUtils.getAvailablePort());
|
||||
registryCenter.startup();
|
||||
// initialize ServiceConfig
|
||||
serviceConfig = new ServiceConfig<>();
|
||||
serviceConfig.setInterface(SingleRegistryCenterIntegrationService.class);
|
||||
|
|
@ -122,11 +113,7 @@ public class SingleRegistryCenterDubboProtocolIntegrationTest implements Integra
|
|||
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
|
||||
.protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
|
||||
.service(serviceConfig);
|
||||
RegistryCenter.Instance instance = registryCenter.getRegistryCenterInstance().get(0);
|
||||
registryConfig = new RegistryConfig(String.format("%s://%s:%s",
|
||||
instance.getType(),
|
||||
instance.getHostname(),
|
||||
instance.getPort()));
|
||||
registryConfig = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress());
|
||||
DubboBootstrap.getInstance().registry(registryConfig);
|
||||
}
|
||||
|
||||
|
|
@ -386,8 +373,5 @@ public class SingleRegistryCenterDubboProtocolIntegrationTest implements Integra
|
|||
Assertions.assertTrue(singleRegistryCenterExportedServiceListener.getExportedServices().isEmpty());
|
||||
singleRegistryCenterExportedServiceListener = null;
|
||||
logger.info(getClass().getSimpleName() + " testcase is ending...");
|
||||
// destroy registry center
|
||||
registryCenter.shutdown();
|
||||
registryCenter = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,10 +14,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single;
|
||||
package org.apache.dubbo.config.integration.single;
|
||||
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
|
||||
|
||||
/**
|
||||
* This implementation of {@link ServiceListener} is to record exported services in single registry center.
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single;
|
||||
package org.apache.dubbo.config.integration.single;
|
||||
|
||||
/**
|
||||
* This interface for integration testcases in single registry center.
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single;
|
||||
package org.apache.dubbo.config.integration.single;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -14,11 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.exportmetadata;
|
||||
package org.apache.dubbo.config.integration.single.exportmetadata;
|
||||
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterExporterListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterExporterListener;
|
||||
import org.apache.dubbo.metadata.MetadataService;
|
||||
|
||||
@Activate(group = CommonConstants.PROVIDER, order = 1000)
|
||||
|
|
@ -14,23 +14,21 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.exportmetadata;
|
||||
package org.apache.dubbo.config.integration.single.exportmetadata;
|
||||
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.config.RegistryConfig;
|
||||
import org.apache.dubbo.config.ServiceConfig;
|
||||
import org.apache.dubbo.config.ApplicationConfig;
|
||||
import org.apache.dubbo.config.ProtocolConfig;
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.integration.IntegrationTest;
|
||||
import org.apache.dubbo.config.integration.IntegrationTest;
|
||||
import org.apache.dubbo.metadata.MetadataService;
|
||||
import org.apache.dubbo.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.rpc.Exporter;
|
||||
import org.apache.dubbo.rpc.ExporterListener;
|
||||
import org.apache.dubbo.rpc.Filter;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -78,17 +76,10 @@ public class SingleRegistryCenterExportMetadataIntegrationTest implements Integr
|
|||
*/
|
||||
private SingleRegistryCenterExportMetadataExporterListener exporterListener;
|
||||
|
||||
/**
|
||||
* Define a registry center.
|
||||
*/
|
||||
private RegistryCenter registryCenter;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
logger.info(getClass().getSimpleName() + " testcase is beginning...");
|
||||
DubboBootstrap.reset();
|
||||
registryCenter = new ZookeeperSingleRegistryCenter(NetUtils.getAvailablePort());
|
||||
registryCenter.startup();
|
||||
// initialize service config
|
||||
serviceConfig = new ServiceConfig<>();
|
||||
serviceConfig.setInterface(SingleRegistryCenterExportMetadataService.class);
|
||||
|
|
@ -101,11 +92,7 @@ public class SingleRegistryCenterExportMetadataIntegrationTest implements Integr
|
|||
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
|
||||
.protocol(new ProtocolConfig(PROTOCOL_NAME))
|
||||
.service(serviceConfig);
|
||||
RegistryCenter.Instance instance = registryCenter.getRegistryCenterInstance().get(0);
|
||||
RegistryConfig registryConfig = new RegistryConfig(String.format("%s://%s:%s",
|
||||
instance.getType(),
|
||||
instance.getHostname(),
|
||||
instance.getPort()));
|
||||
RegistryConfig registryConfig = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress());
|
||||
DubboBootstrap.getInstance().registry(registryConfig);
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +186,5 @@ public class SingleRegistryCenterExportMetadataIntegrationTest implements Integr
|
|||
Assertions.assertTrue(serviceListener.getExportedServices().isEmpty());
|
||||
serviceListener = null;
|
||||
logger.info(getClass().getSimpleName() + " testcase is ending...");
|
||||
registryCenter.shutdown();
|
||||
registryCenter = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.exportmetadata;
|
||||
package org.apache.dubbo.config.integration.single.exportmetadata;
|
||||
|
||||
/**
|
||||
* This interface is used to check if the exported metadata service works well or not.
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.exportmetadata;
|
||||
package org.apache.dubbo.config.integration.single.exportmetadata;
|
||||
|
||||
/**
|
||||
* The simple implementation for {@link SingleRegistryCenterExportMetadataService}
|
||||
|
|
@ -14,10 +14,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.exportmetadata;
|
||||
package org.apache.dubbo.config.integration.single.exportmetadata;
|
||||
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
|
||||
import org.apache.dubbo.metadata.MetadataService;
|
||||
|
||||
/**
|
||||
|
|
@ -14,11 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.exportprovider;
|
||||
package org.apache.dubbo.config.integration.single.exportprovider;
|
||||
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterExporterListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterExporterListener;
|
||||
|
||||
@Activate(group = CommonConstants.PROVIDER, order = 1000)
|
||||
public class SingleRegistryCenterExportProviderExporterListener extends AbstractRegistryCenterExporterListener {
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.exportprovider;
|
||||
package org.apache.dubbo.config.integration.single.exportprovider;
|
||||
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.exportprovider;
|
||||
package org.apache.dubbo.config.integration.single.exportprovider;
|
||||
|
||||
import org.apache.dubbo.common.config.configcenter.ConfigItem;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
|
|
@ -26,15 +26,14 @@ import org.apache.dubbo.config.RegistryConfig;
|
|||
import org.apache.dubbo.config.ServiceConfig;
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.integration.IntegrationTest;
|
||||
import org.apache.dubbo.config.integration.IntegrationTest;
|
||||
import org.apache.dubbo.metadata.ServiceNameMapping;
|
||||
import org.apache.dubbo.metadata.report.MetadataReportInstance;
|
||||
import org.apache.dubbo.registry.integration.RegistryProtocolListener;
|
||||
import org.apache.dubbo.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.registrycenter.ZookeeperMultipleRegistryCenter;
|
||||
import org.apache.dubbo.rpc.ExporterListener;
|
||||
import org.apache.dubbo.rpc.Filter;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -47,7 +46,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_PROTOCOL_LISTENER_KEY;
|
||||
import static org.apache.dubbo.integration.Constants.SINGLE_CONFIG_CENTER_EXPORT_PROVIDER;
|
||||
import static org.apache.dubbo.config.integration.Constants.SINGLE_CONFIG_CENTER_EXPORT_PROVIDER;
|
||||
import static org.apache.dubbo.rpc.Constants.SCOPE_LOCAL;
|
||||
|
||||
/**
|
||||
|
|
@ -76,11 +75,6 @@ public class SingleRegistryCenterExportProviderIntegrationTest implements Integr
|
|||
*/
|
||||
private ServiceConfig<SingleRegistryCenterExportProviderService> serviceConfig;
|
||||
|
||||
/**
|
||||
* Define a registry center.
|
||||
*/
|
||||
private RegistryCenter registryCenter;
|
||||
|
||||
/**
|
||||
* Define a {@link RegistryProtocolListener} instance.
|
||||
*/
|
||||
|
|
@ -105,8 +99,6 @@ public class SingleRegistryCenterExportProviderIntegrationTest implements Integr
|
|||
public void setUp() throws Exception {
|
||||
logger.info(getClass().getSimpleName() + " testcase is beginning...");
|
||||
DubboBootstrap.reset();
|
||||
registryCenter = new ZookeeperMultipleRegistryCenter();
|
||||
registryCenter.startup();
|
||||
// initialize service config
|
||||
serviceConfig = new ServiceConfig<>();
|
||||
serviceConfig.setInterface(SingleRegistryCenterExportProviderService.class);
|
||||
|
|
@ -118,12 +110,8 @@ public class SingleRegistryCenterExportProviderIntegrationTest implements Integr
|
|||
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
|
||||
.protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
|
||||
.service(serviceConfig);
|
||||
RegistryCenter.Instance instance = registryCenter.getRegistryCenterInstance().get(0);
|
||||
|
||||
RegistryConfig registryConfig = new RegistryConfig(String.format("%s://%s:%s",
|
||||
instance.getType(),
|
||||
instance.getHostname(),
|
||||
instance.getPort()));
|
||||
RegistryConfig registryConfig = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress());
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put(REGISTRY_PROTOCOL_LISTENER_KEY, "singleConfigCenterExportProvider");
|
||||
registryConfig.updateParameters(parameters);
|
||||
|
|
@ -253,8 +241,6 @@ public class SingleRegistryCenterExportProviderIntegrationTest implements Integr
|
|||
// The exported service has been unexported
|
||||
Assertions.assertTrue(serviceListener.getExportedServices().isEmpty());
|
||||
logger.info(getClass().getSimpleName() + " testcase is ending...");
|
||||
registryCenter.shutdown();
|
||||
registryProtocolListener = null;
|
||||
registryCenter = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.exportprovider;
|
||||
package org.apache.dubbo.config.integration.single.exportprovider;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
|
|
@ -24,7 +24,7 @@ import org.apache.dubbo.registry.integration.RegistryProtocolListener;
|
|||
import org.apache.dubbo.rpc.Exporter;
|
||||
import org.apache.dubbo.rpc.cluster.ClusterInvoker;
|
||||
|
||||
import static org.apache.dubbo.integration.Constants.SINGLE_CONFIG_CENTER_EXPORT_PROVIDER;
|
||||
import static org.apache.dubbo.config.integration.Constants.SINGLE_CONFIG_CENTER_EXPORT_PROVIDER;
|
||||
|
||||
/**
|
||||
* The {@link RegistryProtocolListener} for {@link SingleRegistryCenterExportProviderService}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.exportprovider;
|
||||
package org.apache.dubbo.config.integration.single.exportprovider;
|
||||
|
||||
/**
|
||||
* This interface is used to check if the exported provider works well or not.
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.exportprovider;
|
||||
package org.apache.dubbo.config.integration.single.exportprovider;
|
||||
|
||||
/**
|
||||
* The implementation of {@link SingleRegistryCenterExportProviderService}
|
||||
|
|
@ -14,10 +14,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.exportprovider;
|
||||
package org.apache.dubbo.config.integration.single.exportprovider;
|
||||
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
|
||||
|
||||
/**
|
||||
* This implementation of {@link ServiceListener} is to record exported services with injvm protocol in single registry center.
|
||||
|
|
@ -14,11 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.injvm;
|
||||
package org.apache.dubbo.config.integration.single.injvm;
|
||||
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterExporterListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterExporterListener;
|
||||
|
||||
@Activate(group = CommonConstants.PROVIDER, order = 1000)
|
||||
public class SingleRegistryCenterInjvmExporterListener extends AbstractRegistryCenterExporterListener {
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.injvm;
|
||||
package org.apache.dubbo.config.integration.single.injvm;
|
||||
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
|
|
@ -14,10 +14,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.injvm;
|
||||
package org.apache.dubbo.config.integration.single.injvm;
|
||||
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.config.ApplicationConfig;
|
||||
import org.apache.dubbo.config.ProtocolConfig;
|
||||
import org.apache.dubbo.config.ReferenceConfig;
|
||||
|
|
@ -25,11 +24,10 @@ import org.apache.dubbo.config.RegistryConfig;
|
|||
import org.apache.dubbo.config.ServiceConfig;
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.integration.IntegrationTest;
|
||||
import org.apache.dubbo.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.config.integration.IntegrationTest;
|
||||
import org.apache.dubbo.rpc.ExporterListener;
|
||||
import org.apache.dubbo.rpc.Filter;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -77,17 +75,10 @@ public class SingleRegistryCenterInjvmIntegrationTest implements IntegrationTest
|
|||
*/
|
||||
private SingleRegistryCenterInjvmFilter filter;
|
||||
|
||||
/**
|
||||
* Define a registry center.
|
||||
*/
|
||||
private RegistryCenter registryCenter;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
logger.info(getClass().getSimpleName() + " testcase is beginning...");
|
||||
DubboBootstrap.reset();
|
||||
registryCenter = new ZookeeperSingleRegistryCenter(NetUtils.getAvailablePort());
|
||||
registryCenter.startup();
|
||||
// initialize service config
|
||||
serviceConfig = new ServiceConfig<>();
|
||||
serviceConfig.setInterface(SingleRegistryCenterInjvmService.class);
|
||||
|
|
@ -100,11 +91,7 @@ public class SingleRegistryCenterInjvmIntegrationTest implements IntegrationTest
|
|||
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
|
||||
.protocol(new ProtocolConfig("injvm"))
|
||||
.service(serviceConfig);
|
||||
RegistryCenter.Instance instance = registryCenter.getRegistryCenterInstance().get(0);
|
||||
RegistryConfig registryConfig = new RegistryConfig(String.format("%s://%s:%s",
|
||||
instance.getType(),
|
||||
instance.getHostname(),
|
||||
instance.getPort()));
|
||||
RegistryConfig registryConfig = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress());
|
||||
DubboBootstrap.getInstance().registry(registryConfig);
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +186,5 @@ public class SingleRegistryCenterInjvmIntegrationTest implements IntegrationTest
|
|||
Assertions.assertTrue(serviceListener.getExportedServices().isEmpty());
|
||||
serviceListener = null;
|
||||
logger.info(getClass().getSimpleName() + " testcase is ending...");
|
||||
registryCenter.shutdown();
|
||||
registryCenter = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.injvm;
|
||||
package org.apache.dubbo.config.integration.single.injvm;
|
||||
|
||||
/**
|
||||
* This interface is used to check if the exported injvm protocol works well or not.
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.injvm;
|
||||
package org.apache.dubbo.config.integration.single.injvm;
|
||||
|
||||
/**
|
||||
* The simple implementation for {@link SingleRegistryCenterInjvmService}
|
||||
|
|
@ -14,10 +14,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single.injvm;
|
||||
package org.apache.dubbo.config.integration.single.injvm;
|
||||
|
||||
import org.apache.dubbo.config.ServiceListener;
|
||||
import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
|
||||
import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
|
||||
|
||||
/**
|
||||
* This implementation of {@link ServiceListener} is to record exported services with injvm protocol in single registry center.
|
||||
|
|
@ -19,4 +19,4 @@
|
|||
* The one is single registry center, the other is multiple registry centers.<p>
|
||||
* The purpose of all of testcases in this package is to test for single registry center.
|
||||
*/
|
||||
package org.apache.dubbo.integration.single;
|
||||
package org.apache.dubbo.config.integration.single;
|
||||
|
|
@ -14,23 +14,21 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dubbo.metadata;
|
||||
package org.apache.dubbo.config.metadata;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.config.ApplicationConfig;
|
||||
import org.apache.dubbo.config.ProtocolConfig;
|
||||
import org.apache.dubbo.config.RegistryConfig;
|
||||
import org.apache.dubbo.config.ServiceConfig;
|
||||
import org.apache.dubbo.config.api.DemoService;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.config.metadata.ConfigurableMetadataServiceExporter;
|
||||
import org.apache.dubbo.config.provider.impl.DemoServiceImpl;
|
||||
import org.apache.dubbo.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.metadata.MetadataService;
|
||||
import org.apache.dubbo.metadata.MetadataServiceExporter;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
import org.apache.dubbo.rpc.model.FrameworkModel;
|
||||
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -241,20 +239,12 @@ public class MetadataServiceExporterTest {
|
|||
// assertFalse(exporter.isExported());
|
||||
// }
|
||||
|
||||
private static ZookeeperSingleRegistryCenter registryCenter;
|
||||
private static RegistryConfig registryConfig;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
FrameworkModel.destroyAll();
|
||||
registryCenter = new ZookeeperSingleRegistryCenter(NetUtils.getAvailablePort());
|
||||
registryCenter.startup();
|
||||
RegistryCenter.Instance instance = registryCenter.getRegistryCenterInstance().get(0);
|
||||
registryConfig = new RegistryConfig(String.format("%s://%s:%s",
|
||||
instance.getType(),
|
||||
instance.getHostname(),
|
||||
instance.getPort()));
|
||||
|
||||
registryConfig = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress());
|
||||
// pre-check threads
|
||||
//precheckUnclosedThreads();
|
||||
}
|
||||
|
|
@ -1,107 +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.registrycenter;
|
||||
|
||||
import org.apache.curator.test.InstanceSpec;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The abstraction of {@link RegistryCenter} implements the basic methods.
|
||||
*/
|
||||
abstract class AbstractRegistryCenter implements RegistryCenter {
|
||||
|
||||
/**
|
||||
* The default data directory is null
|
||||
*/
|
||||
private static final File DEFAULT_DATA_DIRECTORY = null;
|
||||
|
||||
/**
|
||||
* The default election port is -1.
|
||||
*/
|
||||
private static final int DEFAULT_ELECTION_PORT = -1;
|
||||
|
||||
/**
|
||||
* The default quorum port is -1.
|
||||
*/
|
||||
private static final int DEFAULT_QUORUM_PORT = -1;
|
||||
|
||||
/**
|
||||
* The default value is true.
|
||||
*/
|
||||
private static final boolean DEFAULT_DELETE_DATA_DIRECTORY_ON_CLOSE = true;
|
||||
|
||||
/**
|
||||
* The default service id is -1.
|
||||
*/
|
||||
private static final int DEFAULT_SERVER_ID = -1;
|
||||
|
||||
/**
|
||||
* The default tick time is 5000
|
||||
*/
|
||||
private static final int DEFAULT_TICK_TIME = 5 * 1000;
|
||||
|
||||
/**
|
||||
* The default value is -1.
|
||||
*/
|
||||
private static final int DEFAULT_MAX_CLIENT_CNXNS = 200;
|
||||
|
||||
/**
|
||||
* The minimum session timeout.
|
||||
*/
|
||||
private static final int DEFAULT_MINIMUM_SESSION_TIMEOUT = DEFAULT_TICK_TIME * 2;
|
||||
|
||||
/**
|
||||
* The maximum session timeout.
|
||||
*/
|
||||
private static final int DEFAULT_MAXIMUM_SESSION_TIMEOUT = 60 * 1000;
|
||||
|
||||
/**
|
||||
* The default customer properties.
|
||||
*/
|
||||
private static final Map<String, Object> DEFAULT_CUSTOM_PROPERTIES = new HashMap<>(2);
|
||||
|
||||
/**
|
||||
* The default hostname.
|
||||
*/
|
||||
private static final String DEFAULT_HOSTNAME = "127.0.0.1";
|
||||
|
||||
static {
|
||||
DEFAULT_CUSTOM_PROPERTIES.put("minSessionTimeout", DEFAULT_MINIMUM_SESSION_TIMEOUT);
|
||||
DEFAULT_CUSTOM_PROPERTIES.put("maxSessionTimeout", DEFAULT_MAXIMUM_SESSION_TIMEOUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an {@link InstanceSpec} instance to initialize {@link org.apache.curator.test.TestingServer}
|
||||
*
|
||||
* @param port the zookeeper server's port.
|
||||
*/
|
||||
protected InstanceSpec createInstanceSpec(int port) {
|
||||
return new InstanceSpec(DEFAULT_DATA_DIRECTORY,
|
||||
port,
|
||||
DEFAULT_ELECTION_PORT,
|
||||
DEFAULT_QUORUM_PORT,
|
||||
DEFAULT_DELETE_DATA_DIRECTORY_ON_CLOSE,
|
||||
DEFAULT_SERVER_ID,
|
||||
DEFAULT_TICK_TIME,
|
||||
DEFAULT_MAX_CLIENT_CNXNS,
|
||||
DEFAULT_CUSTOM_PROPERTIES,
|
||||
DEFAULT_HOSTNAME);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,70 +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.registrycenter;
|
||||
|
||||
import org.apache.dubbo.rpc.RpcException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The mock registry center.
|
||||
*/
|
||||
public interface RegistryCenter {
|
||||
|
||||
/**
|
||||
* Start the registry center.
|
||||
*
|
||||
* @throws RpcException when an exception occurred
|
||||
*/
|
||||
void startup() throws RpcException;
|
||||
|
||||
/**
|
||||
* Returns the registry center instance.
|
||||
* <p>This method can be called only after {@link #startup()} is called</p>
|
||||
*
|
||||
* @throws RpcException when an exception occurred
|
||||
*/
|
||||
List<Instance> getRegistryCenterInstance() throws RpcException;
|
||||
|
||||
/**
|
||||
* Stop the registry center.
|
||||
*
|
||||
* @throws RpcException when an exception occurred
|
||||
*/
|
||||
void shutdown() throws RpcException;
|
||||
|
||||
/**
|
||||
* The registry center instance.
|
||||
*/
|
||||
interface Instance {
|
||||
|
||||
/**
|
||||
* Returns the registry center type.
|
||||
*/
|
||||
String getType();
|
||||
|
||||
/**
|
||||
* Returns the hostname of registry center.
|
||||
*/
|
||||
String getHostname();
|
||||
|
||||
/**
|
||||
* Returns the port of registry center.
|
||||
*/
|
||||
int getPort();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,142 +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.registrycenter;
|
||||
|
||||
import org.apache.curator.test.InstanceSpec;
|
||||
import org.apache.curator.test.TestingServer;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.rpc.RpcException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* The default implementation of registry center can support single and multiple registry center.
|
||||
* <p>Each port represents an instance. You can provide multiple ports to build multiple registry center,
|
||||
* if you want to create multiple registry center
|
||||
*/
|
||||
class ZookeeperRegistryCenter extends AbstractRegistryCenter {
|
||||
|
||||
/**
|
||||
* Initialize the default registry center.
|
||||
*
|
||||
* @param ports the registry center's ports.
|
||||
*/
|
||||
public ZookeeperRegistryCenter(int... ports) {
|
||||
this.ports = ports;
|
||||
this.instanceSpecs = new ArrayList<>(this.ports.length);
|
||||
this.zookeeperServers = new ArrayList<>(this.ports.length);
|
||||
}
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ZookeeperRegistryCenter.class);
|
||||
|
||||
/**
|
||||
* The type of the registry center.
|
||||
*/
|
||||
private static final String DEFAULT_REGISTRY_CENTER_TYPE = "zookeeper";
|
||||
|
||||
private int[] ports;
|
||||
|
||||
private List<InstanceSpec> instanceSpecs;
|
||||
|
||||
private List<TestingServer> zookeeperServers;
|
||||
|
||||
private AtomicBoolean started = new AtomicBoolean(false);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void startup() throws RpcException {
|
||||
try {
|
||||
if (started.compareAndSet(false, true)) {
|
||||
logger.info("The ZookeeperRegistryCenter is starting...");
|
||||
for (int port : this.ports) {
|
||||
InstanceSpec instanceSpec = this.createInstanceSpec(port);
|
||||
this.instanceSpecs.add(instanceSpec);
|
||||
this.zookeeperServers.add(new TestingServer(instanceSpec, true));
|
||||
}
|
||||
logger.info("The ZookeeperRegistryCenter is started successfully");
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
started.set(false);
|
||||
throw new RpcException("Failed to initialize ZookeeperRegistryCenter instance", exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Instance> getRegistryCenterInstance() throws RpcException {
|
||||
this.startup();
|
||||
List<Instance> instances = new ArrayList<>(this.instanceSpecs.size());
|
||||
for (InstanceSpec instanceSpec : this.instanceSpecs) {
|
||||
instances.add(new Instance() {
|
||||
@Override
|
||||
public String getType() {
|
||||
return DEFAULT_REGISTRY_CENTER_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHostname() {
|
||||
return instanceSpec.getHostname();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return instanceSpec.getPort();
|
||||
}
|
||||
});
|
||||
}
|
||||
return instances;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void shutdown() throws RpcException {
|
||||
logger.info("The ZookeeperRegistryCenter is stopping...");
|
||||
List<RpcException> exceptions = new ArrayList<>(this.zookeeperServers.size());
|
||||
for (TestingServer testingServer : this.zookeeperServers) {
|
||||
try {
|
||||
testingServer.close();
|
||||
logger.info(String.format("The zookeeper instance of %s is shutdown successfully",
|
||||
testingServer.getConnectString()));
|
||||
} catch (IOException exception) {
|
||||
RpcException rpcException = new RpcException(String.format("Failed to close zookeeper instance of %s",
|
||||
testingServer.getConnectString()),
|
||||
exception);
|
||||
exceptions.add(rpcException);
|
||||
logger.error(rpcException);
|
||||
}
|
||||
}
|
||||
this.instanceSpecs.clear();
|
||||
this.zookeeperServers.clear();
|
||||
if (!exceptions.isEmpty()) {
|
||||
logger.info("The ZookeeperRegistryCenter failed to close.");
|
||||
// throw any one of exceptions
|
||||
throw exceptions.get(0);
|
||||
} else {
|
||||
logger.info("The ZookeeperRegistryCenter close successfully.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
mock=org.apache.dubbo.config.mock.MockServiceListener
|
||||
exported=org.apache.dubbo.integration.single.SingleRegistryCenterExportedServiceListener
|
||||
singleConfigCenterInjvm=org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmServiceListener
|
||||
multipleConfigCenterInjvm=org.apache.dubbo.integration.multiple.injvm.MultipleRegistryCenterInjvmServiceListener
|
||||
singleConfigCenterExportProvider=org.apache.dubbo.integration.single.exportprovider.SingleRegistryCenterExportProviderServiceListener
|
||||
singleConfigCenterExportMetadata=org.apache.dubbo.integration.single.exportmetadata.SingleRegistryCenterExportMetadataServiceListener
|
||||
multipleConfigCenterExportMetadata=org.apache.dubbo.integration.multiple.exportmetadata.MultipleRegistryCenterExportMetadataServiceListener
|
||||
multipleConfigCenterExportProvider=org.apache.dubbo.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderServiceListener
|
||||
exported=org.apache.dubbo.config.integration.single.SingleRegistryCenterExportedServiceListener
|
||||
singleConfigCenterInjvm=org.apache.dubbo.config.integration.single.injvm.SingleRegistryCenterInjvmServiceListener
|
||||
multipleConfigCenterInjvm=org.apache.dubbo.config.integration.multiple.injvm.MultipleRegistryCenterInjvmServiceListener
|
||||
singleConfigCenterExportProvider=org.apache.dubbo.config.integration.single.exportprovider.SingleRegistryCenterExportProviderServiceListener
|
||||
singleConfigCenterExportMetadata=org.apache.dubbo.config.integration.single.exportmetadata.SingleRegistryCenterExportMetadataServiceListener
|
||||
multipleConfigCenterExportMetadata=org.apache.dubbo.config.integration.multiple.exportmetadata.MultipleRegistryCenterExportMetadataServiceListener
|
||||
multipleConfigCenterExportProvider=org.apache.dubbo.config.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderServiceListener
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
multipleConfigCenterServiceDiscoveryRegistry=org.apache.dubbo.integration.multiple.servicediscoveryregistry.MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener
|
||||
multipleConfigCenterServiceDiscoveryRegistry=org.apache.dubbo.config.integration.multiple.servicediscoveryregistry.MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
singleConfigCenterExportProvider=org.apache.dubbo.integration.single.exportprovider.SingleRegistryCenterExportProviderRegistryProtocolListener
|
||||
multipleConfigCenterExportProvider=org.apache.dubbo.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderRegistryProtocolListener
|
||||
singleConfigCenterExportProvider=org.apache.dubbo.config.integration.single.exportprovider.SingleRegistryCenterExportProviderRegistryProtocolListener
|
||||
multipleConfigCenterExportProvider=org.apache.dubbo.config.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderRegistryProtocolListener
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
mockexporterlistener=org.apache.dubbo.config.mock.MockExporterListener
|
||||
singleConfigCenterInjvm=org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmExporterListener
|
||||
multipleConfigCenterInjvm=org.apache.dubbo.integration.multiple.injvm.MultipleRegistryCenterInjvmExporterListener
|
||||
singleConfigCenterExportProvider=org.apache.dubbo.integration.single.exportprovider.SingleRegistryCenterExportProviderExporterListener
|
||||
singleConfigCenterExportMetadata=org.apache.dubbo.integration.single.exportmetadata.SingleRegistryCenterExportMetadataExporterListener
|
||||
multipleConfigCenterExportMetadata=org.apache.dubbo.integration.multiple.exportmetadata.MultipleRegistryCenterExportMetadataExporterListener
|
||||
multipleConfigCenterExportProvider=org.apache.dubbo.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderExporterListener
|
||||
singleConfigCenterInjvm=org.apache.dubbo.config.integration.single.injvm.SingleRegistryCenterInjvmExporterListener
|
||||
multipleConfigCenterInjvm=org.apache.dubbo.config.integration.multiple.injvm.MultipleRegistryCenterInjvmExporterListener
|
||||
singleConfigCenterExportProvider=org.apache.dubbo.config.integration.single.exportprovider.SingleRegistryCenterExportProviderExporterListener
|
||||
singleConfigCenterExportMetadata=org.apache.dubbo.config.integration.single.exportmetadata.SingleRegistryCenterExportMetadataExporterListener
|
||||
multipleConfigCenterExportMetadata=org.apache.dubbo.config.integration.multiple.exportmetadata.MultipleRegistryCenterExportMetadataExporterListener
|
||||
multipleConfigCenterExportProvider=org.apache.dubbo.config.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderExporterListener
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
mockfilter=org.apache.dubbo.config.mock.MockFilter
|
||||
singleConfigCenterInjvm=org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmFilter
|
||||
multipleConfigCenterInjvm=org.apache.dubbo.integration.multiple.injvm.MultipleRegistryCenterInjvmFilter
|
||||
singleConfigCenterExportProvider=org.apache.dubbo.integration.single.exportprovider.SingleRegistryCenterExportProviderFilter
|
||||
multipleConfigCenterExportProvider=org.apache.dubbo.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderFilter
|
||||
singleConfigCenterInjvm=org.apache.dubbo.config.integration.single.injvm.SingleRegistryCenterInjvmFilter
|
||||
multipleConfigCenterInjvm=org.apache.dubbo.config.integration.multiple.injvm.MultipleRegistryCenterInjvmFilter
|
||||
singleConfigCenterExportProvider=org.apache.dubbo.config.integration.single.exportprovider.SingleRegistryCenterExportProviderFilter
|
||||
multipleConfigCenterExportProvider=org.apache.dubbo.config.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderFilter
|
||||
|
|
|
|||
|
|
@ -43,8 +43,6 @@ import org.apache.dubbo.config.spring.impl.HelloServiceImpl;
|
|||
import org.apache.dubbo.config.spring.impl.NotifyService;
|
||||
import org.apache.dubbo.config.spring.registry.MockRegistry;
|
||||
import org.apache.dubbo.config.spring.registry.MockRegistryFactory;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.registry.Registry;
|
||||
import org.apache.dubbo.registry.RegistryService;
|
||||
import org.apache.dubbo.rpc.Exporter;
|
||||
|
|
@ -86,19 +84,6 @@ public class ConfigTest {
|
|||
|
||||
private static String resourcePath = ConfigTest.class.getPackage().getName().replace('.', '/');
|
||||
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
SysProps.clear();
|
||||
|
|
|
|||
|
|
@ -29,14 +29,11 @@ import org.apache.dubbo.config.context.ModuleConfigManager;
|
|||
import org.apache.dubbo.config.spring.api.DemoService;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.apache.dubbo.config.spring.impl.DemoServiceImpl;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.rpc.Constants;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
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.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
|
@ -50,18 +47,6 @@ public class JavaConfigBeanTest {
|
|||
|
||||
private static final String MY_PROTOCOL_ID = "myProtocol";
|
||||
private static final String MY_REGISTRY_ID = "my-registry";
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void beforeEach() {
|
||||
|
|
@ -80,7 +65,7 @@ public class JavaConfigBeanTest {
|
|||
SysProps.setProperty("dubbo.application.qos-enable", "false");
|
||||
SysProps.setProperty("dubbo.protocol.name", "dubbo");
|
||||
SysProps.setProperty("dubbo.protocol.port", "2346");
|
||||
String registryAddress = "zookeeper://127.0.0.1:2181";
|
||||
String registryAddress = ZookeeperRegistryCenterConfig.getConnectionAddress();
|
||||
SysProps.setProperty("dubbo.registry.address", registryAddress);
|
||||
SysProps.setProperty("dubbo.provider.group", "test");
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ import org.apache.dubbo.config.spring.api.HelloService;
|
|||
import org.apache.dubbo.config.spring.api.MethodCallback;
|
||||
import org.apache.dubbo.config.spring.context.annotation.provider.ProviderConfiguration;
|
||||
import org.apache.dubbo.config.spring.impl.MethodCallbackImpl;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -49,25 +47,20 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|||
})
|
||||
@TestPropertySource(properties = {
|
||||
"dubbo.protocol.port=-1",
|
||||
"dubbo.registry.address=zookeeper://127.0.0.1:2181"
|
||||
"dubbo.registry.address=${zookeeper.connection.address}"
|
||||
})
|
||||
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class MethodConfigCallbackTest {
|
||||
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
DubboBootstrap.reset();
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ package org.apache.dubbo.config.spring.boot.conditional1;
|
|||
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.config.spring.api.HelloService;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -50,19 +48,14 @@ import java.util.Map;
|
|||
//@ComponentScan
|
||||
public class XmlReferenceBeanConditionalTest {
|
||||
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll(){
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll(){
|
||||
DubboBootstrap.reset();
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ import org.apache.dubbo.config.spring.ReferenceBean;
|
|||
import org.apache.dubbo.config.spring.api.HelloService;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.apache.dubbo.config.spring.context.annotation.provider.HelloServiceImpl;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -56,19 +54,14 @@ import java.util.Map;
|
|||
@EnableDubbo
|
||||
public class JavaConfigAnnotationReferenceBeanConditionalTest {
|
||||
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll(){
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll(){
|
||||
DubboBootstrap.reset();
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ import org.apache.dubbo.config.spring.api.HelloService;
|
|||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.apache.dubbo.config.spring.context.annotation.provider.HelloServiceImpl;
|
||||
import org.apache.dubbo.config.spring.reference.ReferenceBeanBuilder;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -56,19 +54,14 @@ import java.util.Map;
|
|||
@EnableDubbo
|
||||
public class JavaConfigRawReferenceBeanConditionalTest {
|
||||
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll(){
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll(){
|
||||
DubboBootstrap.reset();
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ import org.apache.dubbo.config.spring.ReferenceBean;
|
|||
import org.apache.dubbo.config.spring.api.HelloService;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.apache.dubbo.config.spring.context.annotation.provider.HelloServiceImpl;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -56,19 +54,14 @@ import java.util.Map;
|
|||
@EnableDubbo
|
||||
public class JavaConfigReferenceBeanConditionalTest4 {
|
||||
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll(){
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll(){
|
||||
DubboBootstrap.reset();
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -30,9 +30,8 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
|||
import org.apache.dubbo.config.context.ConfigManager;
|
||||
import org.apache.dubbo.config.context.ModuleConfigManager;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperMultipleRegistryCenter;
|
||||
import org.apache.dubbo.rpc.model.ModuleModel;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -48,51 +47,46 @@ import java.util.List;
|
|||
import static org.apache.dubbo.common.constants.MetricsConstants.PROTOCOL_PROMETHEUS;
|
||||
|
||||
@SpringBootTest(
|
||||
properties = {
|
||||
"dubbo.application.NAME = dubbo-demo-application",
|
||||
"dubbo.module.name = dubbo-demo-module",
|
||||
"dubbo.registry.address = zookeeper://192.168.99.100:32770",
|
||||
"dubbo.protocol.name=dubbo",
|
||||
"dubbo.protocol.port=20880",
|
||||
"dubbo.metrics.protocol=prometheus",
|
||||
"dubbo.metrics.prometheus.exporter.enabled=true",
|
||||
"dubbo.metrics.prometheus.exporter.enable-http-service-discovery=true",
|
||||
"dubbo.metrics.prometheus.exporter.http-service-discovery-url=localhost:8080",
|
||||
"dubbo.metrics.prometheus.exporter.metrics-port=20888",
|
||||
"dubbo.metrics.prometheus.exporter.metrics-path=/metrics",
|
||||
"dubbo.metrics.aggregation.enabled=true",
|
||||
"dubbo.metrics.aggregation.bucket-num=5",
|
||||
"dubbo.metrics.aggregation.time-window-seconds=120",
|
||||
"dubbo.monitor.address=zookeeper://127.0.0.1:32770",
|
||||
"dubbo.Config-center.address=zookeeper://127.0.0.1:2181",
|
||||
"dubbo.config-Center.group=group1",
|
||||
"dubbo.metadata-report.address=zookeeper://127.0.0.1:2182",
|
||||
"dubbo.METADATA-REPORT.username=User",
|
||||
"dubbo.provider.host=127.0.0.1",
|
||||
"dubbo.consumer.client=netty"
|
||||
},
|
||||
classes = {
|
||||
SpringBootConfigPropsTest.class
|
||||
}
|
||||
properties = {
|
||||
"dubbo.application.NAME = dubbo-demo-application",
|
||||
"dubbo.module.name = dubbo-demo-module",
|
||||
"dubbo.registry.address = zookeeper://192.168.99.100:32770",
|
||||
"dubbo.protocol.name=dubbo",
|
||||
"dubbo.protocol.port=20880",
|
||||
"dubbo.metrics.protocol=prometheus",
|
||||
"dubbo.metrics.prometheus.exporter.enabled=true",
|
||||
"dubbo.metrics.prometheus.exporter.enable-http-service-discovery=true",
|
||||
"dubbo.metrics.prometheus.exporter.http-service-discovery-url=localhost:8080",
|
||||
"dubbo.metrics.prometheus.exporter.metrics-port=20888",
|
||||
"dubbo.metrics.prometheus.exporter.metrics-path=/metrics",
|
||||
"dubbo.metrics.aggregation.enabled=true",
|
||||
"dubbo.metrics.aggregation.bucket-num=5",
|
||||
"dubbo.metrics.aggregation.time-window-seconds=120",
|
||||
"dubbo.monitor.address=zookeeper://127.0.0.1:32770",
|
||||
"dubbo.Config-center.address=${zookeeper.connection.address.1}",
|
||||
"dubbo.config-Center.group=group1",
|
||||
"dubbo.metadata-report.address=${zookeeper.connection.address.2}",
|
||||
"dubbo.METADATA-REPORT.username=User",
|
||||
"dubbo.provider.host=127.0.0.1",
|
||||
"dubbo.consumer.client=netty"
|
||||
},
|
||||
classes = {
|
||||
SpringBootConfigPropsTest.class
|
||||
}
|
||||
)
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
@EnableDubbo
|
||||
public class SpringBootConfigPropsTest {
|
||||
|
||||
private static RegistryCenter multipleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
multipleRegistryCenter = new ZookeeperMultipleRegistryCenter();
|
||||
multipleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
DubboBootstrap.reset();
|
||||
multipleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
|
@ -135,13 +129,13 @@ public class SpringBootConfigPropsTest {
|
|||
Collection<ConfigCenterConfig> configCenters = configManager.getConfigCenters();
|
||||
Assertions.assertEquals(1, configCenters.size());
|
||||
ConfigCenterConfig centerConfig = configCenters.iterator().next();
|
||||
Assertions.assertEquals("zookeeper://127.0.0.1:2181", centerConfig.getAddress());
|
||||
Assertions.assertEquals(ZookeeperRegistryCenterConfig.getConnectionAddress1(), centerConfig.getAddress());
|
||||
Assertions.assertEquals("group1", centerConfig.getGroup());
|
||||
|
||||
Collection<MetadataReportConfig> metadataConfigs = configManager.getMetadataConfigs();
|
||||
Assertions.assertEquals(1, metadataConfigs.size());
|
||||
MetadataReportConfig reportConfig = metadataConfigs.iterator().next();
|
||||
Assertions.assertEquals("zookeeper://127.0.0.1:2182", reportConfig.getAddress());
|
||||
Assertions.assertEquals(ZookeeperRegistryCenterConfig.getConnectionAddress2(), reportConfig.getAddress());
|
||||
Assertions.assertEquals("User", reportConfig.getUsername());
|
||||
|
||||
// module configs
|
||||
|
|
|
|||
|
|
@ -30,10 +30,8 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
|||
import org.apache.dubbo.config.context.ConfigManager;
|
||||
import org.apache.dubbo.config.context.ModuleConfigManager;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperMultipleRegistryCenter;
|
||||
import org.apache.dubbo.rpc.model.ModuleModel;
|
||||
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -65,9 +63,9 @@ import static org.apache.dubbo.common.constants.MetricsConstants.PROTOCOL_PROMET
|
|||
"dubbo.metricses.my-metrics.aggregation.bucket-num=5",
|
||||
"dubbo.metricses.my-metrics.aggregation.time-window-seconds=120",
|
||||
"dubbo.monitors.my-monitor.address=zookeeper://127.0.0.1:32770",
|
||||
"dubbo.config-centers.my-configcenter.address=zookeeper://127.0.0.1:2181",
|
||||
"dubbo.config-centers.my-configcenter.address=${zookeeper.connection.address.1}",
|
||||
"dubbo.config-centers.my-configcenter.group=group1",
|
||||
"dubbo.metadata-reports.my-metadata.address=zookeeper://127.0.0.1:2182",
|
||||
"dubbo.metadata-reports.my-metadata.address=${zookeeper.connection.address.2}",
|
||||
"dubbo.metadata-reports.my-metadata.username=User",
|
||||
"dubbo.providers.my-provider.host=127.0.0.1",
|
||||
"dubbo.consumers.my-consumer.client=netty"
|
||||
|
|
@ -81,19 +79,14 @@ import static org.apache.dubbo.common.constants.MetricsConstants.PROTOCOL_PROMET
|
|||
@EnableDubbo
|
||||
public class SpringBootMultipleConfigPropsTest {
|
||||
|
||||
private static RegistryCenter multipleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
multipleRegistryCenter = new ZookeeperMultipleRegistryCenter();
|
||||
multipleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
DubboBootstrap.reset();
|
||||
multipleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
|
@ -137,13 +130,13 @@ public class SpringBootMultipleConfigPropsTest {
|
|||
Collection<ConfigCenterConfig> configCenters = configManager.getConfigCenters();
|
||||
Assertions.assertEquals(1, configCenters.size());
|
||||
ConfigCenterConfig centerConfig = configCenters.iterator().next();
|
||||
Assertions.assertEquals("zookeeper://127.0.0.1:2181", centerConfig.getAddress());
|
||||
Assertions.assertEquals(ZookeeperRegistryCenterConfig.getConnectionAddress1(), centerConfig.getAddress());
|
||||
Assertions.assertEquals("group1", centerConfig.getGroup());
|
||||
|
||||
Collection<MetadataReportConfig> metadataConfigs = configManager.getMetadataConfigs();
|
||||
Assertions.assertEquals(1, metadataConfigs.size());
|
||||
MetadataReportConfig reportConfig = metadataConfigs.iterator().next();
|
||||
Assertions.assertEquals("zookeeper://127.0.0.1:2182", reportConfig.getAddress());
|
||||
Assertions.assertEquals(ZookeeperRegistryCenterConfig.getConnectionAddress2(), reportConfig.getAddress());
|
||||
Assertions.assertEquals("User", reportConfig.getUsername());
|
||||
|
||||
// module configs
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ package org.apache.dubbo.config.spring.boot.importxml;
|
|||
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.config.spring.api.HelloService;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -44,19 +42,14 @@ import org.springframework.context.annotation.ImportResource;
|
|||
@ImportResource("classpath:/org/apache/dubbo/config/spring/boot/importxml/consumer/dubbo-consumer.xml")
|
||||
public class SpringBootImportDubboXmlTest {
|
||||
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll(){
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll(){
|
||||
DubboBootstrap.reset();
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ import org.apache.dubbo.config.ProtocolConfig;
|
|||
import org.apache.dubbo.config.RegistryConfig;
|
||||
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -83,20 +81,14 @@ public class DubboConfigConfigurationTest {
|
|||
|
||||
@Test
|
||||
public void testMultiple() {
|
||||
RegistryCenter singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
try{
|
||||
context.register(DubboConfigConfiguration.Multiple.class);
|
||||
context.refresh();
|
||||
context.register(DubboConfigConfiguration.Multiple.class);
|
||||
context.refresh();
|
||||
|
||||
RegistryConfig registry1 = context.getBean("registry1", RegistryConfig.class);
|
||||
Assertions.assertEquals(2181, registry1.getPort());
|
||||
RegistryConfig registry1 = context.getBean("registry1", RegistryConfig.class);
|
||||
Assertions.assertEquals(2181, registry1.getPort());
|
||||
|
||||
RegistryConfig registry2 = context.getBean("registry2", RegistryConfig.class);
|
||||
Assertions.assertEquals(2182, registry2.getPort());
|
||||
}finally {
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
RegistryConfig registry2 = context.getBean("registry2", RegistryConfig.class);
|
||||
Assertions.assertEquals(2182, registry2.getPort());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ import org.apache.dubbo.config.ProviderConfig;
|
|||
import org.apache.dubbo.config.RegistryConfig;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.config.context.ConfigManager;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperMultipleRegistryCenter;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
|
@ -48,19 +46,14 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
|||
*/
|
||||
public class EnableDubboConfigTest {
|
||||
|
||||
private RegistryCenter multipleRegistryCenter;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
multipleRegistryCenter = new ZookeeperMultipleRegistryCenter();
|
||||
multipleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
DubboBootstrap.reset();
|
||||
multipleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
//@Test
|
||||
|
|
|
|||
|
|
@ -20,12 +20,11 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
|||
import org.apache.dubbo.config.spring.SysProps;
|
||||
import org.apache.dubbo.config.spring.api.HelloService;
|
||||
import org.apache.dubbo.config.spring.context.DubboSpringInitCustomizerHolder;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
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.ServiceDescriptor;
|
||||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -34,22 +33,16 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|||
|
||||
public class DubboSpringInitCustomizerTest {
|
||||
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
DubboBootstrap.reset();
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
RegistryCenter.Instance registryCenterInstance = singleRegistryCenter.getRegistryCenterInstance().get(0);
|
||||
SysProps.setProperty("dubbo.registry.address", registryCenterInstance.toURL());
|
||||
SysProps.setProperty("dubbo.registry.address", ZookeeperRegistryCenterConfig.getConnectionAddress());
|
||||
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
DubboBootstrap.reset();
|
||||
singleRegistryCenter.shutdown();
|
||||
SysProps.clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ package org.apache.dubbo.config.spring.issues.issue6000;
|
|||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.apache.dubbo.config.spring.issues.issue6000.adubbo.HelloDubbo;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
|
|
@ -40,19 +38,14 @@ import org.springframework.context.annotation.PropertySource;
|
|||
@PropertySource("classpath:/META-INF/issues/issue6000/config.properties")
|
||||
public class Issue6000Test {
|
||||
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
DubboBootstrap.reset();
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -18,10 +18,8 @@ package org.apache.dubbo.config.spring.issues.issue6252;
|
|||
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.config.spring.api.DemoService;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperMultipleRegistryCenter;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -39,19 +37,14 @@ import org.springframework.context.annotation.PropertySource;
|
|||
@PropertySource("classpath:/META-INF/issues/issue6252/config.properties")
|
||||
public class Issue6252Test {
|
||||
|
||||
private static RegistryCenter multipleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
multipleRegistryCenter = new ZookeeperMultipleRegistryCenter();
|
||||
multipleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
DubboBootstrap.reset();
|
||||
multipleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@DubboReference
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
|||
import org.apache.dubbo.config.spring.ReferenceBean;
|
||||
import org.apache.dubbo.config.spring.api.HelloService;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
|
@ -49,19 +47,14 @@ import java.util.Map;
|
|||
@PropertySource("classpath:/META-INF/issues/issue7003/config.properties")
|
||||
public class Issue7003Test {
|
||||
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
DubboBootstrap.reset();
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -25,12 +25,9 @@ import org.apache.dubbo.config.spring.api.HelloService;
|
|||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.apache.dubbo.config.spring.impl.DemoServiceImpl;
|
||||
import org.apache.dubbo.config.spring.impl.HelloServiceImpl;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperMultipleRegistryCenter;
|
||||
import org.apache.dubbo.config.spring.util.DubboBeanUtils;
|
||||
import org.apache.dubbo.rpc.model.ModuleModel;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
@ -41,21 +38,6 @@ import org.springframework.context.annotation.PropertySource;
|
|||
*/
|
||||
public class MultipleConsumerAndProviderTest {
|
||||
|
||||
private static ZookeeperMultipleRegistryCenter registryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() {
|
||||
registryCenter = new ZookeeperMultipleRegistryCenter();
|
||||
registryCenter.startup();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void tearDown() {
|
||||
if (registryCenter != null) {
|
||||
registryCenter.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ package org.apache.dubbo.config.spring.propertyconfigurer.consumer;
|
|||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.apache.dubbo.config.spring.api.HelloService;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -34,19 +32,14 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|||
|
||||
public class PropertyConfigurerTest {
|
||||
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
DubboBootstrap.reset();
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
dubbo.registry.address=zookeeper://127.0.0.1:2181?registry-type=service
|
||||
dubbo.registry.address=${zookeeper.connection.address}?registry-type=service
|
||||
biz.group=greeting
|
||||
biz.group2=group2
|
||||
dubbo.call-timeout=2000
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
<dubbo:application name="demo-consumer">
|
||||
</dubbo:application>
|
||||
|
||||
<!-- <dubbo:metadata-report address="zookeeper://127.0.0.1:2181"/>-->
|
||||
<!-- <dubbo:metadata-report address="${zookeeper.connection.address}"/>-->
|
||||
|
||||
<dubbo:registry address="${dubbo.registry.address}"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
|||
import org.apache.dubbo.config.spring.api.HelloService;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.apache.dubbo.config.spring.propertyconfigurer.consumer.DemoBeanFactoryPostProcessor;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -35,19 +33,14 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|||
|
||||
public class PropertySourcesConfigurerTest {
|
||||
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
DubboBootstrap.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
DubboBootstrap.reset();
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
dubbo.registry.address=zookeeper://127.0.0.1:2181?registry-type=service
|
||||
dubbo.registry.address=${zookeeper.connection.address}?registry-type=service
|
||||
biz.group=greeting
|
||||
biz.group2=group2
|
||||
dubbo.call-timeout=2000
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
<dubbo:application name="demo-consumer">
|
||||
</dubbo:application>
|
||||
|
||||
<!-- <dubbo:metadata-report address="zookeeper://127.0.0.1:2181"/>-->
|
||||
<!-- <dubbo:metadata-report address="${zookeeper.connection.address}"/>-->
|
||||
|
||||
<dubbo:registry address="${dubbo.registry.address}"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,12 +20,8 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
|||
import org.apache.dubbo.config.spring.api.HelloService;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.apache.dubbo.config.spring.propertyconfigurer.consumer.DemoBeanFactoryPostProcessor;
|
||||
import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
|
||||
import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
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.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
|
@ -45,18 +41,6 @@ public class PropertySourcesInJavaConfigTest {
|
|||
private static final String SCAN_PACKAGE_NAME = "org.apache.dubbo.config.spring.propertyconfigurer.consumer3.notexist";
|
||||
private static final String PACKAGE_PATH = "/org/apache/dubbo/config/spring/propertyconfigurer/consumer3";
|
||||
private static final String PROVIDER_CONFIG_PATH = "org/apache/dubbo/config/spring/propertyconfigurer/provider/dubbo-provider.xml";
|
||||
private static RegistryCenter singleRegistryCenter;
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
singleRegistryCenter = new ZookeeperSingleRegistryCenter();
|
||||
singleRegistryCenter.startup();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
singleRegistryCenter.shutdown();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
dubbo.registry.address=zookeeper://127.0.0.1:2181?registry-type=service
|
||||
dubbo.registry.address=${zookeeper.connection.address}?registry-type=service
|
||||
biz.group=greeting
|
||||
biz.group2=group2
|
||||
dubbo.call-timeout=2000
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<dubbo:application name="demo-consumer">
|
||||
</dubbo:application>
|
||||
|
||||
<!-- <dubbo:metadata-report address="zookeeper://127.0.0.1:2181"/>-->
|
||||
<!-- <dubbo:metadata-report address="${zookeeper.connection.address}"/>-->
|
||||
|
||||
<dubbo:registry address="${dubbo.registry.address}"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
dubbo.application.name=demo-provider
|
||||
dubbo.registry.address=zookeeper://127.0.0.1:2181?registry-type=service
|
||||
dubbo.config-center.address=zookeeper://127.0.0.1:2181
|
||||
dubbo.metadata-report.address=zookeeper://127.0.0.1:2181
|
||||
dubbo.registry.address=${zookeeper.connection.address}?registry-type=service
|
||||
dubbo.config-center.address=${zookeeper.connection.address}
|
||||
dubbo.metadata-report.address=${zookeeper.connection.address}
|
||||
biz.group=greeting
|
||||
biz.group2=group2
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue