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

An optimization about MessageFuture #831

Merged
merged 19 commits into from
Apr 23, 2019

Conversation

XCXCXCXCX
Copy link
Contributor

Ⅰ. Describe what this PR did

In the MessageFuture class, it is currently implemented using CountDownLatch.
This synchronization method is relatively heavy, we should replace it with CompletableFuture to achieve.

  1. Will not change the MessageFuture API
  2. Consider that the server will process a large number of Messages in the future, and the Get mode of the CompletableFuture will perform better when testing a large number of messages.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented Apr 18, 2019

Codecov Report

Merging #831 into develop will increase coverage by 0.01%.
The diff coverage is 66.66%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #831      +/-   ##
=============================================
+ Coverage      38.04%   38.05%   +0.01%     
+ Complexity      1006     1005       -1     
=============================================
  Files            220      220              
  Lines           8449     8452       +3     
  Branches        1016     1015       -1     
=============================================
+ Hits            3214     3216       +2     
- Misses          4850     4852       +2     
+ Partials         385      384       -1
Impacted Files Coverage Δ Complexity Δ
...ain/java/io/seata/core/protocol/MessageFuture.java 84% <66.66%> (-2.37%) 11 <3> (-1)

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 f1143a8...908d9d0. Read the comment docs.

@xingfudeshi xingfudeshi self-requested a review April 18, 2019 10:04
Copy link
Member

@xingfudeshi xingfudeshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.LGTM.

Copy link
Contributor

@CoffeeLatte007 CoffeeLatte007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments

@@ -26,13 +29,12 @@
* @author jimin.jm @alibaba-inc.com
* @date 2018 /10/9
*/
public class MessageFuture {
public class MessageFuture{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ white space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

result = origin.get(timeout, unit);
} catch (ExecutionException e) {
throw new ShouldNeverHappenException("Should not get results in a multi-threaded environment", e);
} catch (TimeoutException e){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ white space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@github-ygy
Copy link
Contributor

@CoffeeLatte007 do u have any other questions ?

@xingfudeshi xingfudeshi merged commit 58284ea into apache:develop Apr 23, 2019
nick-tan pushed a commit to nick-tan/seata that referenced this pull request Jul 12, 2019
Use CompletableFuture instead CountDownLatch in MessageFuture
@wangliang181230 wangliang181230 added this to the 0.5.* milestone Aug 9, 2021
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.

None yet

7 participants