Skip to content

Commit e7ce16d

Browse files
authored
Dubbo Cloud Native (apache#4764)
* Polish apache#4542 : [Enhancement] Adapt the Java standard Event/Listener mechanism * Polish apache#4541 : [Feature] Add local File System DynamicConfigurationFactory‘s extension * Polish apache#4541 : Bugfix * Polish apache#4541 : Optimization * Polish apache#4541 : Add the compatibility for PollingWatchService on the some platforms * Polish apache#4541 : Add delay publish without ThreadPoolExecutor * Polish apache#4541 : Refactor the extension name * Polish apache#4541 : Add remove ops * Polish apache#4541 : Add testable constructor * Polish apache#4541 : Add getConfigGroups method * Polish apache#4610 : [Refactor] Refactor the bootstrap module * Polish apache#4541 : Fix the nulling URL issue * Polish apache#4622 : [Refactor] Refactor ConfigManager * Polish apache#4622 : [Refactor] Refactor ConfigManager * Polish apache#4622 : Support multiple configcenters * Polish apache#4671 : ServiceNameMapping will not map the group, version and protocol * update referenceCount log (apache#4683) Add comments to support multiple shared connections * Polish /apache#4687 : Remove the duplicated test code in dubbo-config-spring (apache#4688) * apache#4685 修改代码if判断false问题 if (hasException == false)修改成if (!hasException) (apache#4695) * Fixed Service annotation method parameters are not in effect (apache#4598) * keep demo simple, and switch to use zookeeper as registry center (apache#4705) * keep demo simple, and switch to use zookeeper as registry center * remove comment * @reference auto-wires the instance of generic interface apache#4594 (apache#4677) * try to shorten maven output to make travis build pass (apache#4710) * use CountDownLatch to check zk registry if establish connection (apache#4589) * Minor change * Rename the extension name of WritableMetadataService * Polish apache#4759 : [Refactor] Change the signature of methods of MetadataService apache#4759 * Merge remote-tracking branch 'upstream/master' into dubbo-cloud-native # Conflicts: # dubbo-all/pom.xml # dubbo-bom/pom.xml # dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java # dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ApplicationConfig.java # dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java # dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java # dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java # dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java # dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java # dubbo-configcenter/dubbo-configcenter-api/src/main/java/org/apache/dubbo/configcenter/DynamicConfiguration.java # dubbo-configcenter/dubbo-configcenter-api/src/test/java/org/apache/dubbo/configcenter/mock/MockDynamicConfiguration.java # dubbo-configcenter/dubbo-configcenter-consul/src/main/java/org/apache/dubbo/configcenter/consul/ConsulDynamicConfiguration.java # dubbo-configcenter/dubbo-configcenter-etcd/src/test/java/org/apache/dubbo/configcenter/support/etcd/EtcdDynamicConfigurationTest.java # dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java # dubbo-configcenter/dubbo-configcenter-nacos/src/test/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationTest.java # dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java # dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/definition/model/MethodDefinition.java # dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifier.java # dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReport.java # dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifierTest.java # dubbo-metadata/dubbo-metadata-definition-protobuf/src/main/java/org/apache/dubbo/metadata/definition/protobuf/ProtobufTypeBuilder.java # dubbo-metadata/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/ProtobufTypeBuilderTest.java # dubbo-metadata/pom.xml # dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java # dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java # dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java # dubbo-rpc/dubbo-rpc-xml/src/main/java/org/apache/dubbo/xml/rpc/protocol/xmlrpc/XmlRpcProtocol.java * Polish apache#3984 : Add the implementation of Page<ServiceInstance> getInstances(String serviceName, int offset, int pageSize, boolean healthyOnly) * Code merge
1 parent df34800 commit e7ce16d

File tree

229 files changed

+1527
-1914
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+1527
-1914
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cache:
1212
install: true
1313

1414
script:
15-
- travis_wait 30 ./mvnw clean install -DskipTests=false -Dcheckstyle.skip=false -Drat.skip=false -Dmaven.javadoc.skip=true
15+
- travis_wait 30 ./mvnw --quiet clean install -DskipTests=false -Dcheckstyle.skip=false -Drat.skip=false -Dmaven.javadoc.skip=true
1616

1717
after_success:
1818
- bash <(curl -s https://codecov.io/bash)

dubbo-bom/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<groupId>org.apache.dubbo</groupId>
2424
<artifactId>dubbo-parent</artifactId>
2525
<version>${revision}</version>
26+
<relativePath>../pom.xml</relativePath>
2627
</parent>
2728

2829
<artifactId>dubbo-bom</artifactId>

dubbo-bootstrap/pom.xml

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,7 @@
2626

2727
<!-- Test dependencies -->
2828

29-
30-
<dependency>
31-
<groupId>org.apache.dubbo</groupId>
32-
<artifactId>dubbo-configcenter-zookeeper</artifactId>
33-
<version>${project.parent.version}</version>
34-
<scope>test</scope>
35-
</dependency>
36-
29+
<!-- Zookeeper dependencies for testing -->
3730
<dependency>
3831
<groupId>org.apache.dubbo</groupId>
3932
<artifactId>dubbo-registry-zookeeper</artifactId>
@@ -48,29 +41,13 @@
4841
<scope>test</scope>
4942
</dependency>
5043

51-
<!-- Zookeeper dependencies for testing -->
5244
<dependency>
5345
<groupId>org.apache.dubbo</groupId>
54-
<artifactId>dubbo-registry-etcd3</artifactId>
55-
<version>${project.parent.version}</version>
56-
<!-- <scope>test</scope>-->
57-
</dependency>
58-
59-
<dependency>
60-
<groupId>org.apache.dubbo</groupId>
61-
<artifactId>dubbo-metadata-report-etcd</artifactId>
62-
<version>${project.parent.version}</version>
63-
<scope>test</scope>
64-
</dependency>
65-
66-
<dependency>
67-
<groupId>org.apache.dubbo</groupId>
68-
<artifactId>dubbo-configcenter-etcd</artifactId>
46+
<artifactId>dubbo-configcenter-zookeeper</artifactId>
6947
<version>${project.parent.version}</version>
7048
<scope>test</scope>
7149
</dependency>
7250

73-
7451
<!-- Nacos dependencies for testing -->
7552
<dependency>
7653
<groupId>org.apache.dubbo</groupId>
@@ -113,17 +90,6 @@
11390
<scope>test</scope>
11491
</dependency>
11592

116-
<!-- <dependency>-->
117-
<!-- <groupId>com.google.guava</groupId>-->
118-
<!-- <artifactId>guava</artifactId>-->
119-
<!-- <version>20.0</version>-->
120-
<!-- </dependency>-->
121-
<dependency>
122-
<groupId>org.apache.curator</groupId>
123-
<artifactId>curator-test</artifactId>
124-
<scope>test</scope>
125-
</dependency>
126-
12793
</dependencies>
12894

129-
</project>
95+
</project>

dubbo-bootstrap/src/main/java/org/apache/dubbo/bootstrap/DubboBootstrap.java

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
import java.io.IOException;
5858
import java.util.ArrayList;
5959
import java.util.Collection;
60-
import java.util.HashMap;
6160
import java.util.List;
6261
import java.util.Map;
6362
import java.util.Set;
@@ -77,7 +76,6 @@
7776
import static org.apache.dubbo.common.utils.StringUtils.isNotEmpty;
7877
import static org.apache.dubbo.config.context.ConfigManager.getInstance;
7978
import static org.apache.dubbo.registry.support.AbstractRegistryFactory.getRegistries;
80-
import static org.apache.dubbo.remoting.Constants.CLIENT_KEY;
8179

8280
/**
8381
* The bootstrap class of Dubbo
@@ -114,19 +112,14 @@ public class DubboBootstrap {
114112

115113
private final ConfigManager configManager = getInstance();
116114

117-
/**
118-
* Is provider or not
119-
*/
120-
private boolean isProvider;
121-
122-
private boolean initialized = false;
115+
private volatile boolean initialized = false;
123116

124-
private boolean started = false;
117+
private volatile boolean started = false;
125118

126119
/**
127120
* Only Provider Register
128121
*/
129-
private boolean onlyRegisterProvider = false;
122+
private volatile boolean onlyRegisterProvider = false;
130123

131124
private ServiceInstance serviceInstance;
132125

@@ -155,6 +148,7 @@ public DubboBootstrap metadataReport(List<MetadataReportConfig> metadataReportCo
155148
return this;
156149
}
157150

151+
158152
// {@link ApplicationConfig} correlative methods
159153

160154
/**
@@ -193,6 +187,7 @@ public DubboBootstrap application(ApplicationConfig applicationConfig) {
193187
return this;
194188
}
195189

190+
196191
// {@link RegistryConfig} correlative methods
197192

198193
/**
@@ -240,8 +235,8 @@ public DubboBootstrap registries(Iterable<RegistryConfig> registryConfigs) {
240235
return this;
241236
}
242237

243-
// {@link ProtocolConfig} correlative methods
244238

239+
// {@link ProtocolConfig} correlative methods
245240
public DubboBootstrap protocol(Consumer<ProtocolBuilder> consumerBuilder) {
246241
return protocol(DEFAULT_PROTOCOL_ID, consumerBuilder);
247242
}
@@ -261,8 +256,8 @@ public DubboBootstrap protocols(List<ProtocolConfig> protocolConfigs) {
261256
return this;
262257
}
263258

264-
// {@link ServiceConfig} correlative methods
265259

260+
// {@link ServiceConfig} correlative methods
266261
public <S> DubboBootstrap service(Consumer<ServiceBuilder<S>> consumerBuilder) {
267262
return service(DEFAULT_SERVICE_ID, consumerBuilder);
268263
}
@@ -278,8 +273,8 @@ public DubboBootstrap service(ServiceConfig<?> serviceConfig) {
278273
return this;
279274
}
280275

281-
// {@link Reference} correlative methods
282276

277+
// {@link Reference} correlative methods
283278
public <S> DubboBootstrap reference(Consumer<ReferenceBuilder<S>> consumerBuilder) {
284279
return reference(DEFAULT_REFERENCE_ID, consumerBuilder);
285280
}
@@ -295,8 +290,8 @@ public DubboBootstrap reference(ReferenceConfig<?> referenceConfig) {
295290
return this;
296291
}
297292

298-
// {@link ProviderConfig} correlative methods
299293

294+
// {@link ProviderConfig} correlative methods
300295
public DubboBootstrap provider(Consumer<ProviderBuilder> builderConsumer) {
301296
return provider(DEFAULT_PROVIDER_ID, builderConsumer);
302297
}
@@ -316,8 +311,8 @@ public DubboBootstrap providers(List<ProviderConfig> providerConfigs) {
316311
return this;
317312
}
318313

319-
// {@link ConsumerConfig} correlative methods
320314

315+
// {@link ConsumerConfig} correlative methods
321316
public DubboBootstrap consumer(Consumer<ConsumerBuilder> builderConsumer) {
322317
return consumer(DEFAULT_CONSUMER_ID, builderConsumer);
323318
}
@@ -338,6 +333,7 @@ public DubboBootstrap consumers(List<ConsumerConfig> consumerConfigs) {
338333
}
339334

340335
// {@link ConfigCenterConfig} correlative methods
336+
341337
public DubboBootstrap configCenter(ConfigCenterConfig configCenterConfig) {
342338
return configCenter(asList(configCenterConfig));
343339
}
@@ -424,13 +420,8 @@ private void useRegistryAsConfigCenterIfNecessary() {
424420
String id = "config-center-" + protocol + "-" + registryConfig.getPort();
425421
ConfigCenterConfig cc = new ConfigCenterConfig();
426422
cc.setId(id);
427-
cc.setParameters(registryConfig.getParameters() == null ?
428-
new HashMap<>() :
429-
new HashMap<>(registryConfig.getParameters()));
430-
cc.getParameters().put(CLIENT_KEY,registryConfig.getClient());
431-
cc.setProtocol(registryConfig.getProtocol());
423+
cc.setProtocol(protocol);
432424
cc.setAddress(registryConfig.getAddress());
433-
cc.setNamespace(registryConfig.getGroup());
434425
cc.setHighestPriority(false);
435426
configManager.addConfigCenter(cc);
436427
});
@@ -463,7 +454,6 @@ public DubboBootstrap start() {
463454
/**
464455
* export {@link MetadataService}
465456
*/
466-
// TODO, only export to default registry?
467457
List<URL> exportedURLs = exportMetadataService(
468458
configManager.getApplication().orElseThrow(() -> new IllegalStateException("ApplicationConfig cannot be null")),
469459
configManager.getRegistries(),
@@ -541,6 +531,7 @@ public boolean isStarted() {
541531

542532

543533
/* serve for builder apis, begin */
534+
544535
private ApplicationBuilder createApplicationBuilder(String name) {
545536
return new ApplicationBuilder().name(name);
546537
}
@@ -569,8 +560,8 @@ private ConsumerBuilder createConsumerBuilder(String id) {
569560
return new ConsumerBuilder().id(id);
570561
}
571562

572-
/* serve for builder apis, end */
573563

564+
/* serve for builder apis, end */
574565
private void startMetadataReport() {
575566
ApplicationConfig applicationConfig = configManager.getApplication().orElseThrow(() -> new IllegalStateException("There's no ApplicationConfig specified."));
576567

@@ -612,15 +603,14 @@ private DynamicConfiguration prepareEnvironment(ConfigCenterConfig configCenter)
612603
return null;
613604
}
614605
DynamicConfiguration dynamicConfiguration = getDynamicConfiguration(configCenter.toUrl());
615-
String configContent = dynamicConfiguration.getProperties(configCenter.getConfigFile(), configCenter.getGroup());
606+
String configContent = dynamicConfiguration.getRule(configCenter.getConfigFile(), configCenter.getGroup());
616607

617608
String appGroup = configManager.getApplication().orElse(new ApplicationConfig()).getName();
618609
String appConfigContent = null;
619610
if (isNotEmpty(appGroup)) {
620-
appConfigContent = dynamicConfiguration.getProperties
621-
(isNotEmpty(configCenter.getAppConfigFile()) ? configCenter.getAppConfigFile() : configCenter.getConfigFile(),
622-
appGroup
623-
);
611+
appConfigContent = dynamicConfiguration.getConfig(isNotEmpty(configCenter.getAppConfigFile()) ?
612+
configCenter.getAppConfigFile() : configCenter.getConfigFile(), appGroup
613+
);
624614
}
625615
try {
626616
Environment.getInstance().setConfigCenterFirst(configCenter.isHighestPriority());
@@ -663,6 +653,10 @@ public void exportServiceConfig(ServiceConfig<?> serviceConfig) {
663653
serviceConfig.export();
664654
}
665655

656+
public boolean isOnlyRegisterProvider() {
657+
return onlyRegisterProvider;
658+
}
659+
666660
private void registerServiceInstance(List<URL> exportedURLs) {
667661

668662
exportedURLs

dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.apache.dubbo.config.ReferenceConfig;
2020
import org.apache.dubbo.config.context.ConfigManager;
2121

22-
2322
/**
2423
* Dubbo Provider Bootstrap
2524
*

dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public static void main(String[] args) {
3030
.registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry-type=service"))
3131
// Nacos
3232
.registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry-type=service"))
33-
// .registry(RegistryBuilder.newBuilder().address("etcd3://127.0.0.1:2379?registry-type=service").build())
3433
.protocol(builder -> builder.port(-1).name("dubbo"))
3534
.service(builder -> builder.id("test").interfaceClass(EchoService.class).ref(new EchoServiceImpl()))
3635
.start()

dubbo-cluster/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<groupId>org.apache.dubbo</groupId>
2121
<artifactId>dubbo-parent</artifactId>
2222
<version>${revision}</version>
23+
<relativePath>../pom.xml</relativePath>
2324
</parent>
2425
<artifactId>dubbo-cluster</artifactId>
2526
<packaging>jar</packaging>

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/config/ListenableRouter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private synchronized void init(String ruleKey) {
119119
}
120120
String routerKey = ruleKey + RULE_SUFFIX;
121121
configuration.addListener(routerKey, this);
122-
String rule = configuration.getRule(routerKey, DynamicConfiguration.DEFAULT_GROUP);
122+
String rule = configuration.getConfig(routerKey, DynamicConfiguration.DEFAULT_GROUP);
123123
if (StringUtils.isNotEmpty(rule)) {
124124
this.process(new ConfigChangeEvent(routerKey, rule));
125125
}

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public <T> void notify(List<Invoker<T>> invokers) {
249249
String key = providerApplication + RULE_SUFFIX;
250250
configuration.addListener(key, this);
251251
application = providerApplication;
252-
String rawRule = configuration.getRule(key, DynamicConfiguration.DEFAULT_GROUP);
252+
String rawRule = configuration.getConfig(key, DynamicConfiguration.DEFAULT_GROUP);
253253
if (StringUtils.isNotEmpty(rawRule)) {
254254
this.process(new ConfigChangeEvent(key, rawRule));
255255
}

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232

3333
import java.util.List;
3434

35-
import static org.apache.dubbo.rpc.cluster.Constants.INVOCATION_NEED_MOCK;
3635
import static org.apache.dubbo.rpc.Constants.MOCK_KEY;
36+
import static org.apache.dubbo.rpc.cluster.Constants.INVOCATION_NEED_MOCK;
3737

3838
public class MockClusterInvoker<T> implements Invoker<T> {
3939

0 commit comments

Comments
 (0)