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

[Dubbo-1876] Enhancements for the new async way of Dubbo #1957

Merged
merged 47 commits into from
Jul 11, 2018

Conversation

chickenlj
Copy link
Contributor

@chickenlj chickenlj commented Jun 18, 2018

What is the purpose of the change

Enhancements for the new async way of Dubbo introduced in #1876. Below is the main issues this PR trys to solve:

  • Support service signature with original CompletableFuture returntype.
      public interface DemoService {
          CompletableFuture<String> sayHello(String name);
      }
  • Provide context restore API when switching threads.
      AsyncContext.signalContextSwitch();
  • Postprocess of async result in filter chain.

Brief changelog

  • Add AsyncRpcResult to represent result value of async invoke, equivalent to RpcResult for sync invoke.

  • Add PostProcessFilter to support postprocess of result in filter chain

  • Change AbstractProxyInvoker and DubboInvoker to support services with original Future signature, supplementary for generated Future service.

Verifying this change

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

  • Make sure there is a GITHUB_issue 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.
  • 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.
  • Run mvn clean install -DskipTests & mvn clean test-compile failsafe:integration-test to make sure unit-test and integration-test pass.
  • If this contribution is large, please follow the Software Donation Guide.

# Conflicts:
#	dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ClusterUtils.java
#	dubbo-common/src/main/java/com/alibaba/dubbo/common/Constants.java
#	dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ReferenceConfig.java
#	dubbo-demo/dubbo-demo-api/src/main/java/com/alibaba/dubbo/demo/DemoService.java
#	dubbo-demo/dubbo-demo-consumer/src/main/java/com/alibaba/dubbo/demo/consumer/Consumer.java
#	dubbo-demo/dubbo-demo-provider/src/main/java/com/alibaba/dubbo/demo/provider/DemoServiceImpl.java
#	dubbo-demo/dubbo-demo-provider/src/main/resources/META-INF/spring/dubbo-demo-provider.xml
#	dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryProtocol.java
#	dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/ExchangeHandler.java
#	dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeHandlerAdapter.java
#	dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeHandlerDispatcher.java
#	dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java
#	dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java
#	dubbo-remoting/dubbo-remoting-api/src/test/java/com/alibaba/dubbo/remoting/PerformanceServerTest.java
#	dubbo-remoting/dubbo-remoting-api/src/test/java/com/alibaba/dubbo/remoting/handler/HeaderExchangeHandlerTest.java
#	dubbo-remoting/dubbo-remoting-netty/src/test/java/com/alibaba/dubbo/remoting/exchange/support/header/HeartbeatHandlerTest.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/Result.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcResult.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ConsumerContextFilter.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ContextFilter.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ExceptionFilter.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/AbstractProxyFactory.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/AbstractProxyInvoker.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/InvokerInvocationHandler.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/RpcUtils.java
#	dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java
#	dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboInvoker.java
#	dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocol.java
#	dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/FutureAdapter.java
#	dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftProtocol.java
#	dubbo-test/dubbo-test-benchmark/pom.xml
#	dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/AbstractBenchmarkServer.java
# Conflicts:
#	dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/AsyncContext.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/AsyncContextImpl.java
@codecov-io
Copy link

codecov-io commented Jun 19, 2018

Codecov Report

Merging #1957 into master will increase coverage by <.01%.
The diff coverage is 38.03%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1957      +/-   ##
============================================
+ Coverage     53.07%   53.07%   +<.01%     
- Complexity     4930     4956      +26     
============================================
  Files           557      559       +2     
  Lines         24802    24892      +90     
  Branches       4427     4431       +4     
============================================
+ Hits          13164    13212      +48     
- Misses         9618     9660      +42     
  Partials       2020     2020
Impacted Files Coverage Δ Complexity Δ
...oting/exchange/support/ExchangeHandlerAdapter.java 0% <ø> (ø) 0 <0> (ø) ⬇️
.../src/main/java/org/apache/dubbo/rpc/RpcResult.java 72.72% <ø> (+21.44%) 10 <0> (ø) ⬇️
...c/main/java/org/apache/dubbo/common/Constants.java 88.88% <ø> (ø) 1 <0> (ø) ⬇️
...ache/dubbo/rpc/proxy/InvokerInvocationHandler.java 30.76% <0%> (-4.02%) 3 <0> (ø)
...exchange/support/header/HeaderExchangeHandler.java 30.15% <0%> (ø) 10 <0> (ø) ⬇️
...ava/org/apache/dubbo/rpc/SimpleAsyncRpcResult.java 0% <0%> (ø) 0 <0> (?)
...le/src/main/java/com/alibaba/dubbo/rpc/Result.java 22.22% <0%> (-11.12%) 0 <0> (ø)
...main/java/org/apache/dubbo/rpc/AsyncRpcResult.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...apache/dubbo/rpc/filter/ConsumerContextFilter.java 85.71% <100%> (+1.09%) 3 <2> (+1) ⬆️
.../dubbo/rpc/protocol/dubbo/filter/FutureFilter.java 59.09% <100%> (+2.52%) 16 <6> (+3) ⬆️
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c36be6...0ff5134. Read the comment docs.

# Conflicts:
#	dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/DemoService.java
#	dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/DemoServiceImpl.java
@nobodyiam
Copy link
Contributor

Looks fantastic! This new async way of Dubbo is quite amazing!

(It may be better to squash the commits into one commit)

@chickenlj
Copy link
Contributor Author

@chickenlj
Copy link
Contributor Author

chickenlj commented Jul 6, 2018

Thank @hengyunabc for help reviewing, he totally agrees with the new async way showed in the demo.
And he'll dive into the code soon.

@chickenlj chickenlj added this to the 2.7.0 milestone Jul 9, 2018
# Conflicts:
#	dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftProtocol.java
@chickenlj chickenlj merged commit b055991 into apache:master Jul 11, 2018
July-X pushed a commit to July-X/dubbo that referenced this pull request Jul 12, 2018
* commit 'b055991b317f4e58d256721875a00c52fe415510': (271 commits)
  Merge pull request apache#1957, enhancements for the new async way of Dubbo.
  rename log file from alibaba to custom-access (apache#2057)
  Merge pull request apache#2049, upgrade netty4 to the latest release and make it the default option for transporter.
  Format style.
  Restore the badges in README.
  Polish README.
  Refactor README.
  Merge pull request apache#2047, deprecate dubbo-rpc-thrift.
  Merge pull request apache#2005, change maven parent from sonatype to apache.
  rename access log in unit test from 'alibaba' to 'alibaba.log' so that it cannot be committed by accident. (apache#2051)
  add test cases for injvm rpc protocol (apache#2041)
  add test cases for rpc thrift protocol (apache#2042)
  Merge pull request apache#1966, introduces dubbo metrics API module.
  [Dubbo- unit test class not found] fix class not found "hi" (apache#2034)
  add README for compatible module (apache#2019)
  Polish README.
  update README (apache#2025)
  [Dubbo-1695] Enhance the test coverage part-16 : dubbo-rpc/dubbo-rpc-api  module (apache#2004)
  Merge pull request apache#1997, clienthandler in netty4 should trigger heartbeat handler.
  Update issue template description.
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants