[dubbo] branch performance-tuning-2.7.x updated: unify heartbeat stamp key
This is an automated email from the ASF dual-hosted git repository. liujun pushed a commit to branch performance-tuning-2.7.x in repository https://gitbox.apache.org/repos/asf/dubbo.git The following commit(s) were added to refs/heads/performance-tuning-2.7.x by this push: new 5cab5d3 unify heartbeat stamp key 5cab5d3 is described below commit 5cab5d36d4573bd47180e8ee27212031e1d8ec08 Author: ken.lj AuthorDate: Tue Jun 4 18:09:48 2019 +0800 unify heartbeat stamp key --- .../dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java index 3249d46..9e0ee0f 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java +++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java @@ -21,6 +21,7 @@ import org.apache.dubbo.common.URL; import org.apache.dubbo.common.timer.HashedWheelTimer; import org.apache.dubbo.remoting.Channel; import org.apache.dubbo.remoting.exchange.Request; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -63,10 +64,8 @@ public class HeartBeatTaskTest { long now = System.currentTimeMillis(); url = url.addParameter(DUBBO_VERSION_KEY, "2.1.1"); -channel.setAttribute( -HeaderExchangeHandler.KEY_READ_TIMESTAMP, now); -channel.setAttribute( -HeaderExchangeHandler.KEY_WRITE_TIMESTAMP, now); +channel.setAttribute(HeartbeatHandler.KEY_READ_TIMESTAMP, now); +channel.setAttribute(HeartbeatHandler.KEY_WRITE_TIMESTAMP, now); heartbeatTimer.newTimeout(heartbeatTimerTask, 250, TimeUnit.MILLISECONDS);
[dubbo] branch performance-tuning-2.7.x updated: check before calling getMethodParameter
This is an automated email from the ASF dual-hosted git repository. liujun pushed a commit to branch performance-tuning-2.7.x in repository https://gitbox.apache.org/repos/asf/dubbo.git The following commit(s) were added to refs/heads/performance-tuning-2.7.x by this push: new 34e7871 check before calling getMethodParameter 34e7871 is described below commit 34e787119303341505a008838ca0d14b14da3284 Author: ken.lj AuthorDate: Tue Jun 4 18:07:16 2019 +0800 check before calling getMethodParameter --- dubbo-common/src/main/java/org/apache/dubbo/common/URL.java | 7 +++ .../main/java/org/apache/dubbo/rpc/support/MockInvoker.java | 11 +++ .../apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java | 8 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java b/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java index 741b7cb..38008b6 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java @@ -1015,6 +1015,13 @@ class URL implements Serializable { return value != null && value.length() > 0; } +public boolean hasMethodParameter(String method) { +if (method == null) { +return false; +} +return getMethodParameters().containsKey(method); +} + public boolean isLocalHost() { return NetUtils.isLocalHost(host) || getParameter(LOCALHOST_KEY, false); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java index 90f4d69..2badc04 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java @@ -39,12 +39,12 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import static org.apache.dubbo.rpc.Constants.MOCK_KEY; -import static org.apache.dubbo.rpc.Constants.RETURN_PREFIX; -import static org.apache.dubbo.rpc.Constants.THROW_PREFIX; import static org.apache.dubbo.rpc.Constants.FAIL_PREFIX; import static org.apache.dubbo.rpc.Constants.FORCE_PREFIX; +import static org.apache.dubbo.rpc.Constants.MOCK_KEY; import static org.apache.dubbo.rpc.Constants.RETURN_KEY; +import static org.apache.dubbo.rpc.Constants.RETURN_PREFIX; +import static org.apache.dubbo.rpc.Constants.THROW_PREFIX; final public class MockInvoker implements Invoker { private final static ProxyFactory PROXY_FACTORY = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension(); @@ -95,10 +95,13 @@ final public class MockInvoker implements Invoker { @Override public Result invoke(Invocation invocation) throws RpcException { -String mock = getUrl().getParameter(invocation.getMethodName() + "." + MOCK_KEY); if (invocation instanceof RpcInvocation) { ((RpcInvocation) invocation).setInvoker(this); } +String mock = null; +if (getUrl().hasMethodParameter(invocation.getMethodName())) { +mock = getUrl().getParameter(invocation.getMethodName() + "." + MOCK_KEY); +} if (StringUtils.isBlank(mock)) { mock = getUrl().getParameter(MOCK_KEY); } diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java index c82599c..e151cb6 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java @@ -41,13 +41,13 @@ import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY; import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY; import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY; import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY; -import static org.apache.dubbo.rpc.protocol.dubbo.Constants.CALLBACK_SERVICE_KEY; import static org.apache.dubbo.rpc.Constants.CALLBACK_INSTANCES_LIMIT_KEY; import static org.apache.dubbo.rpc.Constants.DEFAULT_CALLBACK_INSTANCES; +import static org.apache.dubbo.rpc.Constants.IS_SERVER_KEY; +import static org.apache.dubbo.rpc.protocol.dubbo.Constants.CALLBACK_SERVICE_KEY; import static org.apache.dubbo.rpc.protocol.dubbo.Constants.CALLBACK_SERVICE_PROXY_KEY; -import static org.apache.dubbo.rpc.protocol.dubbo.Constants.IS_CALLBACK_SERVICE; import static org.apache.dubbo.rpc.protocol.dubbo.Constants.CHANNEL_CALLBACK_KEY; -import static org.apache.dubbo.rpc.Constants.IS_SERVER_KEY; +import static
[dubbo] branch performance-tuning-2.7.x updated: Performance tuning: keep heartbeat updated in io thread to avoid race condition. (#4246)
This is an automated email from the ASF dual-hosted git repository. liujun pushed a commit to branch performance-tuning-2.7.x in repository https://gitbox.apache.org/repos/asf/dubbo.git The following commit(s) were added to refs/heads/performance-tuning-2.7.x by this push: new 4c35890 Performance tuning: keep heartbeat updated in io thread to avoid race condition. (#4246) 4c35890 is described below commit 4c358907023a7f055cff769549b8030ed1a926fb Author: ken.lj AuthorDate: Tue Jun 4 17:49:51 2019 +0800 Performance tuning: keep heartbeat updated in io thread to avoid race condition. (#4246) --- .../remoting/exchange/support/header/AbstractTimerTask.java| 4 ++-- .../exchange/support/header/HeaderExchangeHandler.java | 10 -- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/AbstractTimerTask.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/AbstractTimerTask.java index befa688..3779d99 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/AbstractTimerTask.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/AbstractTimerTask.java @@ -45,11 +45,11 @@ public abstract class AbstractTimerTask implements TimerTask { } static Long lastRead(Channel channel) { -return (Long) channel.getAttribute(HeaderExchangeHandler.KEY_READ_TIMESTAMP); +return (Long) channel.getAttribute(HeartbeatHandler.KEY_READ_TIMESTAMP); } static Long lastWrite(Channel channel) { -return (Long) channel.getAttribute(HeaderExchangeHandler.KEY_WRITE_TIMESTAMP); +return (Long) channel.getAttribute(HeartbeatHandler.KEY_WRITE_TIMESTAMP); } static Long now() { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java index 220d5d7..23fe27c 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java @@ -44,10 +44,6 @@ public class HeaderExchangeHandler implements ChannelHandlerDelegate { protected static final Logger logger = LoggerFactory.getLogger(HeaderExchangeHandler.class); -public static final String KEY_READ_TIMESTAMP = HeartbeatHandler.KEY_READ_TIMESTAMP; - -public static final String KEY_WRITE_TIMESTAMP = HeartbeatHandler.KEY_WRITE_TIMESTAMP; - private final ExchangeHandler handler; public HeaderExchangeHandler(ExchangeHandler handler) { @@ -125,8 +121,6 @@ public class HeaderExchangeHandler implements ChannelHandlerDelegate { @Override public void connected(Channel channel) throws RemotingException { -channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis()); -channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis()); ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel); try { handler.connected(exchangeChannel); @@ -137,8 +131,6 @@ public class HeaderExchangeHandler implements ChannelHandlerDelegate { @Override public void disconnected(Channel channel) throws RemotingException { -channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis()); -channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis()); ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel); try { handler.disconnected(exchangeChannel); @@ -152,7 +144,6 @@ public class HeaderExchangeHandler implements ChannelHandlerDelegate { public void sent(Channel channel, Object message) throws RemotingException { Throwable exception = null; try { -channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis()); ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel); try { handler.sent(exchangeChannel, message); @@ -180,7 +171,6 @@ public class HeaderExchangeHandler implements ChannelHandlerDelegate { @Override public void received(Channel channel, Object message) throws RemotingException { -channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis()); final ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel); try { if (message instanceof Request) {
[dubbo] branch performance-tuning-2.7.x updated: performance tuning: Applicationmodel revert (#4245)
This is an automated email from the ASF dual-hosted git repository. liujun pushed a commit to branch performance-tuning-2.7.x in repository https://gitbox.apache.org/repos/asf/dubbo.git The following commit(s) were added to refs/heads/performance-tuning-2.7.x by this push: new faec551 performance tuning: Applicationmodel revert (#4245) faec551 is described below commit faec551df75cb22c65970c0d83d446e306184926 Author: ken.lj AuthorDate: Tue Jun 4 17:49:00 2019 +0800 performance tuning: Applicationmodel revert (#4245) --- .../org/apache/dubbo/common/beanutil/Bean.java | 6 ++-- .../common/beanutil/JavaBeanSerializeUtilTest.java | 10 +++--- .../apache/dubbo/common/utils/PojoUtilsTest.java | 19 +- .../apache/dubbo/{common => rpc}/model/Person.java | 2 +- .../{common => rpc}/model/SerializablePerson.java | 2 +- .../apache/dubbo/{common => rpc}/model/User.java | 2 +- .../dubbo/{common => rpc}/model/media/Image.java | 2 +- .../dubbo/{common => rpc}/model/media/Media.java | 2 +- .../{common => rpc}/model/person/BigPerson.java| 2 +- .../{common => rpc}/model/person/FullAddress.java | 2 +- .../{common => rpc}/model/person/PersonInfo.java | 2 +- .../{common => rpc}/model/person/PersonStatus.java | 42 +++--- .../dubbo/{common => rpc}/model/person/Phone.java | 2 +- .../org/apache/dubbo/config/MethodConfigTest.java | 2 +- .../org/apache/dubbo/config/AbstractConfig.java| 2 +- .../dubbo/config/AbstractInterfaceConfig.java | 2 +- .../org/apache/dubbo/config/ReferenceConfig.java | 4 +-- .../org/apache/dubbo/config/ServiceConfig.java | 4 +-- .../dubbo/monitor/dubbo/DubboMonitorFactory.java | 2 +- .../apache/dubbo/monitor/dubbo/MetricsFilter.java | 2 +- .../java/org/apache/dubbo/qos/command/impl/Ls.java | 6 ++-- .../org/apache/dubbo/qos/command/impl/Offline.java | 4 +-- .../org/apache/dubbo/qos/command/impl/Online.java | 4 +-- .../org/apache/dubbo/qos/command/impl/LsTest.java | 6 ++-- .../apache/dubbo/qos/command/impl/OfflineTest.java | 4 +-- .../apache/dubbo/qos/command/impl/OnlineTest.java | 4 +-- .../registry/integration/RegistryDirectory.java| 2 +- .../registry/integration/RegistryProtocol.java | 2 +- .../java/org/apache/dubbo/rpc/RpcInvocation.java | 2 +- .../apache/dubbo/rpc}/model/ApplicationModel.java | 2 +- .../org/apache/dubbo/rpc}/model/ConsumerModel.java | 2 +- .../org/apache/dubbo/rpc}/model/MethodModel.java | 2 +- .../org/apache/dubbo/rpc}/model/ProviderModel.java | 2 +- .../org/apache/dubbo/rpc}/model/ServiceModel.java | 2 +- .../protocol/dubbo/DecodeableRpcInvocation.java| 6 ++-- .../rpc/protocol/dubbo/filter/FutureFilter.java| 4 +-- .../protocol/dubbo/telnet/InvokeTelnetHandler.java | 6 ++-- .../protocol/dubbo/telnet/ListTelnetHandler.java | 8 ++--- .../rpc/protocol/dubbo/ImplicitCallBackTest.java | 4 +-- .../dubbo/telnet/InvokerTelnetHandlerTest.java | 4 +-- .../dubbo/telnet/ListTelnetHandlerTest.java| 4 +-- .../dubbo/telnet/SelectTelnetHandlerTest.java | 4 +-- .../dubbo/rpc/protocol/rest/RestProtocol.java | 2 +- .../dubbo/rpc/protocol/rest/RestProtocolTest.java | 4 +-- 44 files changed, 102 insertions(+), 101 deletions(-) diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/Bean.java b/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/Bean.java index 2ca32b2..e17a538 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/Bean.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/Bean.java @@ -1,8 +1,8 @@ package org.apache.dubbo.common.beanutil; -import org.apache.dubbo.common.model.person.FullAddress; -import org.apache.dubbo.common.model.person.PersonStatus; -import org.apache.dubbo.common.model.person.Phone; +import org.apache.dubbo.rpc.model.person.FullAddress; +import org.apache.dubbo.rpc.model.person.PersonStatus; +import org.apache.dubbo.rpc.model.person.Phone; import java.util.Collection; import java.util.Date; diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtilTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtilTest.java index 68c7100..c98ea15 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtilTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtilTest.java @@ -16,12 +16,12 @@ */ package org.apache.dubbo.common.beanutil; -import org.apache.dubbo.common.model.person.BigPerson; -import org.apache.dubbo.common.model.person.FullAddress; -import org.apache.dubbo.common.model.person.PersonInfo; -import org.apache.dubbo.common.model.person.PersonStatus; -import org.apache.dubbo.common.model.person.Phone; import org.apache.dubbo.common.utils.PojoUtilsTest; +import org.apache.dubbo.rpc.model.person.BigPerson; +import
[dubbo] branch performance-tuning-2.7.x updated: performance tuning: getMethodparameter refactor (#4244)
This is an automated email from the ASF dual-hosted git repository. liujun pushed a commit to branch performance-tuning-2.7.x in repository https://gitbox.apache.org/repos/asf/dubbo.git The following commit(s) were added to refs/heads/performance-tuning-2.7.x by this push: new 086949c performance tuning: getMethodparameter refactor (#4244) 086949c is described below commit 086949c8fb2204bfa51e989b1fb7b8ccc6a3bc39 Author: ken.lj AuthorDate: Tue Jun 4 17:29:03 2019 +0800 performance tuning: getMethodparameter refactor (#4244) --- .../src/main/java/org/apache/dubbo/common/URL.java | 81 +- .../java/org/apache/dubbo/common/URLBuilder.java | 57 --- .../java/org/apache/dubbo/rpc/RpcInvocation.java | 16 +++-- 3 files changed, 121 insertions(+), 33 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java b/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java index 5dac550..741b7cb 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java @@ -19,8 +19,6 @@ package org.apache.dubbo.common; import org.apache.dubbo.common.config.Configuration; import org.apache.dubbo.common.config.InmemoryConfiguration; import org.apache.dubbo.common.constants.RemotingConstants; -import org.apache.dubbo.common.model.ApplicationModel; -import org.apache.dubbo.common.model.MethodModel; import org.apache.dubbo.common.utils.ArrayUtils; import org.apache.dubbo.common.utils.CollectionUtils; import org.apache.dubbo.common.utils.NetUtils; @@ -39,7 +37,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -50,6 +47,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY; import static org.apache.dubbo.common.constants.CommonConstants.HOST_KEY; import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY; import static org.apache.dubbo.common.constants.CommonConstants.LOCALHOST_KEY; +import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY; import static org.apache.dubbo.common.constants.CommonConstants.PASSWORD_KEY; import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY; import static org.apache.dubbo.common.constants.CommonConstants.PORT_KEY; @@ -180,7 +178,7 @@ class URL implements Serializable { int port, String path, Map parameters) { -this (protocol, username, password, host, port, path, parameters, toMethodParameters(parameters, path)); +this (protocol, username, password, host, port, path, parameters, toMethodParameters(parameters)); } public URL(String protocol, @@ -302,22 +300,31 @@ class URL implements Serializable { return new URL(protocol, username, password, host, port, path, parameters); } -public static Map> toMethodParameters(Map parameters, String path) { +public static Map> toMethodParameters(Map parameters) { Map> methodParameters = new HashMap<>(); if (parameters != null) { -for (Map.Entry entry : parameters.entrySet()) { -String key = entry.getKey(); -int methodSeparator = key.indexOf("."); -if (methodSeparator > 0) { -String method = key.substring(0, methodSeparator); -String realKey = key.substring(methodSeparator + 1); - ApplicationModel.getServiceModel(path).ifPresent(serviceModel -> { -Set methodModels = serviceModel.getMethods(method); -if (CollectionUtils.isNotEmpty(methodModels)) { -Map subParameter = methodParameters.computeIfAbsent(method, k -> new HashMap<>()); -subParameter.put(realKey, entry.getValue()); +String methodsString = parameters.get(METHODS_KEY); +if (StringUtils.isNotEmpty(methodsString)) { +String[] methods = methodsString.split(","); +for (Map.Entry entry : parameters.entrySet()) { +String key = entry.getKey(); +for (String method : methods) { +String methodPrefix = method + "."; +if (key.startsWith(methodPrefix)) { +String realKey = key.substring(methodPrefix.length()); +URL.putMethodParameter(method, realKey, entry.getValue(), methodParameters); } -}); +} +} +} else { +for (Map.Entry entry : parameters.entrySet()) { +String key = entry.getKey(); +int methodSeparator = key.indexOf("."); +
[dubbo] branch master updated (0b27565 -> d3a5166)
This is an automated email from the ASF dual-hosted git repository. huxing pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/dubbo.git. from 0b27565 [Dubbo-4218] Fix NPE when the TagRouterRule addresses config is null (#4218) (#4236) add d3a5166 Delete useless code (#4242) No new revisions were added by this update. Summary of changes: .../java/org/apache/dubbo/common/config/AbstractPrefixConfiguration.java | 1 - 1 file changed, 1 deletion(-)