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

Triple flowcontrol #10811

Closed
wants to merge 0 commits into from
Closed

Triple flowcontrol #10811

wants to merge 0 commits into from

Conversation

asa3311
Copy link
Contributor

@asa3311 asa3311 commented Oct 24, 2022

What is the purpose of the change

Related with #10748
sample:
apache/dubbo-samples#531

Brief changelog

Verifying this change

Checklist

  • Make sure there is a GitHub_issue 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.
  • 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.
  • Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
  • 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 sample in dubbo samples project.
  • Add some description to dubbo-website project if you are requesting to add a feature.
  • GitHub Actions works fine on your own branch.
  • If this contribution is large, please follow the Software Donation Guide.

@codecov-commenter
Copy link

Codecov Report

Merging #10811 (21beaff) into 3.2 (fcb4aa5) will decrease coverage by 0.02%.
The diff coverage is 58.15%.

@@             Coverage Diff              @@
##                3.2   #10811      +/-   ##
============================================
- Coverage     64.68%   64.66%   -0.03%     
+ Complexity      390      389       -1     
============================================
  Files          1342     1345       +3     
  Lines         57276    57811     +535     
  Branches       8446     8512      +66     
============================================
+ Hits          37047    37381     +334     
- Misses        16244    16397     +153     
- Partials       3985     4033      +48     
Impacted Files Coverage Δ
.../dubbo/rpc/protocol/tri/call/TripleClientCall.java 29.93% <7.69%> (-1.92%) ⬇️
...bo/rpc/protocol/tri/stream/TripleClientStream.java 50.00% <50.00%> (ø)
...rpc/protocol/tri/TriHttp2RemoteFlowController.java 54.58% <54.58%> (ø)
.../rpc/protocol/tri/TriHttp2LocalFlowController.java 55.73% <55.73%> (ø)
...dubbo/rpc/protocol/tri/TripleFlowControlFrame.java 61.90% <61.90%> (ø)
.../protocol/tri/call/BiStreamServerCallListener.java 70.37% <66.66%> (-4.63%) ⬇️
.../protocol/tri/call/AbstractServerCallListener.java 70.45% <75.00%> (+0.45%) ⬆️
...tocol/tri/call/ServerStreamServerCallListener.java 76.47% <80.00%> (+3.74%) ⬆️
...pache/dubbo/rpc/protocol/tri/frame/TriDecoder.java 83.58% <91.66%> (+2.22%) ⬆️
...he/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java 92.53% <100.00%> (+0.73%) ⬆️
... and 32 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Assertions.assertTrue(listener.started);
stream.request(2);
byte[] data = new byte[]{0, 0, 0, 0, 1, 1};
final ByteBuf buf = Unpooled.wrappedBuffer(data);
transportListener.onData(buf, false);
Http2DataFrame fame = new DefaultHttp2DataFrame(buf);
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't understand

@@ -173,12 +173,14 @@ public final void onComplete() {
}

@Override
public final void onMessage(byte[] message) {
public final void onMessage(TripleFlowControlFrame data) {
Copy link
Contributor

Choose a reason for hiding this comment

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

FlowControlFrame should not be known by Call class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

change to object


private Object instance;

public TripleFlowControlFrame(Http2Connection http2Connection, int windowSizeIncrement, Http2WindowUpdateFrame http2WindowUpdateFrame, byte[] message){
Copy link
Contributor

Choose a reason for hiding this comment

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

Decouple message bytes , instance and flow control related field maybe better

/**
* This design is learning from {@see io.netty.handler.codec.http2.DefaultHttp2RemoteFlowController} which is in Netty.
*/
@UnstableApi
Copy link
Contributor

Choose a reason for hiding this comment

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

TLDR, why copy instead just use netty directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because netty directly will consumeBytes to when received data, i use new function consumeTriBytes to instead it. so it can consumeBytes when after dubbo invoke.

@@ -46,7 +47,7 @@ public AbstractServerCallListener(RpcInvocation invocation, Invoker<?> invoker,
this.responseObserver = responseObserver;
}

public void invoke() {
public void invoke(TripleFlowControlFrame tripleFlowControlBean) {
Copy link
Contributor

Choose a reason for hiding this comment

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

call may only need a common data class as param, no need to know flow control

Copy link
Contributor Author

Choose a reason for hiding this comment

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

change to object

@@ -59,6 +60,12 @@ public void invoke() {
final long stInMillis = System.currentTimeMillis();
try {
final Result response = invoker.invoke(invocation);
//unary and serverstream add flowcontrol update windowsize
if(null != tripleFlowControlBean && null != tripleFlowControlBean.getHttp2Connection() && tripleFlowControlBean.getWindowSizeIncrement() > 0 && null != tripleFlowControlBean.getHttp2WindowUpdateFrame()){
Copy link
Contributor

Choose a reason for hiding this comment

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

This may lead to queueing on IO when inovke is slow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is removed

public BiStreamServerCallListener(RpcInvocation invocation, Invoker<?> invoker,
ServerCallToObserverAdapter<Object> responseObserver) {
super(invocation, invoker, responseObserver);
invocation.setArguments(new Object[]{responseObserver});
invoke();
invoke(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

🙅 to pass null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@asa3311 asa3311 closed this Nov 22, 2022
@asa3311 asa3311 mentioned this pull request Nov 24, 2022
8 tasks
@asa3311
Copy link
Contributor Author

asa3311 commented Nov 24, 2022

link #11011

@asa3311
Copy link
Contributor Author

asa3311 commented Nov 24, 2022

conflic too much,link #11011

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