Skip to content

Commit ad7c7cf

Browse files
authored
Merge pull request #10 from apache/master
master sync
2 parents a868472 + fda71e7 commit ad7c7cf

File tree

569 files changed

+8495
-6363
lines changed

Some content is hidden

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

569 files changed

+8495
-6363
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.

dubbo-all/pom.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,16 @@
398398

399399
<!-- Temporarily add this part to exclude transitive dependency -->
400400
<dependency>
401-
<groupId>junit</groupId>
402-
<artifactId>junit</artifactId>
403-
<version>${junit_version}</version>
401+
<groupId>org.junit.jupiter</groupId>
402+
<artifactId>junit-jupiter-engine</artifactId>
403+
<version>${junit_jupiter_version}</version>
404+
<scope>test</scope>
405+
</dependency>
406+
<dependency>
407+
<groupId>org.junit.jupiter</groupId>
408+
<artifactId>junit-jupiter-params</artifactId>
409+
<version>${junit_jupiter_version}</version>
404410
<scope>test</scope>
405-
<optional>true</optional>
406411
</dependency>
407412
<dependency>
408413
<groupId>cglib</groupId>

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

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,36 @@
3535
public interface Configurator extends Comparable<Configurator> {
3636

3737
/**
38-
* get the configurator url.
38+
* Get the configurator url.
3939
*
4040
* @return configurator url.
4141
*/
4242
URL getUrl();
4343

4444
/**
4545
* Configure the provider url.
46-
* O
4746
*
48-
* @param url - old rovider url.
47+
* @param url - old provider url.
4948
* @return new provider url.
5049
*/
5150
URL configure(URL url);
5251

5352

5453
/**
55-
* Convert override urls to map for use when re-refer.
56-
* Send all rules every time, the urls will be reassembled and calculated
54+
* Convert override urls to map for use when re-refer. Send all rules every time, the urls will be reassembled and
55+
* calculated
5756
*
58-
* @param urls Contract:
59-
* </br>1.override://0.0.0.0/...( or override://ip:port...?anyhost=true)&para1=value1... means global rules (all of the providers take effect)
60-
* </br>2.override://ip:port...?anyhost=false Special rules (only for a certain provider)
61-
* </br>3.override:// rule is not supported... ,needs to be calculated by registry itself.
62-
* </br>4.override://0.0.0.0/ without parameters means clearing the override
63-
* @return
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
6468
*/
6569
static Optional<List<Configurator>> toConfigurators(List<URL> urls) {
6670
if (CollectionUtils.isEmpty(urls)) {
@@ -70,13 +74,13 @@ static Optional<List<Configurator>> toConfigurators(List<URL> urls) {
7074
ConfiguratorFactory configuratorFactory = ExtensionLoader.getExtensionLoader(ConfiguratorFactory.class)
7175
.getAdaptiveExtension();
7276

73-
List<Configurator> configurators = new ArrayList<Configurator>(urls.size());
77+
List<Configurator> configurators = new ArrayList<>(urls.size());
7478
for (URL url : urls) {
7579
if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) {
7680
configurators.clear();
7781
break;
7882
}
79-
Map<String, String> override = new HashMap<String, String>(url.getParameters());
83+
Map<String, String> override = new HashMap<>(url.getParameters());
8084
//The anyhost parameter of override may be added automatically, it can't change the judgement of changing url
8185
override.remove(Constants.ANYHOST_KEY);
8286
if (override.size() == 0) {
@@ -88,4 +92,25 @@ static Optional<List<Configurator>> toConfigurators(List<URL> urls) {
8892
Collections.sort(configurators);
8993
return Optional.of(configurators);
9094
}
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+
}
91116
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ public void initWithRouters(List<Router> builtinRouters) {
6767
this.sort();
6868
}
6969

70-
public void addRouter(Router router) {
71-
this.routers.add(router);
72-
}
73-
7470
/**
7571
* If we use route:// protocol in version before 2.7.0, each URL will generate a Router instance, so we should
7672
* keep the routers up to date, that is, each time router URLs changes, we should update the routers list, only

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/configurator/AbstractConfigurator.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,32 +131,6 @@ private URL configureIfMatch(String host, URL url) {
131131
return url;
132132
}
133133

134-
/**
135-
* Sort by host, priority
136-
* 1. the url with a specific host ip should have higher priority than 0.0.0.0
137-
* 2. if two url has the same host, compare by priority value;
138-
*
139-
* @param o
140-
* @return
141-
*/
142-
@Override
143-
public int compareTo(Configurator o) {
144-
if (o == null) {
145-
return -1;
146-
}
147-
148-
int ipCompare = getUrl().getHost().compareTo(o.getUrl().getHost());
149-
if (ipCompare == 0) {//host is the same, sort by priority
150-
int i = getUrl().getParameter(Constants.PRIORITY_KEY, 0),
151-
j = o.getUrl().getParameter(Constants.PRIORITY_KEY, 0);
152-
return Integer.compare(i, j);
153-
} else {
154-
return ipCompare;
155-
}
156-
157-
158-
}
159-
160134
protected abstract URL doConfigure(URL currentUrl, URL configUrl);
161135

162136
}

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/configurator/parser/ConfigParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private static String toParameterString(ConfigItem item) {
130130
sb.append(item.getSide());
131131
}
132132
Map<String, String> parameters = item.getParameters();
133-
if (parameters == null || parameters.isEmpty()) {
133+
if (CollectionUtils.isEmptyMap(parameters)) {
134134
throw new IllegalStateException("Invalid configurator rule, please specify at least one parameter " +
135135
"you want to change in the rule.");
136136
}

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.apache.dubbo.rpc.cluster.Router;
2929
import org.apache.dubbo.rpc.cluster.RouterChain;
3030

31-
import java.util.ArrayList;
31+
import java.util.Collections;
3232
import java.util.List;
3333
import java.util.Map;
3434

@@ -96,8 +96,7 @@ public void setRouterChain(RouterChain<T> routerChain) {
9696
}
9797

9898
protected void addRouters(List<Router> routers) {
99-
// copy list
100-
routers = routers == null ? new ArrayList<>() : new ArrayList<>(routers);
99+
routers = routers == null ? Collections.emptyList() : routers;
101100
routerChain.addRouters(routers);
102101
}
103102

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectory.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.apache.dubbo.common.URL;
2020
import org.apache.dubbo.common.logger.Logger;
2121
import org.apache.dubbo.common.logger.LoggerFactory;
22+
import org.apache.dubbo.common.utils.CollectionUtils;
2223
import org.apache.dubbo.rpc.Invocation;
2324
import org.apache.dubbo.rpc.Invoker;
2425
import org.apache.dubbo.rpc.RpcException;
@@ -29,7 +30,6 @@
2930

3031
/**
3132
* StaticDirectory
32-
*
3333
*/
3434
public class StaticDirectory<T> extends AbstractDirectory<T> {
3535
private static final Logger logger = LoggerFactory.getLogger(StaticDirectory.class);
@@ -49,9 +49,10 @@ public StaticDirectory(URL url, List<Invoker<T>> invokers) {
4949
}
5050

5151
public StaticDirectory(URL url, List<Invoker<T>> invokers, RouterChain<T> routerChain) {
52-
super(url == null && invokers != null && !invokers.isEmpty() ? invokers.get(0).getUrl() : url, routerChain);
53-
if (invokers == null || invokers.isEmpty())
52+
super(url == null && CollectionUtils.isNotEmpty(invokers) ? invokers.get(0).getUrl() : url, routerChain);
53+
if (CollectionUtils.isEmpty(invokers)) {
5454
throw new IllegalArgumentException("invokers == null");
55+
}
5556
this.invokers = invokers;
5657
}
5758

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.dubbo.common.Constants;
2020
import org.apache.dubbo.common.URL;
21+
import org.apache.dubbo.common.utils.CollectionUtils;
2122
import org.apache.dubbo.rpc.Invocation;
2223
import org.apache.dubbo.rpc.Invoker;
2324
import org.apache.dubbo.rpc.cluster.LoadBalance;
@@ -44,7 +45,7 @@ static int calculateWarmupWeight(int uptime, int warmup, int weight) {
4445

4546
@Override
4647
public <T> Invoker<T> select(List<Invoker<T>> invokers, URL url, Invocation invocation) {
47-
if (invokers == null || invokers.isEmpty()) {
48+
if (CollectionUtils.isEmpty(invokers)) {
4849
return null;
4950
}
5051
if (invokers.size() == 1) {

0 commit comments

Comments
 (0)