Skip to content

Commit 2911b31

Browse files
committed
Merge branch 'upsteam' into feature-trace
2 parents 160bb40 + ddb518d commit 2911b31

File tree

378 files changed

+18166
-3942
lines changed

Some content is hidden

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

378 files changed

+18166
-3942
lines changed

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Apache Dubbo (incubating)
2-
Copyright 2018 The Apache Software Foundation
2+
Copyright 2018-2019 The Apache Software Foundation
33

44
This product includes software developed at
55
The Apache Software Foundation (http://www.apache.org/).

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/apache/incubator-dubbo.svg)](http://isitmaintained.com/project/apache/incubator-dubbo "Average time to resolve an issue")
88
[![Percentage of issues still open](http://isitmaintained.com/badge/open/apache/incubator-dubbo.svg)](http://isitmaintained.com/project/apache/incubator-dubbo "Percentage of issues still open")
99
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Apache%20Dubbo%20(incubating)%20is%20a%20high-performance%2C%20java%20based%2C%20open%20source%20RPC%20framework.&url=http://dubbo.incubator.apache.org/&via=ApacheDubbo&hashtags=rpc,java,dubbo,micro-service)
10+
[![](https://img.shields.io/twitter/follow/ApacheDubbo.svg?label=Follow&style=social&logoWidth=0)](https://twitter.com/intent/follow?screen_name=ApacheDubbo)
1011
[![Gitter](https://badges.gitter.im/alibaba/dubbo.svg)](https://gitter.im/alibaba/dubbo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
1112

1213
Apache Dubbo (incubating) is a high-performance, Java based open source RPC framework. Please visit [official site](http://dubbo.incubator.apache.org) for quick start and documentations, as well as [Wiki](https://github.com/apache/incubator-dubbo/wiki) for news, FAQ, and release notes.

codestyle/checkstyle.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
<module name="OuterTypeFilename"/>
2222
<module name="UnusedImports"/>
2323

24-
<module name="CustomImportOrder">
25-
<property name="specialImportsRegExp" value="org.apache.dubbo.*"/>
26-
<property name="sortImportsInGroupAlphabetically" value="false"/>
27-
<property name="customImportOrderRules" value="SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###STATIC"/>
28-
</module>
24+
<!--<module name="CustomImportOrder">-->
25+
<!--<property name="specialImportsRegExp" value="org.apache.dubbo.*"/>-->
26+
<!--<property name="sortImportsInGroupAlphabetically" value="false"/>-->
27+
<!--<property name="customImportOrderRules" value="SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###STATIC"/>-->
28+
<!--</module>-->
2929
</module>
3030
</module>

dubbo-all/pom.xml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,27 @@
325325
<scope>compile</scope>
326326
<optional>true</optional>
327327
</dependency>
328+
<dependency>
329+
<groupId>org.apache.dubbo</groupId>
330+
<artifactId>dubbo-configcenter-api</artifactId>
331+
<version>${project.version}</version>
332+
<scope>compile</scope>
333+
<optional>true</optional>
334+
</dependency>
335+
<dependency>
336+
<groupId>org.apache.dubbo</groupId>
337+
<artifactId>dubbo-configcenter-zookeeper</artifactId>
338+
<version>${project.version}</version>
339+
<scope>compile</scope>
340+
<optional>true</optional>
341+
</dependency>
342+
<dependency>
343+
<groupId>org.apache.dubbo</groupId>
344+
<artifactId>dubbo-configcenter-apollo</artifactId>
345+
<version>${project.version}</version>
346+
<scope>compile</scope>
347+
<optional>true</optional>
348+
</dependency>
328349
<dependency>
329350
<groupId>org.apache.dubbo</groupId>
330351
<artifactId>dubbo-compatible</artifactId>
@@ -338,6 +359,28 @@
338359
<scope>compile</scope>
339360
<optional>true</optional>
340361
</dependency>
362+
<!-- metadata -->
363+
<dependency>
364+
<groupId>org.apache.dubbo</groupId>
365+
<artifactId>dubbo-metadata-report-api</artifactId>
366+
<version>${project.version}</version>
367+
<scope>compile</scope>
368+
<optional>true</optional>
369+
</dependency>
370+
<dependency>
371+
<groupId>org.apache.dubbo</groupId>
372+
<artifactId>dubbo-metadata-report-zookeeper</artifactId>
373+
<version>${project.version}</version>
374+
<scope>compile</scope>
375+
<optional>true</optional>
376+
</dependency>
377+
<dependency>
378+
<groupId>org.apache.dubbo</groupId>
379+
<artifactId>dubbo-metadata-report-redis</artifactId>
380+
<version>${project.version}</version>
381+
<scope>compile</scope>
382+
<optional>true</optional>
383+
</dependency>
341384

342385
<!-- Transitive dependencies -->
343386
<dependency>
@@ -432,6 +475,15 @@
432475
<include>org.apache.dubbo:dubbo-serialization-kryo</include>
433476
<include>org.apache.dubbo:dubbo-serialization-jdk</include>
434477
<include>org.apache.dubbo:dubbo-serialization-protostuff</include>
478+
<include>org.apache.dubbo:dubbo-configcenter-api</include>
479+
<include>org.apache.dubbo:dubbo-configcenter-definition</include>
480+
<include>org.apache.dubbo:dubbo-configcenter-apollo</include>
481+
<include>org.apache.dubbo:dubbo-configcenter-zookeeper</include>
482+
<include>org.apache.dubbo:dubbo-metadata-report-api</include>
483+
<include>org.apache.dubbo:dubbo-metadata-definition</include>
484+
<include>org.apache.dubbo:dubbo-metadata-report-redis</include>
485+
<include>org.apache.dubbo:dubbo-metadata-report-zookeeper</include>
486+
<include>com.google.code.gson:gson</include>
435487
</includes>
436488
</artifactSet>
437489
<transformers>
@@ -549,6 +601,11 @@
549601
<resource>META-INF/dubbo/internal/org.apache.dubbo.qos.command.BaseCommand
550602
</resource>
551603
</transformer>
604+
<transformer
605+
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
606+
<resource>META-INF/dubbo/internal/org.apache.dubbo.configcenter.DynamicConfiguration
607+
</resource>
608+
</transformer>
552609
</transformers>
553610
</configuration>
554611
</execution>

dubbo-bom/pom.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,41 @@
288288
<artifactId>dubbo-compatible</artifactId>
289289
<version>${project.version}</version>
290290
</dependency>
291+
<dependency>
292+
<groupId>org.apache.dubbo</groupId>
293+
<artifactId>dubbo-metadata-report-api</artifactId>
294+
<version>${project.version}</version>
295+
</dependency>
296+
<dependency>
297+
<groupId>org.apache.dubbo</groupId>
298+
<artifactId>dubbo-metadata-report-zookeeper</artifactId>
299+
<version>${project.version}</version>
300+
</dependency>
301+
<dependency>
302+
<groupId>org.apache.dubbo</groupId>
303+
<artifactId>dubbo-metadata-report-redis</artifactId>
304+
<version>${project.version}</version>
305+
</dependency>
306+
<dependency>
307+
<groupId>org.apache.dubbo</groupId>
308+
<artifactId>dubbo-configcenter-api</artifactId>
309+
<version>${project.version}</version>
310+
</dependency>
311+
<dependency>
312+
<groupId>org.apache.dubbo</groupId>
313+
<artifactId>dubbo-configcenter-zookeeper</artifactId>
314+
<version>${project.version}</version>
315+
</dependency>
316+
<dependency>
317+
<groupId>org.apache.dubbo</groupId>
318+
<artifactId>dubbo-configcenter-apollo</artifactId>
319+
<version>${project.version}</version>
320+
</dependency>
321+
<dependency>
322+
<groupId>org.apache.dubbo</groupId>
323+
<artifactId>dubbo-metadata-definition</artifactId>
324+
<version>${project.version}</version>
325+
</dependency>
291326
</dependencies>
292327
</dependencyManagement>
293328

dubbo-cluster/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,25 @@
3434
<artifactId>dubbo-rpc-api</artifactId>
3535
<version>${project.parent.version}</version>
3636
</dependency>
37+
<dependency>
38+
<groupId>org.apache.dubbo</groupId>
39+
<artifactId>dubbo-configcenter-api</artifactId>
40+
<version>${project.parent.version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.yaml</groupId>
44+
<artifactId>snakeyaml</artifactId>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>org.apache.curator</groupId>
49+
<artifactId>curator-framework</artifactId>
50+
<scope>test</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.apache.zookeeper</groupId>
54+
<artifactId>zookeeper</artifactId>
55+
<scope>test</scope>
56+
</dependency>
3757
</dependencies>
3858
</project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.dubbo.rpc.cluster;
18+
19+
import org.apache.dubbo.common.URL;
20+
21+
import java.util.concurrent.ConcurrentHashMap;
22+
import java.util.concurrent.ConcurrentMap;
23+
24+
/**
25+
* If you want to provide a router implementation based on design of v2.7.0, please extend from this abstract class.
26+
* For 2.6.x style router, please implement and use RouterFactory directly.
27+
*/
28+
public abstract class CacheableRouterFactory implements RouterFactory {
29+
private ConcurrentMap<String, Router> routerMap = new ConcurrentHashMap<>();
30+
31+
@Override
32+
public Router getRouter(URL url) {
33+
routerMap.computeIfAbsent(url.getServiceKey(), k -> createRouter(url));
34+
return routerMap.get(url.getServiceKey());
35+
}
36+
37+
protected abstract Router createRouter(URL url);
38+
}

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/Configurator.java

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@
1616
*/
1717
package org.apache.dubbo.rpc.cluster;
1818

19+
import org.apache.dubbo.common.Constants;
1920
import org.apache.dubbo.common.URL;
21+
import org.apache.dubbo.common.extension.ExtensionLoader;
22+
import org.apache.dubbo.common.utils.CollectionUtils;
23+
24+
import java.util.ArrayList;
25+
import java.util.Collections;
26+
import java.util.HashMap;
27+
import java.util.List;
28+
import java.util.Map;
29+
import java.util.Optional;
2030

2131
/**
2232
* Configurator. (SPI, Prototype, ThreadSafe)
@@ -25,19 +35,82 @@
2535
public interface Configurator extends Comparable<Configurator> {
2636

2737
/**
28-
* get the configurator url.
38+
* Get the configurator url.
2939
*
3040
* @return configurator url.
3141
*/
3242
URL getUrl();
3343

3444
/**
3545
* Configure the provider url.
36-
* O
3746
*
38-
* @param url - old rovider url.
47+
* @param url - old provider url.
3948
* @return new provider url.
4049
*/
4150
URL configure(URL url);
4251

52+
53+
/**
54+
* Convert override urls to map for use when re-refer. Send all rules every time, the urls will be reassembled and
55+
* calculated
56+
*
57+
* URL contract:
58+
* <ol>
59+
* <li>override://0.0.0.0/...( or override://ip:port...?anyhost=true)&para1=value1... means global rules
60+
* (all of the providers take effect)</li>
61+
* <li>override://ip:port...?anyhost=false Special rules (only for a certain provider)</li>
62+
* <li>override:// rule is not supported... ,needs to be calculated by registry itself</li>
63+
* <li>override://0.0.0.0/ without parameters means clearing the override</li>
64+
* </ol>
65+
*
66+
* @param urls URL list to convert
67+
* @return converted configurator list
68+
*/
69+
static Optional<List<Configurator>> toConfigurators(List<URL> urls) {
70+
if (CollectionUtils.isEmpty(urls)) {
71+
return Optional.empty();
72+
}
73+
74+
ConfiguratorFactory configuratorFactory = ExtensionLoader.getExtensionLoader(ConfiguratorFactory.class)
75+
.getAdaptiveExtension();
76+
77+
List<Configurator> configurators = new ArrayList<>(urls.size());
78+
for (URL url : urls) {
79+
if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) {
80+
configurators.clear();
81+
break;
82+
}
83+
Map<String, String> override = new HashMap<>(url.getParameters());
84+
//The anyhost parameter of override may be added automatically, it can't change the judgement of changing url
85+
override.remove(Constants.ANYHOST_KEY);
86+
if (override.size() == 0) {
87+
configurators.clear();
88+
continue;
89+
}
90+
configurators.add(configuratorFactory.getConfigurator(url));
91+
}
92+
Collections.sort(configurators);
93+
return Optional.of(configurators);
94+
}
95+
96+
/**
97+
* Sort by host, then by priority
98+
* 1. the url with a specific host ip should have higher priority than 0.0.0.0
99+
* 2. if two url has the same host, compare by priority value;
100+
*/
101+
default int compareTo(Configurator o) {
102+
if (o == null) {
103+
return -1;
104+
}
105+
106+
int ipCompare = getUrl().getHost().compareTo(o.getUrl().getHost());
107+
// host is the same, sort by priority
108+
if (ipCompare == 0) {
109+
int i = getUrl().getParameter(Constants.PRIORITY_KEY, 0);
110+
int j = o.getUrl().getParameter(Constants.PRIORITY_KEY, 0);
111+
return Integer.compare(i, j);
112+
} else {
113+
return ipCompare;
114+
}
115+
}
43116
}

0 commit comments

Comments
 (0)