Skip to content

Commit

Permalink
test1 (#7)
Browse files Browse the repository at this point in the history
* combine test coverage report (apache#2643)

* Optimize ut for serialization model. (apache#2632)

* 1. Integrate the unit test of the serialization module, code reuse.
2. Remove redundant unit tests and pojo classes.
3. Remove the useless pojo class in the common module.

* fix ci fail

* fix ci fail

* fix ci fail

* fix ci fail

* remove author info

* prototype for issue2570 (apache#2640)

* apache#2570: dubbo all in one fail to start from a tomcat server when spring framework is absent

* add comments and fix unit test

* add license header

* update comments in unit tests

* [Dubbo -fix annotation bug] Fix @reference bug (apache#2649)

It's fine.

* Merge pull request apache#2656, make sure serialization exception sends back to consumer to preventing endless waiting.

Fixes apache#1903: Our customized serialization id exceeds the maximum limit, now it cannot work on 2.6.2 anymore.

*     apache#1903: supplemental change (apache#2666)

* Optimize the doSelect method of RandomLoadBalance to reduce the times of invoke of the getWeight method of the AbstractLoadBalance (apache#2597)

* 解决与quartz集成报错问题 (apache#2677)

quartz初始化的Bean没有beanName,beanName=null,走这段代码的时候报空指针了。
org.springframework.boot.autoconfigure.quartz.AutowireCapableBeanJobFactory类的createJobInstance方法中使用this.beanFactory.initializeBean(jobInstance, null);初始化的Bean,其beanName=null。

* Code format (apache#2662)

* NullPointerException

* code rule

* Merge pull request#2679, consumer throws RpcException when RegistryDirectory notify in high QPS.

Fixes apache#2016

* remove ServiceClassHolder and use the ApplicationModel replacedly (apache#2646)

* [Dubbo] move the classes of model from config to rpc-api for reusing

* remove ServiceClassHolder and use the ApplicationModel replacedly

* [Dubbo] delete the unused imported of ApplicationModel

* Update dubbo-demo-consumer.xml

this commits is no need to commit to remote repo.

* [Dubbo-1983] Support Protobuf Serialization (apache#2618)

* finish support protobuf

* polish

* fix code review

* use the general test for serialization

* Smooth Round Robin selection (apache#2650)

* enhance pull request 2618 (apache#2691)

* enhance pull request 2618

* move spi file into the right directory

* ignore protostuff test case

* make unit test pass, support Time type

* fix useless imports issue

* add license header

* fix typo error in FAQ (apache#2684)

fix typo error in FAQ

* remove author info for RoundRobinLoadBalance (apache#2697)

* fix pom for protostuff serialization (apache#2700)

* Optimize REGISTRIES field in AbstractRegistryFactory. (apache#2703)

* modify ConcurrentHashMap to HashMap.这里REGISTRIES在使用的时候都会先加锁,不存在多线程安全的问题。所以这里建议使用hashmap

* modify ConcurrentHashMap to HashMap.这里REGISTRIES在使用的时候都会先加锁,不存在多线程安全的问题。所以这里建议使用hashmap

* [version 2.7.0]remove the StaticContext class and refactor the code related to Async (apache#2688)

* [Dubbo] move the classes of model from config to rpc-api for reusing

* remove ServiceClassHolder and use the ApplicationModel replacedly

* [Dubbo] delete the unused imported of ApplicationModel

* Update dubbo-demo-consumer.xml

this commits is no need to commit to remote repo.

* remove StaticContext

* remove the unused imported classes of ReferenceConfig

* fix NPE of ConsumerModel

* fix the failed testcase of AbstractClusterInvokerTest

* [Dubbo] #PR2688 to fix the review issues

* Optimize heartbeat and reconnect task. (apache#2658)

* Optimize heartbeat and reconnect task.
1.Use hashedWheelTimer.
2.Distinguish between reconnect and heartbeat.
3.Increase inspection cycle.

* fix ci fail.

* fix ci fail.

* fix ci fail.

* polish the code for pull request 2658: Optimize heartbeat and reconnect task (apache#2709)

* 重构 ServiceBean 的 isDelay 方法,使其更符合语义 (apache#2686)

* Refactor method isDelay of ServiceBean to fix the wrong meaning of the method

* Remove unnecessary method isDelay of ServiceBean

* 【Unit Test】FailbackRegistry Test: recover method (apache#2591)

* FailbackRegistry Test: recover method

* fix the type error, and use CountDownLatch await method to fix the unstable problom

* trigger the travis ci test retry

* trigger the code static check again

* replace ServiceAnnotationBeanPostProcessor log.isInfoEnabled->log.isWarnEnabled (apache#2712)

simplify ExtensionLoader code segment

* [Dubbo-2678][For Master] Add ability to turn off SPI auto injection, special support for Object type.  (apache#2682)

* Add ability to turn off SPI auto injection, special support for generic Object type injection.

* Change Inject to AutoInject since it's main purpose is to turn off auto-injection.

* disable is redundant in DisableInject annotation

* Merge pull request apache#2725, problems of graceful shutdown in 2.6.3 and some recommendation.

* enhance comments (apache#2735)

* code format (apache#2730)

* NullPointerException

* code rule

* code rule

* Close all servers/ports after tests finish (apache#2741)

*  Simplify the code of StringUtils to make it more graceful. (apache#2740)

* Simplify the code of StringUtils to make it more graceful.

* Add Apache license

* Add 'forks' config into xml config (apache#2568)

* Add forks into xml config.

* Add forks into xml config.

* Add forks into xml config.

* fix typo (apache#2747)

* [DUBBO-2489] MockClusterInvoker provides local forced mock,I tested it locally, but it doesn't work (apache#2742)

*     apache#2748: Provider should disable mock configuration (apache#2749)

* Fix the bug that ReferenceBean refers service more than once when debugging. (apache#2754)

note:
please visit http://t.cn/EAhta27 for more detail.

* Close all servers/ports after tests finish (apache#2755)

* add checkstyle rule to check import order (apache#2745)

* Changing URL so tests can run in any order (apache#2760)

* [Dubbo-2353]fix Invalid property 'interfaceName' of bean class [org.apache.dubbo.config.spring.ServiceBean]apache#2353 (apache#2418)

* add getter and setter for ServiceConfig's interfaceName property#2353

* add interfaceName to ignoreAttributeNames and change the unit test

* delete the demo source code and update the unit test

* unchange ServiceConfig

* update unit test

* update unit test

*     apache#2762: [Dubbo - qos-http] stopServer should be invoked ? (apache#2767)

*     apache#2777: heartbeat threads blocks process shutdown (apache#2778)

Fix heartbeat threads blocks process shutdown because its hashed-wheel-timer is non-daemon thread.

* oschina vote (apache#2786)

* fix typo (apache#2791)

Fix typo confilict -> conflict

* improvement on Parameters and CollectionUtils (apache#2790)

Use CollectionUtils.toStringMap to reduce duplicate code in Parameters, and use Java 8 type inference for collections.

* [REFACTOR]:[fix typo] (apache#2804)

fix typos

* [Dubbo-2798]fix apporiate NotWritablePropertyException (apache#2800)

fix apache#2798 .
'propertyname in java donot contain '-' but camel format'.

* [Dubbo-2758] Adding dependency on dubbo-remoting-mina for tests in dubbo-rpc-dubbo (apache#2797)

* Adding dependency on dubbo-remoting-mina so DubboProtocolTest.testDubboProtocolWithMina is no longer flaky

* Changing port number to ensure new server/client created for test

* modify dubbo version to 2.6.5

* fix typo of field (apache#2825)

* [Dubbo-2845] Fix OOM in UT testSelectByWeight (apache#2845) (apache#2846)

Fix OOM Exception generated during UT

* Fix UT failed on windows with FileNetworkerTest (apache#2848)

Fix FileNetworkerTest failure

* Update README.md

remove oschina vote

* fixed typo of variable (apache#2875)

fixed type of variable

* Remove unnessesary code  in RegistryDirectory#doList (apache#2861)

* remove unnessesary code

* remove unused import

* add some ScriptRoute test case (apache#2879)

* add router test case

* correct an error word

* remove the duplicate superclass of TagRouter and ConditionRouter (apache#2885)

Remove the class ConditionRouter and TagRouter implement duplicate superclass Comparable
  • Loading branch information
CrazyHZM authored Dec 6, 2018
1 parent 45b3ab4 commit 5c8827f
Show file tree
Hide file tree
Showing 340 changed files with 5,258 additions and 9,218 deletions.
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

0 comments on commit 5c8827f

Please sign in to comment.