Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the latest branch #9

Merged
merged 56 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8cafcab
combine test coverage report (#2643)
htynkn Oct 15, 2018
1ef1220
Optimize ut for serialization model. (#2632)
carryxyh Oct 15, 2018
393ffce
prototype for issue2570 (#2640)
beiwei30 Oct 16, 2018
d8282fe
[Dubbo -fix annotation bug] Fix @Reference bug (#2649)
zonghaishang Oct 17, 2018
b723837
Merge pull request #2656, make sure serialization exception sends bac…
beiwei30 Oct 19, 2018
c805c1d
#1903: supplemental change (#2666)
beiwei30 Oct 21, 2018
5e60bef
Optimize the doSelect method of RandomLoadBalance to reduce the times…
tswstarplanet Oct 21, 2018
dd950ac
解决与quartz集成报错问题 (#2677)
liunancun Oct 23, 2018
6938d48
Code format (#2662)
x-ultimate Oct 23, 2018
f2b6f07
Merge pull request#2679, consumer throws RpcException when RegistryDi…
beiwei30 Oct 24, 2018
7286e23
remove ServiceClassHolder and use the ApplicationModel replacedly (#2…
Jeff-Lv Oct 24, 2018
ac013b1
[Dubbo-1983] Support Protobuf Serialization (#2618)
kun-song Oct 26, 2018
910b261
Smooth Round Robin selection (#2650)
jasonjoo2010 Oct 26, 2018
b8bc80b
enhance pull request 2618 (#2691)
beiwei30 Oct 26, 2018
46f95bf
fix typo error in FAQ (#2684)
xuchuanyin Oct 26, 2018
a777aec
remove author info for RoundRobinLoadBalance (#2697)
jasonjoo2010 Oct 29, 2018
dba175a
fix pom for protostuff serialization (#2700)
beiwei30 Oct 29, 2018
99a00ba
Optimize REGISTRIES field in AbstractRegistryFactory. (#2703)
jingui123 Oct 30, 2018
36a1155
[version 2.7.0]remove the StaticContext class and refactor the code r…
Jeff-Lv Oct 30, 2018
e94d74b
Optimize heartbeat and reconnect task. (#2658)
carryxyh Oct 30, 2018
195c82d
polish the code for pull request 2658: Optimize heartbeat and reconne…
beiwei30 Oct 30, 2018
4d0a36c
重构 ServiceBean 的 isDelay 方法,使其更符合语义 (#2686)
code4wt Oct 30, 2018
0a116aa
【Unit Test】FailbackRegistry Test: recover method (#2591)
tswstarplanet Oct 30, 2018
c21cc05
replace ServiceAnnotationBeanPostProcessor log.isInfoEnabled->log.isW…
Oct 31, 2018
3cf801b
[Dubbo-2678][For Master] Add ability to turn off SPI auto injection, …
chickenlj Nov 1, 2018
0d51bc4
Merge pull request #2725, problems of graceful shutdown in 2.6.3 and …
beiwei30 Nov 5, 2018
505d155
enhance comments (#2735)
beiwei30 Nov 5, 2018
2284ede
code format (#2730)
x-ultimate Nov 5, 2018
16f7a1e
Close all servers/ports after tests finish (#2741)
OrDTesters Nov 6, 2018
aed0102
Simplify the code of StringUtils to make it more graceful. (#2740)
code4wt Nov 6, 2018
56b2193
Add 'forks' config into xml config (#2568)
carryxyh Nov 6, 2018
1a88c22
fix typo (#2747)
zonghaishang Nov 7, 2018
e3bd693
[DUBBO-2489] MockClusterInvoker provides local forced mock,I tested i…
beiwei30 Nov 7, 2018
b0107e7
#2748: Provider should disable mock configuration (#2749)
beiwei30 Nov 7, 2018
aa9f16e
Fix the bug that ReferenceBean refers service more than once when deb…
code4wt Nov 8, 2018
20a5efb
Close all servers/ports after tests finish (#2755)
OrDTesters Nov 8, 2018
a7cf737
add checkstyle rule to check import order (#2745)
htynkn Nov 8, 2018
dcbd326
Changing URL so tests can run in any order (#2760)
OrDTesters Nov 8, 2018
117d485
[Dubbo-2353]fix Invalid property 'interfaceName' of bean class [org.a…
kexianjun Nov 8, 2018
7f5fd46
#2762: [Dubbo - qos-http] stopServer should be invoked ? (#2767)
beiwei30 Nov 9, 2018
bff16eb
#2777: heartbeat threads blocks process shutdown (#2778)
beiwei30 Nov 13, 2018
38a6511
oschina vote (#2786)
beiwei30 Nov 14, 2018
b1a7622
fix typo (#2791)
kun-song Nov 16, 2018
9466425
improvement on Parameters and CollectionUtils (#2790)
kun-song Nov 16, 2018
026fa0b
[REFACTOR]:[fix typo] (#2804)
Ivan97 Nov 19, 2018
5ea6b33
[Dubbo-2798]fix apporiate NotWritablePropertyException (#2800)
kexianjun Nov 20, 2018
28b3736
[Dubbo-2758] Adding dependency on dubbo-remoting-mina for tests in du…
OrDTesters Nov 22, 2018
a24289f
modify dubbo version to 2.6.5
cvictory Nov 23, 2018
46b3458
fix typo of field (#2825)
likemoongg Nov 24, 2018
5aeb049
[Dubbo-2845] Fix OOM in UT testSelectByWeight (#2845) (#2846)
biyuhao Nov 29, 2018
bc6a06c
Fix UT failed on windows with FileNetworkerTest (#2848)
water-coder Nov 29, 2018
133d570
Update README.md
beiwei30 Dec 3, 2018
32140d4
fixed typo of variable (#2875)
zzkyeee Dec 4, 2018
d0f7c05
Remove unnessesary code in RegistryDirectory#doList (#2861)
LiZhenNet Dec 4, 2018
1f751a6
add some ScriptRoute test case (#2879)
lixiaojiee Dec 4, 2018
e8af04d
remove the duplicate superclass of TagRouter and ConditionRouter (#2885)
lixiaojiee Dec 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ For committers, make sure select the right label and target branch for every PR,

[Example question](https://github.com/alibaba/dubbo/issues/742)

Dubbo support to specify ip/port via system environment variables, examples can be found [here](https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-docker).
Dubbo supports specifying ip/port via system environment variables, examples can be found [here](https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-docker).
2 changes: 1 addition & 1 deletion PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ XXXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

- [x] Make sure there is a [GITHUB_issue](https://github.com/apache/incubator-dubbo/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a GITHUB issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
- [x] Make sure there is a [GITHUB_issue](https://github.com/apache/incubator-dubbo/issues) field for the change (usually before you start working on it). Trivial changes like typos do not require a GITHUB issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
- [ ] Format the pull request title like `[Dubbo-XXX] Fix UnknownException when host config not exist #XXX`. Each commit in the pull request should have a meaningful subject line and body.
- [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [ ] Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/incubator-dubbo/tree/master/dubbo-test).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ There's a [README](https://github.com/dubbo/dubbo-samples/blob/master/dubbo-samp
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.6.4</version>
<version>2.6.5</version>
</dependency>
```

Expand Down
6 changes: 6 additions & 0 deletions codestyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@
<module name="NoLineWrap"/>
<module name="OuterTypeFilename"/>
<module name="UnusedImports"/>

<module name="CustomImportOrder">
<property name="specialImportsRegExp" value="org.apache.dubbo.*"/>
<property name="sortImportsInGroupAlphabetically" value="false"/>
<property name="customImportOrderRules" value="SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###STATIC"/>
</module>
</module>
</module>
2 changes: 0 additions & 2 deletions codestyle/dubbo_codestyle_for_idea.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<value>
<package name="org.apache.dubbo" withSubpackages="true" static="false"/>
<emptyLine/>
<package name="com.taobao" withSubpackages="true" static="false"/>
<emptyLine/>
<package name="" withSubpackages="true" static="false"/>
<emptyLine/>
<package name="javax" withSubpackages="true" static="false"/>
Expand Down
6 changes: 3 additions & 3 deletions dubbo-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-bootstrap</artifactId>
<artifactId>dubbo-serialization-protostuff</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
Expand Down Expand Up @@ -431,7 +431,7 @@
<include>org.apache.dubbo:dubbo-serialization-fst</include>
<include>org.apache.dubbo:dubbo-serialization-kryo</include>
<include>org.apache.dubbo:dubbo-serialization-jdk</include>
<include>org.apache.dubbo:dubbo-bootstrap</include>
<include>org.apache.dubbo:dubbo-serialization-protostuff</include>
</includes>
</artifactSet>
<transformers>
Expand Down Expand Up @@ -595,4 +595,4 @@
</build>
</profile>
</profiles>
</project>
</project>
2 changes: 1 addition & 1 deletion dubbo-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-bootstrap</artifactId>
<artifactId>dubbo-serialization-protostuff</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public class RandomLoadBalance extends AbstractLoadBalance {
@Override
protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {
int length = invokers.size(); // Number of invokers
int totalWeight = 0; // The sum of weights
boolean sameWeight = true; // Every invoker has the same weight?
for (int i = 0; i < length; i++) {
int firstWeight = getWeight(invokers.get(0), invocation);
int totalWeight = firstWeight; // The sum of weights
for (int i = 1; i < length; i++) {
int weight = getWeight(invokers.get(i), invocation);
totalWeight += weight; // Sum
if (sameWeight && i > 0
&& weight != getWeight(invokers.get(i - 1), invocation)) {
if (sameWeight && weight != firstWeight) {
sameWeight = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,68 +17,137 @@
package org.apache.dubbo.rpc.cluster.loadbalance;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.AtomicPositiveInteger;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;

/**
* Round robin load balance.
*/
public class RoundRobinLoadBalance extends AbstractLoadBalance {

public static final String NAME = "roundrobin";

private static int RECYCLE_PERIOD = 60000;

protected static class WeightedRoundRobin {
private int weight;
private AtomicLong current = new AtomicLong(0);
private long lastUpdate;
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
current.set(0);
}
public long increaseCurrent() {
return current.addAndGet(weight);
}
public void sel(int total) {
current.addAndGet(-1 * total);
}
public long getLastUpdate() {
return lastUpdate;
}
public void setLastUpdate(long lastUpdate) {
this.lastUpdate = lastUpdate;
}
}

private final ConcurrentMap<String, AtomicPositiveInteger> sequences = new ConcurrentHashMap<String, AtomicPositiveInteger>();

private final ConcurrentMap<String, AtomicPositiveInteger> indexSeqs = new ConcurrentHashMap<String, AtomicPositiveInteger>();

private ConcurrentMap<String, ConcurrentMap<String, WeightedRoundRobin>> methodWeightMap = new ConcurrentHashMap<String, ConcurrentMap<String, WeightedRoundRobin>>();
private AtomicBoolean updateLock = new AtomicBoolean();

/**
* get invoker addr list cached for specified invocation
* <p>
* <b>for unit test only</b>
*
* @param invokers
* @param invocation
* @return
*/
protected <T> Collection<String> getInvokerAddrList(List<Invoker<T>> invokers, Invocation invocation) {
String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName();
Map<String, WeightedRoundRobin> map = methodWeightMap.get(key);
if (map != null) {
return map.keySet();
}
return null;
}

@Override
protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {
String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName();
int length = invokers.size(); // Number of invokers
int maxWeight = 0; // The maximum weight
int minWeight = Integer.MAX_VALUE; // The minimum weight
final List<Invoker<T>> nonZeroWeightedInvokers = new ArrayList<>();
for (int i = 0; i < length; i++) {
int weight = getWeight(invokers.get(i), invocation);
maxWeight = Math.max(maxWeight, weight); // Choose the maximum weight
minWeight = Math.min(minWeight, weight); // Choose the minimum weight
if (weight > 0) {
nonZeroWeightedInvokers.add(invokers.get(i));
}
}
AtomicPositiveInteger sequence = sequences.get(key);
if (sequence == null) {
sequences.putIfAbsent(key, new AtomicPositiveInteger());
sequence = sequences.get(key);
ConcurrentMap<String, WeightedRoundRobin> map = methodWeightMap.get(key);
if (map == null) {
methodWeightMap.putIfAbsent(key, new ConcurrentHashMap<String, WeightedRoundRobin>());
map = methodWeightMap.get(key);
}

if (maxWeight > 0 && minWeight < maxWeight) {
AtomicPositiveInteger indexSeq = indexSeqs.get(key);
if (indexSeq == null) {
indexSeqs.putIfAbsent(key, new AtomicPositiveInteger(-1));
indexSeq = indexSeqs.get(key);
int totalWeight = 0;
long maxCurrent = Long.MIN_VALUE;
long now = System.currentTimeMillis();
Invoker<T> selectedInvoker = null;
WeightedRoundRobin selectedWRR = null;
for (Invoker<T> invoker : invokers) {
String identifyString = invoker.getUrl().toIdentityString();
WeightedRoundRobin weightedRoundRobin = map.get(identifyString);
int weight = getWeight(invoker, invocation);
if (weight < 0) {
weight = 0;
}
length = nonZeroWeightedInvokers.size();
while (true) {
int index = indexSeq.incrementAndGet() % length;
int currentWeight;
if (index == 0) {
currentWeight = sequence.incrementAndGet() % maxWeight;
} else {
currentWeight = sequence.get() % maxWeight;
}
if (getWeight(nonZeroWeightedInvokers.get(index), invocation) > currentWeight) {
return nonZeroWeightedInvokers.get(index);
if (weightedRoundRobin == null) {
weightedRoundRobin = new WeightedRoundRobin();
weightedRoundRobin.setWeight(weight);
map.putIfAbsent(identifyString, weightedRoundRobin);
weightedRoundRobin = map.get(identifyString);
}
if (weight != weightedRoundRobin.getWeight()) {
//weight changed
weightedRoundRobin.setWeight(weight);
}
long cur = weightedRoundRobin.increaseCurrent();
weightedRoundRobin.setLastUpdate(now);
if (cur > maxCurrent) {
maxCurrent = cur;
selectedInvoker = invoker;
selectedWRR = weightedRoundRobin;
}
totalWeight += weight;
}
if (!updateLock.get() && invokers.size() != map.size()) {
if (updateLock.compareAndSet(false, true)) {
try {
// copy -> modify -> update reference
ConcurrentMap<String, WeightedRoundRobin> newMap = new ConcurrentHashMap<String, WeightedRoundRobin>();
newMap.putAll(map);
Iterator<Entry<String, WeightedRoundRobin>> it = newMap.entrySet().iterator();
while (it.hasNext()) {
Entry<String, WeightedRoundRobin> item = it.next();
if (now - item.getValue().getLastUpdate() > RECYCLE_PERIOD) {
it.remove();
}
}
methodWeightMap.put(key, newMap);
} finally {
updateLock.set(false);
}
}
}
// Round robin
return invokers.get(sequence.getAndIncrement() % length);
if (selectedInvoker != null) {
selectedWRR.sel(totalWeight);
return selectedInvoker;
}
// should not happen here
return invokers.get(0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* ConditionRouter
*
*/
public class ConditionRouter implements Router, Comparable<Router> {
public class ConditionRouter implements Router {

private static final Logger logger = LoggerFactory.getLogger(ConditionRouter.class);
private static Pattern ROUTE_PATTERN = Pattern.compile("([&!=,]*)\\s*([^&!=,\\s]+)");
Expand Down
Loading