Skip to content

Commit

Permalink
Merge alibaba/dubbo/master to myself repo (#4)
Browse files Browse the repository at this point in the history
* @reference support annotate on annotation type

* Fixes apache#1303 TimeUnit conversion error

* Fixes apache#1289, use bind_port as mapping key

* Fixes apache#1313, remove destroy check in Registry.

* checkout .travis.yml from origin/master

* Fix hessian2 serialized short, byte is converted to int bug (apache#1232)

* Fix hessian2 serialized short, byte is converted to int bug

* Fix hessian2 serialized short, byte is converted to int bug

* adapt jdk1.5+

* fixed travis-ci failed because of test cases. (apache#1370)

* Merge pull request apache#1377, remove redundant arguments for StatItem.isAllowable()

* Merge pull request apache#1378, replace StringBuider with simple string concatenation in log.

* Merge pull request apache#1375, remove unnecessary boxing.

Fixes apache#1245

* Merge pull request apache#1331, add optional parameter to support hessian protocol method overload and request protocol version.

* Merge pull request apache#1376, do not instantiate load balance if there is no invokers

Fixes apache#1297

* Merge pull request apache#1384, fix build string bug.

* Merge pull request apache#1040, refactor: replace some deprecated methods related with jedis.

* Merge pull request apache#1242, remove redundant null check.

fixes apache#1231

* Change Mailing list address

* Fixed apache#1398, revert bugs introduced from apache#1375

* Fix time unit problem in UT

* Fix time unit problem related with FutureAdapter in UT

* Fix time unit problem related with FutureAdapter in UT

* Merge pull request apache#1391, fix typo of method name in qos module.

* fix hessian lite test case fail bug (apache#1394)

* fix hessian lite test case fail bug

* update test

* remove ignore

* Fix time unit problem related with FutureAdapter in UT

* revert file

* fix number type is lost in yaml config file (apache#1401)

* apache#1399 fi

* update test

* update readme to add some details (apache#1403)

* update readme to add some details

update readme to add some details

* delete duplicated words

delete duplicated words

* update README format

*     apache#1411: Locale deserialize 'zh-hant_CN'
  • Loading branch information
诣极 ( yì jí ) authored Mar 2, 2018
1 parent 16bac78 commit a3b8d73
Show file tree
Hide file tree
Showing 47 changed files with 814 additions and 286 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ We are now collecting dubbo user info in order to help us to improve dubbo bette

* [Side projects](http://github.com/dubbo)
* [Dubbo Spring Boot](https://github.com/dubbo/dubbo-spring-boot-project) - Spring Boot Project for Dubbo.
* [Dubbo ops](https://github.com/dubbo/dubbo-ops) - The reference implementation for dubbo ops.
* [Gitter channel](https://gitter.im/alibaba/dubbo)
* [Mailing list](https://groups.google.com/forum/#!forum/dubbo)
* [Dubbo user manual](http://dubbo.io/books/dubbo-user-book/)
* [Dubbo developer guide](http://dubbo.io/books/dubbo-dev-book/)
* [Dubbo admin manual](http://dubbo.io/books/dubbo-admin-book/)
* [Dubbo ops](https://github.com/dubbo/dubbo-ops) - The reference implementation for dubbo ops(dubbo-admin,dubbo-monitor-simple,dubbo-registry-simple,etc.).
* [Developer Mailing list](https://github.com/alibaba/dubbo/issues/1393) - Any questions or suggestions? Subscribe to ([email protected]) to discuss with us.
* [Gitter channel](https://gitter.im/alibaba/dubbo) - Online chat room with Dubbo developers.
* [Dubbo user manual](http://dubbo.io/books/dubbo-user-book/) - Describe how to use Dubbo and all features of Dubbo concretely.
* [Dubbo developer guide](http://dubbo.io/books/dubbo-dev-book/) - Detailly introduce the design principal, extension mechanisms, code conventions, version control and building project, etc.
* [Dubbo admin manual](http://dubbo.io/books/dubbo-admin-book/) - Describe how to use Dubbo registry and admin-console.
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,18 @@ public void destroy() {

/**
* Select a invoker using loadbalance policy.</br>
* a)Firstly, select an invoker using loadbalance. If this invoker is in previously selected list, or, if this invoker is unavailable, then continue step b (reselect), otherwise return the first selected invoker</br>
* b)Reslection, the validation rule for reselection: selected > available. This rule guarantees that the selected invoker has the minimum chance to be one in the previously selected list, and also guarantees this invoker is available.
* a)Firstly, select an invoker using loadbalance. If this invoker is in previously selected list, or,
* if this invoker is unavailable, then continue step b (reselect), otherwise return the first selected invoker</br>
* b)Reslection, the validation rule for reselection: selected > available. This rule guarantees that
* the selected invoker has the minimum chance to be one in the previously selected list, and also
* guarantees this invoker is available.
*
* @param loadbalance load balance policy
* @param invocation
* @param invokers invoker candidates
* @param selected exclude selected invokers or not
* @return
* @throws RpcExceptione
* @throws RpcException
*/
protected Invoker<T> select(LoadBalance loadbalance, Invocation invocation, List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
if (invokers == null || invokers.isEmpty())
Expand All @@ -109,22 +112,22 @@ protected Invoker<T> select(LoadBalance loadbalance, Invocation invocation, List
if (stickyInvoker != null && !invokers.contains(stickyInvoker)) {
stickyInvoker = null;
}
//ignore cucurrent problem
//ignore concurrency problem
if (sticky && stickyInvoker != null && (selected == null || !selected.contains(stickyInvoker))) {
if (availablecheck && stickyInvoker.isAvailable()) {
return stickyInvoker;
}
}
}
Invoker<T> invoker = doselect(loadbalance, invocation, invokers, selected);
Invoker<T> invoker = doSelect(loadbalance, invocation, invokers, selected);

if (sticky) {
stickyInvoker = invoker;
}
return invoker;
}

private Invoker<T> doselect(LoadBalance loadbalance, Invocation invocation, List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
private Invoker<T> doSelect(LoadBalance loadbalance, Invocation invocation, List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
if (invokers == null || invokers.isEmpty())
return null;
if (invokers.size() == 1)
Expand All @@ -133,6 +136,9 @@ private Invoker<T> doselect(LoadBalance loadbalance, Invocation invocation, List
if (invokers.size() == 2 && selected != null && !selected.isEmpty()) {
return selected.get(0) == invokers.get(0) ? invokers.get(1) : invokers.get(0);
}
if (loadbalance == null) {
loadbalance = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(Constants.DEFAULT_LOADBALANCE);
}
Invoker<T> invoker = loadbalance.select(invokers, getUrl(), invocation);

//If the `invoker` is in the `selected` or invoker is unavailable && availablecheck is true, reselect.
Expand All @@ -153,7 +159,7 @@ private Invoker<T> doselect(LoadBalance loadbalance, Invocation invocation, List
}
}
} catch (Throwable t) {
logger.error("clustor relselect fail reason is :" + t.getMessage() + " if can not slove ,you can set cluster.availablecheck=false in url", t);
logger.error("cluster reselect fail reason is :" + t.getMessage() + " if can not solve, you can set cluster.availablecheck=false in url", t);
}
}
return invoker;
Expand Down Expand Up @@ -216,17 +222,12 @@ private Invoker<T> reselect(LoadBalance loadbalance, Invocation invocation,
}

public Result invoke(final Invocation invocation) throws RpcException {

checkWhetherDestroyed();

LoadBalance loadbalance;

LoadBalance loadbalance = null;
List<Invoker<T>> invokers = list(invocation);
if (invokers != null && !invokers.isEmpty()) {
loadbalance = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(invokers.get(0).getUrl()
.getMethodParameter(invocation.getMethodName(), Constants.LOADBALANCE_KEY, Constants.DEFAULT_LOADBALANCE));
} else {
loadbalance = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(Constants.DEFAULT_LOADBALANCE);
}
RpcUtils.attachInvocationIdIfAsync(getUrl(), invocation);
return doInvoke(invocation, invokers, loadbalance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,38 +141,27 @@ public Result call() throws Exception {
.append(" ]")
.toString());
}
if (method != null) {
if (!Modifier.isPublic(method.getModifiers())) {
method.setAccessible(true);
}
result = resultList.remove(0).getValue();
try {
if (method.getReturnType() != void.class
&& method.getReturnType().isAssignableFrom(result.getClass())) {
for (Result r : resultList) {
result = method.invoke(result, r.getValue());
}
} else {
for (Result r : resultList) {
method.invoke(result, r.getValue());
}
if (!Modifier.isPublic(method.getModifiers())) {
method.setAccessible(true);
}
result = resultList.remove(0).getValue();
try {
if (method.getReturnType() != void.class
&& method.getReturnType().isAssignableFrom(result.getClass())) {
for (Result r : resultList) {
result = method.invoke(result, r.getValue());
}
} else {
for (Result r : resultList) {
method.invoke(result, r.getValue());
}
} catch (Exception e) {
throw new RpcException(
new StringBuilder(32)
.append("Can not merge result: ")
.append(e.getMessage()).toString(),
e);
}
} else {
} catch (Exception e) {
throw new RpcException(
new StringBuilder(32)
.append("Can not merge result because missing method [ ")
.append(merger)
.append(" ] in class [ ")
.append(returnType.getClass().getName())
.append(" ]")
.toString());
.append("Can not merge result: ")
.append(e.getMessage()).toString(),
e);
}
} else {
Merger resultMerger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,14 @@ public class Constants {
public static final String QOS_PORT = "qos.port";

public static final String ACCEPT_FOREIGN_IP = "qos.accept.foreign.ip";

public static final String HESSIAN2_REQUEST_KEY = "hessian2.request";

public static final boolean DEFAULT_HESSIAN2_REQUEST = false;

public static final String HESSIAN_OVERLOAD_METHOD_KEY = "hessian.overload.method";

public static final boolean DEFAULT_HESSIAN_OVERLOAD_METHOD = false;

/*
* private Constants(){ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public String setEnumNameProperty(String name) {

public String getEnumPropertyName() {
if (isEnumType()) {
Object result = getProperty(ENUM_PROPERTY_NAME).toString();
Object result = getProperty(ENUM_PROPERTY_NAME);
return result == null ? null : result.toString();
}
throw new IllegalStateException("The instance is not a enum wrapper");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ public boolean hasExtension(String name) {
if (name == null || name.length() == 0)
throw new IllegalArgumentException("Extension name == null");
try {
return getExtensionClass(name) != null;
this.getExtensionClass(name);
return true;
} catch (Throwable t) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static Map<String, String> split(List<String> list, String separator) {
return null;
}
Map<String, String> map = new HashMap<String, String>();
if (list == null || list.isEmpty()) {
if (list.isEmpty()) {
return map;
}
for (String item : list) {
Expand All @@ -113,7 +113,7 @@ public static List<String> join(Map<String, String> map, String separator) {
return null;
}
List<String> list = new ArrayList<String>();
if (map == null || map.size() == 0) {
if (map.size() == 0) {
return list;
}
for (Map.Entry<String, String> entry : map.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ && isPrimitive(method.getReturnType())) {
if (parameter == null || !parameter.attribute())
continue;
String key;
if (parameter != null && parameter.key() != null && parameter.key().length() > 0) {
if (parameter.key() != null && parameter.key().length() > 0) {
key = parameter.key();
} else {
int i = name.startsWith("get") ? 3 : 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public static Map<String, String> getSubProperties(PropertySources propertySourc
if (name.startsWith(normalizedPrefix)) {
String subName = name.substring(normalizedPrefix.length());
Object value = source.getProperty(name);
if (value instanceof String) {
subProperties.put(subName, String.valueOf(value));
}
subProperties.put(subName, String.valueOf(value));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1202,4 +1202,4 @@
</xsd:annotation>
</xsd:element>

</xsd:schema>
</xsd:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@ public void testGetSubProperties() {

propertySources.addFirst(propertySource);

Map<String, String> result = PropertySourcesUtils.getSubProperties(propertySources, "user");
String KEY_PREFIX = "user";
String KEY_NAME = "name";
String KEY_AGE = "age";
Map<String, String> result = PropertySourcesUtils.getSubProperties(propertySources, KEY_PREFIX);

Assert.assertEquals(Collections.emptyMap(), result);

source.put("user.name", "Mercy");
source.put("user.age", "31");
source.put(KEY_PREFIX + "." + KEY_NAME, "Mercy");
source.put(KEY_PREFIX + "." + KEY_AGE, 31);

Map<String, Object> expected = new HashMap<String, Object>();
expected.put("name", "Mercy");
expected.put("age", "31");

result = PropertySourcesUtils.getSubProperties(propertySources, "user");
expected.put(KEY_NAME, "Mercy");
expected.put(KEY_AGE, "31");

result = PropertySourcesUtils.getSubProperties(propertySources, KEY_PREFIX);
Assert.assertEquals(expected, result);

result = PropertySourcesUtils.getSubProperties(propertySources, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public class Ls implements BaseCommand {
@Override
public String execute(CommandContext commandContext, String[] args) {
StringBuilder result = new StringBuilder();
result.append(listProvier());
result.append(listProvider());
result.append(listConsumer());

return result.toString();
}

public String listProvier() {
public String listProvider() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("As Provider side:\n");
Collection<ProviderModel> ProviderModelList = ApplicationModel.allProviderModels();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;

Expand Down Expand Up @@ -76,8 +75,6 @@ public abstract class AbstractRegistry implements Registry {
// Local disk cache file
private File file;

private AtomicBoolean destroyed = new AtomicBoolean(false);

public AbstractRegistry(URL url) {
setUrl(url);
// Start file save timer
Expand Down Expand Up @@ -442,10 +439,6 @@ private void saveProperties(URL url) {
}

public void destroy() {
if (!destroyed.compareAndSet(false, true)) {
return;
}

if (logger.isInfoEnabled()) {
logger.info("Destroy registry:" + getUrl());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

/**
* FailbackRegistry. (SPI, Prototype, ThreadSafe)
Expand All @@ -58,8 +57,6 @@ public abstract class FailbackRegistry extends AbstractRegistry {

private final ConcurrentMap<URL, Map<NotifyListener, List<URL>>> failedNotified = new ConcurrentHashMap<URL, Map<NotifyListener, List<URL>>>();

private AtomicBoolean destroyed = new AtomicBoolean(false);

public FailbackRegistry(URL url) {
super(url);
int retryPeriod = url.getParameter(Constants.REGISTRY_RETRY_PERIOD_KEY, Constants.DEFAULT_REGISTRY_RETRY_PERIOD);
Expand Down Expand Up @@ -125,9 +122,6 @@ private void removeFailedSubscribed(URL url, NotifyListener listener) {

@Override
public void register(URL url) {
if (destroyed.get()){
return;
}
super.register(url);
failedRegistered.remove(url);
failedUnregistered.remove(url);
Expand Down Expand Up @@ -158,9 +152,6 @@ public void register(URL url) {

@Override
public void unregister(URL url) {
if (destroyed.get()){
return;
}
super.unregister(url);
failedRegistered.remove(url);
failedUnregistered.remove(url);
Expand Down Expand Up @@ -191,9 +182,6 @@ public void unregister(URL url) {

@Override
public void subscribe(URL url, NotifyListener listener) {
if (destroyed.get()){
return;
}
super.subscribe(url, listener);
removeFailedSubscribed(url, listener);
try {
Expand Down Expand Up @@ -228,9 +216,6 @@ public void subscribe(URL url, NotifyListener listener) {

@Override
public void unsubscribe(URL url, NotifyListener listener) {
if (destroyed.get()){
return;
}
super.unsubscribe(url, listener);
removeFailedSubscribed(url, listener);
try {
Expand Down Expand Up @@ -448,9 +433,6 @@ protected void retry() {

@Override
public void destroy() {
if (!canDestroy()){
return;
}
super.destroy();
try {
retryFuture.cancel(true);
Expand All @@ -459,16 +441,6 @@ public void destroy() {
}
}

// TODO: 2017/8/30 to abstract this method
protected boolean canDestroy(){
if (destroyed.compareAndSet(false, true)) {
return true;
}else{
return false;
}
}


// ==== Template method ====

protected abstract void doRegister(URL url);
Expand Down
Loading

0 comments on commit a3b8d73

Please sign in to comment.