You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "PleaseGiveMeTheCoke (via GitHub)" <gi...@apache.org> on 2024/08/31 16:03:40 UTC

[PR] feature: support http protocol [incubator-seata]

PleaseGiveMeTheCoke opened a new pull request, #6801:
URL: https://github.com/apache/incubator-seata/pull/6801

   <!-- Please make sure you have read and understood the contributing guidelines -->
   
   - [ ] I have registered the PR [changes](../changes).
   
   ### Ⅰ. Describe what this PR did
   support http protocol
   
   ### Ⅱ. Does this pull request fix one issue?
   <!-- If that, add "fixes #xxx" below in the next line, for example, fixes #97. -->
   
   
   ### Ⅲ. Why don't you add test cases (unit test/integration test)? 
   
   
   ### Ⅳ. Describe how to verify it
   
   
   ### Ⅴ. Special notes for reviews
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1817982298


##########
common/pom.xml:
##########
@@ -52,5 +52,11 @@
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
         </dependency>
+        <!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->

Review Comment:
   ```suggestion
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#issuecomment-2408272659

   ## [Codecov](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: Patch coverage is `1.48368%` with `332 lines` in your changes missing coverage. Please review.
   > Project coverage is 52.10%. Comparing base [(`22f9c47`)](https://app.codecov.io/gh/apache/incubator-seata/commit/22f9c4785da174ebc2de3125712cf1ecfe5f2861?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`094a82c`)](https://app.codecov.io/gh/apache/incubator-seata/commit/094a82cfe5b5d0b6248964215c566a659e6131b9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 20 commits behind head on 2.x.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...a/core/rpc/netty/http/BaseSeataServletRequest.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp%2FBaseSeataServletRequest.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cC9CYXNlU2VhdGFTZXJ2bGV0UmVxdWVzdC5qYXZh) | 0.00% | [70 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...che/seata/core/rpc/netty/http/ParameterParser.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp%2FParameterParser.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cC9QYXJhbWV0ZXJQYXJzZXIuamF2YQ==) | 0.00% | [47 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [.../core/rpc/netty/http/SeataHttpServletResponse.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp%2FSeataHttpServletResponse.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cC9TZWF0YUh0dHBTZXJ2bGV0UmVzcG9uc2UuamF2YQ==) | 0.00% | [42 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...e/seata/core/rpc/netty/http/ControllerManager.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp%2FControllerManager.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cC9Db250cm9sbGVyTWFuYWdlci5qYXZh) | 0.00% | [37 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...seata/core/rpc/netty/http/HttpDispatchHandler.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp%2FHttpDispatchHandler.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cC9IdHRwRGlzcGF0Y2hIYW5kbGVyLmphdmE=) | 0.00% | [30 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...ata/core/rpc/netty/http2/Http2DispatchHandler.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp2%2FHttp2DispatchHandler.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cDIvSHR0cDJEaXNwYXRjaEhhbmRsZXIuamF2YQ==) | 0.00% | [28 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...e/seata/core/rpc/netty/http/SeataAsyncContext.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp%2FSeataAsyncContext.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cC9TZWF0YUFzeW5jQ29udGV4dC5qYXZh) | 0.00% | [25 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...ache/seata/serializer/protobuf/GrpcSerializer.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=serializer%2Fseata-serializer-protobuf%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fserializer%2Fprotobuf%2FGrpcSerializer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2VyaWFsaXplci9zZWF0YS1zZXJpYWxpemVyLXByb3RvYnVmL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9zZXJpYWxpemVyL3Byb3RvYnVmL0dycGNTZXJpYWxpemVyLmphdmE=) | 0.00% | [17 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...che/seata/core/protocol/detector/HttpDetector.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Fprotocol%2Fdetector%2FHttpDetector.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9wcm90b2NvbC9kZXRlY3Rvci9IdHRwRGV0ZWN0b3IuamF2YQ==) | 0.00% | [13 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...seata/core/rpc/netty/http2/Http2DetectHandler.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp2%2FHttp2DetectHandler.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cDIvSHR0cDJEZXRlY3RIYW5kbGVyLmphdmE=) | 0.00% | [13 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | ... and [2 more](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/incubator-seata/pull/6801/graphs/tree.svg?width=650&height=150&src=pr&token=tbmHt2ZfxO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@             Coverage Diff              @@
   ##                2.x    #6801      +/-   ##
   ============================================
   - Coverage     52.35%   52.10%   -0.25%     
   - Complexity     6422     6545     +123     
   ============================================
     Files          1083     1134      +51     
     Lines         37923    40191    +2268     
     Branches       4492     4697     +205     
   ============================================
   + Hits          19853    20941    +1088     
   - Misses        16093    17254    +1161     
   - Partials       1977     1996      +19     
   ```
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...er/spring/web/RestControllerBeanPostProcessor.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=server%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fserver%2Fspring%2Fweb%2FRestControllerBeanPostProcessor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9zZXJ2ZXIvc3ByaW5nL3dlYi9SZXN0Q29udHJvbGxlckJlYW5Qb3N0UHJvY2Vzc29yLmphdmE=) | `100.00% <100.00%> (ø)` | |
   | [...he/seata/core/protocol/detector/Http2Detector.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Fprotocol%2Fdetector%2FHttp2Detector.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9wcm90b2NvbC9kZXRlY3Rvci9IdHRwMkRldGVjdG9yLmphdmE=) | `31.25% <0.00%> (ø)` | |
   | [...a/core/rpc/netty/http/SeataHttpServletRequest.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp%2FSeataHttpServletRequest.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cC9TZWF0YUh0dHBTZXJ2bGV0UmVxdWVzdC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...che/seata/core/protocol/detector/HttpDetector.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Fprotocol%2Fdetector%2FHttpDetector.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9wcm90b2NvbC9kZXRlY3Rvci9IdHRwRGV0ZWN0b3IuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...seata/core/rpc/netty/http2/Http2DetectHandler.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp2%2FHttp2DetectHandler.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cDIvSHR0cDJEZXRlY3RIYW5kbGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...ache/seata/serializer/protobuf/GrpcSerializer.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=serializer%2Fseata-serializer-protobuf%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fserializer%2Fprotobuf%2FGrpcSerializer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2VyaWFsaXplci9zZWF0YS1zZXJpYWxpemVyLXByb3RvYnVmL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9zZXJpYWxpemVyL3Byb3RvYnVmL0dycGNTZXJpYWxpemVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...e/seata/core/rpc/netty/http/SeataAsyncContext.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp%2FSeataAsyncContext.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cC9TZWF0YUFzeW5jQ29udGV4dC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...ata/core/rpc/netty/http2/Http2DispatchHandler.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp2%2FHttp2DispatchHandler.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cDIvSHR0cDJEaXNwYXRjaEhhbmRsZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...seata/core/rpc/netty/http/HttpDispatchHandler.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp%2FHttpDispatchHandler.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cC9IdHRwRGlzcGF0Y2hIYW5kbGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...e/seata/core/rpc/netty/http/ControllerManager.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Frpc%2Fnetty%2Fhttp%2FControllerManager.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvaHR0cC9Db250cm9sbGVyTWFuYWdlci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | ... and [3 more](https://app.codecov.io/gh/apache/incubator-seata/pull/6801?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
   
   ... and [51 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-seata/pull/6801/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes merged PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1798668547


##########
common/pom.xml:
##########
@@ -52,5 +52,10 @@
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
         </dependency>
+        <!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>

Review Comment:
   scope=provided



##########
core/src/main/java/org/apache/seata/core/rpc/netty/http2/Http2DispatchHandler.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.core.rpc.netty.http2;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.http.QueryStringDecoder;
+import io.netty.handler.codec.http2.DefaultHttp2DataFrame;
+import io.netty.handler.codec.http2.DefaultHttp2Headers;
+import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame;
+import io.netty.handler.codec.http2.Http2DataFrame;
+import io.netty.handler.codec.http2.Http2Headers;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
+import org.apache.seata.core.rpc.netty.grpc.GrpcHeaderEnum;
+import org.apache.seata.core.rpc.netty.http.ControllerManager;
+import org.apache.seata.core.rpc.netty.http.HttpInvocation;
+import org.apache.seata.core.rpc.netty.http.ParameterParser;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Http2DispatchHandler extends ChannelDuplexHandler {
+
+    private final AtomicBoolean headerSent = new AtomicBoolean(false);
+
+    private ObjectNode requestDataNode;
+
+    private String path;
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        if (msg instanceof Http2HeadersFrame) {
+            if (headerSent.compareAndSet(false, true)) {

Review Comment:
   ok,那这个channel应该是http2的那个channel,底层可能还是复用的相同的origin channel?



##########
common/src/main/java/org/apache/seata/common/DefaultValues.java:
##########
@@ -64,6 +66,7 @@ public interface DefaultValues {
     String DEFAULT_NIO_WORKER_THREAD_PREFIX = "NettyServerNIOWorker";
     String DEFAULT_EXECUTOR_THREAD_PREFIX = "NettyServerBizHandler";
     String DEFAULT_PROTOCOL = "seata";
+    String DEFAULT_HTTP_VERSION = "http1";

Review Comment:
   http吧,http1感觉没必要增加一个1标识
   HTTP, HTTP1 doesn't feel the need to add a 1 flag



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1799084177


##########
server/src/main/java/org/apache/seata/server/controller/ClusterController.java:
##########
@@ -55,7 +56,7 @@
 /**
  */
 @RestController
-@RequestMapping("/metadata/v1")
+@RequestMapping("/metadata")

Review Comment:
   为什么去除这里的v1,而在下面给每一个增加v1?



##########
server/src/main/java/org/apache/seata/server/controller/ClusterController.java:
##########
@@ -122,16 +123,25 @@ public MetadataResponse cluster(String group) {
         return metadataResponse;
     }
 
-    @PostMapping("/watch")
+    @PostMapping("/v1/watch")
     public void watch(HttpServletRequest request, @RequestParam Map<String, Object> groupTerms,
-        @RequestParam(defaultValue = "28000") int timeout) {
+                      @RequestParam(defaultValue = "28000") int timeout) {
         AsyncContext context = request.startAsync();
         context.setTimeout(0L);
         groupTerms.forEach((group, term) -> {
             Watcher<AsyncContext> watcher =
-                new Watcher<>(group, context, timeout, Long.parseLong(String.valueOf(term)));
+                    new Watcher<>(group, context, timeout, Long.parseLong(String.valueOf(term)));
             clusterWatcherManager.registryWatcher(watcher);
         });
     }
 
+    @PostMapping("/v2/watch")
+    public void watchV2(Channel channel, @RequestParam Map<String, Object> groupTerms,

Review Comment:
   新弄一个类吧,ClusterV2Controller



##########
discovery/seata-discovery-raft/src/main/java/org/apache/seata/discovery/registry/raft/RaftRegistryServiceImpl.java:
##########
@@ -447,7 +472,7 @@ public List<InetSocketAddress> lookup(String key) throws Exception {
         CURRENT_TRANSACTION_SERVICE_GROUP = key;
         CURRENT_TRANSACTION_CLUSTER_NAME = clusterName;
         if (!METADATA.containsGroup(clusterName)) {
-            String raftClusterAddress = CONFIG.getConfig(getRaftAddrFileKey());
+            String raftClusterAddress = CONFIG.getConfig("httpVersion");

Review Comment:
   这地方改错了吧?



##########
discovery/seata-discovery-raft/src/main/java/org/apache/seata/discovery/registry/raft/RaftRegistryServiceImpl.java:
##########
@@ -313,24 +318,44 @@ private static boolean watch() throws RetryableException {
             if (StringUtils.isNotBlank(jwtToken)) {
                 header.put(AUTHORIZATION_HEADER, jwtToken);
             }
-            try (CloseableHttpResponse response =
-                HttpClientUtil.doPost("http://" + tcAddress + "/metadata/v1/watch", param, header, 30000)) {
-                if (response != null) {
-                    StatusLine statusLine = response.getStatusLine();
-                    if (statusLine != null && statusLine.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
-                        if (StringUtils.isNotBlank(USERNAME) && StringUtils.isNotBlank(PASSWORD)) {
-                            throw new RetryableException("Authentication failed!");
-                        } else {
-                            throw new AuthenticationFailedException("Authentication failed! you should configure the correct username and password.");
-                        }
+            String httpVersion = CONFIG.getConfig(org.apache.seata.common.ConfigurationKeys.TRANSPORT_PROTOCOL, DEFAULT_HTTP_VERSION);
+            if (httpVersion.equals(DEFAULT_HTTP_VERSION)) {
+                return watchWithHttp(header, param, tcAddress);
+            } else {
+                return watchWithHttp2(header, param, tcAddress);
+            }

Review Comment:
   ```suggestion
               }
               break;
   ```



##########
discovery/seata-discovery-raft/src/main/java/org/apache/seata/discovery/registry/raft/RaftRegistryServiceImpl.java:
##########
@@ -313,24 +318,44 @@ private static boolean watch() throws RetryableException {
             if (StringUtils.isNotBlank(jwtToken)) {
                 header.put(AUTHORIZATION_HEADER, jwtToken);
             }
-            try (CloseableHttpResponse response =
-                HttpClientUtil.doPost("http://" + tcAddress + "/metadata/v1/watch", param, header, 30000)) {
-                if (response != null) {
-                    StatusLine statusLine = response.getStatusLine();
-                    if (statusLine != null && statusLine.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
-                        if (StringUtils.isNotBlank(USERNAME) && StringUtils.isNotBlank(PASSWORD)) {
-                            throw new RetryableException("Authentication failed!");
-                        } else {
-                            throw new AuthenticationFailedException("Authentication failed! you should configure the correct username and password.");
-                        }
+            String httpVersion = CONFIG.getConfig(org.apache.seata.common.ConfigurationKeys.TRANSPORT_PROTOCOL, DEFAULT_HTTP_VERSION);

Review Comment:
   ```suggestion
               String httpVersion = CONFIG.getConfig(org.apache.seata.common.ConfigurationKeys.HTTP_VERSION, DEFAULT_HTTP_VERSION);
   ```



##########
discovery/seata-discovery-raft/src/main/java/org/apache/seata/discovery/registry/raft/RaftRegistryServiceImpl.java:
##########
@@ -313,24 +318,44 @@ private static boolean watch() throws RetryableException {
             if (StringUtils.isNotBlank(jwtToken)) {
                 header.put(AUTHORIZATION_HEADER, jwtToken);
             }
-            try (CloseableHttpResponse response =
-                HttpClientUtil.doPost("http://" + tcAddress + "/metadata/v1/watch", param, header, 30000)) {
-                if (response != null) {
-                    StatusLine statusLine = response.getStatusLine();
-                    if (statusLine != null && statusLine.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
-                        if (StringUtils.isNotBlank(USERNAME) && StringUtils.isNotBlank(PASSWORD)) {
-                            throw new RetryableException("Authentication failed!");
-                        } else {
-                            throw new AuthenticationFailedException("Authentication failed! you should configure the correct username and password.");
-                        }
+            String httpVersion = CONFIG.getConfig(org.apache.seata.common.ConfigurationKeys.TRANSPORT_PROTOCOL, DEFAULT_HTTP_VERSION);
+            if (httpVersion.equals(DEFAULT_HTTP_VERSION)) {
+                return watchWithHttp(header, param, tcAddress);
+            } else {
+                return watchWithHttp2(header, param, tcAddress);
+            }
+        }
+        return false;
+    }
+
+    private static Boolean watchWithHttp2(Map<String, String> header, Map<String, String> param, String tcAddress) throws RetryableException {
+        try (Response response =
+                     Http2ClientUtil.doPost("http://" + tcAddress + "/metadata/v1/watch", param, header, 30000)) {

Review Comment:
   ```suggestion
                        Http2ClientUtil.doPost("http://" + tcAddress + "/metadata/v2/watch", param, header, 30000)) {
   ```



##########
discovery/seata-discovery-raft/src/main/java/org/apache/seata/discovery/registry/raft/RaftRegistryServiceImpl.java:
##########
@@ -313,24 +318,44 @@ private static boolean watch() throws RetryableException {
             if (StringUtils.isNotBlank(jwtToken)) {
                 header.put(AUTHORIZATION_HEADER, jwtToken);
             }
-            try (CloseableHttpResponse response =
-                HttpClientUtil.doPost("http://" + tcAddress + "/metadata/v1/watch", param, header, 30000)) {
-                if (response != null) {
-                    StatusLine statusLine = response.getStatusLine();
-                    if (statusLine != null && statusLine.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
-                        if (StringUtils.isNotBlank(USERNAME) && StringUtils.isNotBlank(PASSWORD)) {
-                            throw new RetryableException("Authentication failed!");
-                        } else {
-                            throw new AuthenticationFailedException("Authentication failed! you should configure the correct username and password.");
-                        }
+            String httpVersion = CONFIG.getConfig(org.apache.seata.common.ConfigurationKeys.TRANSPORT_PROTOCOL, DEFAULT_HTTP_VERSION);
+            if (httpVersion.equals(DEFAULT_HTTP_VERSION)) {

Review Comment:
   不应该是DEFAULT_HTTP_VERSION,应该确定好枚举,http和http2



##########
common/src/main/java/org/apache/seata/common/util/Http2ClientUtil.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.common.util;
+
+import io.netty.handler.codec.http.QueryStringEncoder;
+import okhttp3.HttpUrl;
+import okhttp3.OkHttpClient;
+import okhttp3.Protocol;
+import okhttp3.Request;
+import okhttp3.Response;
+import org.apache.http.client.methods.CloseableHttpResponse;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+public class Http2ClientUtil {

Review Comment:
   应该提供一个okhttpclientutil,用来替代httpclientutil



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1817982283


##########
core/src/main/java/org/apache/seata/core/rpc/netty/http2/Http2DispatchHandler.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.core.rpc.netty.http2;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.http.QueryStringDecoder;
+import io.netty.handler.codec.http2.DefaultHttp2DataFrame;
+import io.netty.handler.codec.http2.DefaultHttp2Headers;
+import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame;
+import io.netty.handler.codec.http2.Http2DataFrame;
+import io.netty.handler.codec.http2.Http2Headers;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
+import org.apache.seata.core.rpc.netty.grpc.GrpcHeaderEnum;
+import org.apache.seata.core.rpc.netty.http.ControllerManager;
+import org.apache.seata.core.rpc.netty.http.HttpInvocation;
+import org.apache.seata.core.rpc.netty.http.ParameterParser;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Http2DispatchHandler extends ChannelDuplexHandler {
+
+    private final AtomicBoolean headerSent = new AtomicBoolean(false);
+
+    private ObjectNode requestDataNode;
+
+    private String path;
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        if (msg instanceof Http2HeadersFrame) {
+            if (headerSent.compareAndSet(false, true)) {

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: support http protocol [incubator-seata]

Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1739787748


##########
core/src/main/java/org/apache/seata/core/rpc/netty/grpc/GrpcDecoder.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.core.rpc.netty.grpc;
+
+import com.google.protobuf.Any;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.http2.Http2DataFrame;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
+import io.netty.util.ReferenceCounted;
+import org.apache.seata.core.protocol.RpcMessage;
+import org.apache.seata.core.protocol.generated.GrpcMessageProto;
+import org.apache.seata.core.serializer.Serializer;
+import org.apache.seata.core.serializer.SerializerServiceLoader;
+import org.apache.seata.core.serializer.SerializerType;
+
+public class GrpcDecoder extends ChannelDuplexHandler {
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        if (msg instanceof Http2HeadersFrame) {
+            onHeadersRead(ctx, (Http2HeadersFrame) msg);
+        } else if (msg instanceof Http2DataFrame) {
+            onDataRead(ctx, (Http2DataFrame) msg);
+        } else if (msg instanceof ReferenceCounted) {
+            ctx.fireChannelRead(msg);
+        }
+    }
+
+    public void onDataRead(ChannelHandlerContext ctx, Http2DataFrame msg) throws Exception {
+        ByteBuf content = msg.content();
+        int readableBytes = content.readableBytes();
+        byte[] bytes = new byte[readableBytes];
+        content.readBytes(bytes);
+        if (bytes.length < 5) {
+            return;
+        }
+
+        int srcPos = 0;
+        while (srcPos < readableBytes) {
+            // The first byte defaults to 0, indicating that no decompression is required
+            // Read the value of the next four bytes as the length of the body
+            int length = ((bytes[srcPos + 1] & 0xFF) << 24) |
+                    ((bytes[srcPos + 2] & 0xFF) << 16) |
+                    ((bytes[srcPos + 3] & 0xFF) << 8) |
+                    (bytes[srcPos + 4] & 0xFF);
+
+            byte[] data = new byte[length];
+            System.arraycopy(bytes, srcPos + 5, data, 0, length);
+
+            GrpcMessageProto grpcMessageProto = GrpcMessageProto.parseFrom(data);
+            Any body = grpcMessageProto.getBody();
+            int messageType = grpcMessageProto.getMessageType();
+            int messageId = grpcMessageProto.getId();
+            byte[] byteArray = body.toByteArray();
+
+            Serializer serializer = SerializerServiceLoader.load(SerializerType.getByCode(SerializerType.GRPC.getCode()), (byte) 0);
+            Object messageBody = serializer.deserialize(byteArray);
+
+            RpcMessage rpcMsg = new RpcMessage();
+            rpcMsg.setMessageType((byte) messageType);

Review Comment:
   ## User-controlled data in numeric cast
   
   This cast to a narrower type depends on a [user-provided value](1), potentially causing truncation.
   
   [Show more details](https://github.com/apache/incubator-seata/security/code-scanning/41)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1798671363


##########
core/src/main/java/org/apache/seata/core/rpc/netty/http2/Http2DispatchHandler.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.core.rpc.netty.http2;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.http.QueryStringDecoder;
+import io.netty.handler.codec.http2.DefaultHttp2DataFrame;
+import io.netty.handler.codec.http2.DefaultHttp2Headers;
+import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame;
+import io.netty.handler.codec.http2.Http2DataFrame;
+import io.netty.handler.codec.http2.Http2Headers;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
+import org.apache.seata.core.rpc.netty.grpc.GrpcHeaderEnum;
+import org.apache.seata.core.rpc.netty.http.ControllerManager;
+import org.apache.seata.core.rpc.netty.http.HttpInvocation;
+import org.apache.seata.core.rpc.netty.http.ParameterParser;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Http2DispatchHandler extends ChannelDuplexHandler {
+
+    private final AtomicBoolean headerSent = new AtomicBoolean(false);
+
+    private ObjectNode requestDataNode;
+
+    private String path;
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        if (msg instanceof Http2HeadersFrame) {
+            if (headerSent.compareAndSet(false, true)) {

Review Comment:
   ok,那这个channel应该是http2的那个channel,底层可能还是复用的相同的origin channel?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "PleaseGiveMeTheCoke (via GitHub)" <gi...@apache.org>.
PleaseGiveMeTheCoke commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1800268702


##########
server/src/main/java/org/apache/seata/server/cluster/manager/ClusterWatcherManager.java:
##########
@@ -86,14 +94,18 @@ public void onChangeEvent(ClusterChangeEvent event) {
     }
 
     private void notify(Watcher<?> watcher) {
-        AsyncContext asyncContext = (AsyncContext)watcher.getAsyncContext();
-        HttpServletResponse httpServletResponse = (HttpServletResponse)asyncContext.getResponse();
-        watcher.setDone(true);
+        Channel channel  = (Channel) watcher.getAsyncContext();
+        if (channel instanceof Http2StreamChannel) {
+            // http2
+            channel.writeAndFlush(new DefaultHttp2DataFrame(Unpooled.wrappedBuffer("changed\n".getBytes())));

Review Comment:
   header在一开始建立双向流连接时就响应了



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1799106294


##########
server/src/main/java/org/apache/seata/server/cluster/manager/ClusterWatcherManager.java:
##########
@@ -86,14 +94,18 @@ public void onChangeEvent(ClusterChangeEvent event) {
     }
 
     private void notify(Watcher<?> watcher) {
-        AsyncContext asyncContext = (AsyncContext)watcher.getAsyncContext();
-        HttpServletResponse httpServletResponse = (HttpServletResponse)asyncContext.getResponse();
-        watcher.setDone(true);
+        Channel channel  = (Channel) watcher.getAsyncContext();
+        if (channel instanceof Http2StreamChannel) {
+            // http2
+            channel.writeAndFlush(new DefaultHttp2DataFrame(Unpooled.wrappedBuffer("changed\n".getBytes())));

Review Comment:
   可以不写body吗?只响应header,然后body为空



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1798097135


##########
core/src/main/java/org/apache/seata/core/rpc/netty/http/ParameterParser.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.core.rpc.netty.http;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.netty.channel.Channel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ParameterParser {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ParameterParser.class);
+
+    public static ObjectNode convertParamMap(Map<String, List<String>> paramMap) throws JsonProcessingException {
+        ObjectMapper objectMapper = new ObjectMapper();
+        ObjectNode paramNode = objectMapper.createObjectNode();
+        for (Map.Entry<String, List<String>> entry : paramMap.entrySet()) {
+            List<String> list = entry.getValue();
+            if (list == null || list.isEmpty()) {
+                continue;
+            }
+            if (list.size() == 1) {
+                paramNode.put(entry.getKey(), list.get(0));
+            } else {
+                ArrayNode arrayNode = paramNode.putArray(entry.getKey());
+                for (String s : list) {
+                    arrayNode.add(s);
+                }
+            }
+        }
+        return paramNode;
+    }
+
+    public static Object[] getArgValues(AtomicReference<Channel> channel, ParamMetaData[] paramMetaDatas, Method handleMethod, ObjectNode paramMap) throws JsonProcessingException {
+        Class<?>[] parameterTypes = handleMethod.getParameterTypes();
+        Parameter[] parameters = handleMethod.getParameters();
+        return getParameters(channel, parameterTypes, paramMetaDatas, parameters, paramMap);
+    }
+
+    private static Object[] getParameters(AtomicReference<Channel> channel, Class<?>[] parameterTypes, ParamMetaData[] paramMetaDatas, Parameter[] parameters, ObjectNode paramMap) throws JsonProcessingException {
+        int length = parameterTypes.length;
+        Object[] ret = new Object[length];
+        for (int i = 0; i < length; i++) {
+            Class<?> parameterType = parameterTypes[i];
+            String parameterName = parameters[i].getName();
+            ParamMetaData paramMetaData = paramMetaDatas[i];
+            ret[i] = getArgValue(channel, parameterType, parameterName, paramMetaData, paramMap);
+            if (!parameterType.isAssignableFrom(ret[i].getClass())) {
+                LOGGER.error("[HttpDispatchHandler] not compatible parameter type, expect {}, but {}", parameterType, ret[i].getClass());
+                ret[i] = null;
+            }
+        }
+
+        return ret;
+    }
+
+
+    private static Object getArgValue(AtomicReference<Channel> channel, Class<?> parameterType, String parameterName, ParamMetaData paramMetaData, ObjectNode paramMap) throws JsonProcessingException {
+        ParamMetaData.ParamConvertType paramConvertType = paramMetaData.getParamConvertType();
+        ObjectMapper objectMapper = new ObjectMapper();
+        if (parameterType.equals(Channel.class)) {
+            Channel ret = channel.get();

Review Comment:
   放入到paramMap中,就可以直接从paramMap中获取channel,不需要单独传入channel
   Put it into the paramMap, you can directly get the channel from the paramMap, no need to pass in the channel separately



##########
server/src/main/java/org/apache/seata/server/cluster/manager/ClusterWatcherManager.java:
##########
@@ -86,6 +91,16 @@ public void onChangeEvent(ClusterChangeEvent event) {
     }
 
     private void notify(Watcher<?> watcher) {
+        Channel channel  = (Channel) watcher.getAsyncContext();
+        if (channel instanceof Http2StreamChannel) {

Review Comment:
   http1的呢?如果通过8091端口进来的v1/watch,可不是下面的HttpServletResponse逻辑能正常执行的
   What about HTTP1? If v1/watch comes in through port 8091, the following HttpServletResponse logic can not be executed normally



##########
core/src/main/java/org/apache/seata/core/rpc/netty/http2/Http2DispatchHandler.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.core.rpc.netty.http2;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.http.QueryStringDecoder;
+import io.netty.handler.codec.http2.DefaultHttp2DataFrame;
+import io.netty.handler.codec.http2.DefaultHttp2Headers;
+import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame;
+import io.netty.handler.codec.http2.Http2DataFrame;
+import io.netty.handler.codec.http2.Http2Headers;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
+import org.apache.seata.core.rpc.netty.grpc.GrpcHeaderEnum;
+import org.apache.seata.core.rpc.netty.http.ControllerManager;
+import org.apache.seata.core.rpc.netty.http.HttpInvocation;
+import org.apache.seata.core.rpc.netty.http.ParameterParser;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Http2DispatchHandler extends ChannelDuplexHandler {
+
+    private final AtomicBoolean headerSent = new AtomicBoolean(false);
+
+    private ObjectNode requestDataNode;
+
+    private String path;
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        if (msg instanceof Http2HeadersFrame) {
+            if (headerSent.compareAndSet(false, true)) {
+                Http2Headers headers = new DefaultHttp2Headers();
+                headers.add(GrpcHeaderEnum.HTTP2_STATUS.header, String.valueOf(200));
+                ctx.writeAndFlush(new DefaultHttp2HeadersFrame(headers, false));
+            }
+
+            Http2HeadersFrame http2HeadersFrame = (Http2HeadersFrame) msg;
+            path = http2HeadersFrame.headers().path().toString();
+            QueryStringDecoder queryStringDecoder = new QueryStringDecoder(path);
+            ObjectMapper objectMapper = new ObjectMapper();
+            requestDataNode = objectMapper.createObjectNode();
+            requestDataNode.putIfAbsent("param", ParameterParser.convertParamMap(queryStringDecoder.parameters()));
+        } else if (msg instanceof Http2DataFrame) {
+            ObjectMapper objectMapper = new ObjectMapper();
+            Http2DataFrame http2DataFrame = (Http2DataFrame) msg;
+            ByteBuf byteBuf = http2DataFrame.content();
+            byte[] bytes = new byte[byteBuf.readableBytes()];
+            byteBuf.readBytes(bytes);
+            requestDataNode.putIfAbsent("body", objectMapper.readTree(bytes));
+            invoke(ctx, path, objectMapper);

Review Comment:
   channel被复用时,requestDataNode没有进行清理,是否残留上一次的requestDataNode内容?
   When the channel is reused, the requestDataNode is not cleaned up. Does the last requestDataNode content remain?



##########
core/src/main/java/org/apache/seata/core/rpc/netty/http2/Http2DispatchHandler.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.core.rpc.netty.http2;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.http.QueryStringDecoder;
+import io.netty.handler.codec.http2.DefaultHttp2DataFrame;
+import io.netty.handler.codec.http2.DefaultHttp2Headers;
+import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame;
+import io.netty.handler.codec.http2.Http2DataFrame;
+import io.netty.handler.codec.http2.Http2Headers;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
+import org.apache.seata.core.rpc.netty.grpc.GrpcHeaderEnum;
+import org.apache.seata.core.rpc.netty.http.ControllerManager;
+import org.apache.seata.core.rpc.netty.http.HttpInvocation;
+import org.apache.seata.core.rpc.netty.http.ParameterParser;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Http2DispatchHandler extends ChannelDuplexHandler {
+
+    private final AtomicBoolean headerSent = new AtomicBoolean(false);
+
+    private ObjectNode requestDataNode;
+
+    private String path;
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        if (msg instanceof Http2HeadersFrame) {
+            if (headerSent.compareAndSet(false, true)) {

Review Comment:
   这个连接如果一直被复用,但是没有开启双向流的形式,使用http2传递不同的header,但是这里只读了一次,会不会有问题?
   If this connection has been reused all the time, but the form of bidirectional streaming is not enabled, using HTTP2 to pass different headers, but only read it once, will there be a problem?



##########
server/src/main/java/org/apache/seata/server/controller/ClusterController.java:
##########
@@ -123,13 +122,11 @@ public MetadataResponse cluster(String group) {
     }
 
     @PostMapping("/watch")
-    public void watch(HttpServletRequest request, @RequestParam Map<String, Object> groupTerms,
-        @RequestParam(defaultValue = "28000") int timeout) {
-        AsyncContext context = request.startAsync();
-        context.setTimeout(0L);
+    public void watch(Channel channel, @RequestParam Map<String, Object> groupTerms,

Review Comment:
   保持向下兼容,要保留HttpServletRequest request,因为当前版本spring-web还没去除,所以HttpServletRequest request还要留着,有些接口会从7091访问进来
   To maintain backward compatibility, keep the HttpServletRequest request, because the current version of spring-web has not been removed, so the HttpServletRequest request will remain, and some interfaces will be accessed from 7091



##########
serializer/seata-serializer-protobuf/src/main/java/org/apache/seata/serializer/protobuf/GrpcSerializer.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.serializer.protobuf;
+
+import com.google.protobuf.Any;
+import com.google.protobuf.Message;
+import org.apache.seata.common.exception.ShouldNeverHappenException;
+import org.apache.seata.common.loader.LoadLevel;
+import org.apache.seata.core.serializer.Serializer;
+import org.apache.seata.serializer.protobuf.convertor.PbConvertor;
+import org.apache.seata.serializer.protobuf.manager.ProtobufConvertManager;
+
+@LoadLevel(name = "GRPC")
+public class GrpcSerializer implements Serializer {

Review Comment:
   这个为什么还留着?
   Why is this still there?



##########
server/src/main/java/org/apache/seata/server/controller/ClusterController.java:
##########
@@ -123,13 +122,11 @@ public MetadataResponse cluster(String group) {
     }
 
     @PostMapping("/watch")
-    public void watch(HttpServletRequest request, @RequestParam Map<String, Object> groupTerms,
-        @RequestParam(defaultValue = "28000") int timeout) {
-        AsyncContext context = request.startAsync();

Review Comment:
   逻辑上要判断,如果是request为空就是走的8091,如果request不为空就是7091,要保留原逻辑
   Logically, it should be judged that if the request is empty, it will go 8091, if the request is not empty, it will go 7091, and the original logic should be retained.



##########
core/src/main/java/org/apache/seata/core/rpc/netty/http/HttpDispatchHandler.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.core.rpc.netty.http;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.handler.codec.http.DefaultFullHttpResponse;
+import io.netty.handler.codec.http.FullHttpResponse;
+import io.netty.handler.codec.http.HttpHeaderNames;
+import io.netty.handler.codec.http.HttpMethod;
+import io.netty.handler.codec.http.HttpRequest;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.handler.codec.http.HttpVersion;
+import io.netty.handler.codec.http.QueryStringDecoder;
+import io.netty.handler.codec.http.multipart.Attribute;
+import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder;
+import io.netty.handler.codec.http.multipart.InterfaceHttpData;
+
+import java.lang.reflect.Method;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class HttpDispatchHandler extends SimpleChannelInboundHandler<HttpRequest> {
+
+    @Override
+    protected void channelRead0(ChannelHandlerContext ctx, HttpRequest httpRequest) throws Exception {
+        QueryStringDecoder queryStringDecoder = new QueryStringDecoder(httpRequest.uri());
+        String path = queryStringDecoder.path();
+        ObjectMapper objectMapper = new ObjectMapper();
+        ObjectNode requestDataNode = objectMapper.createObjectNode();
+        requestDataNode.putIfAbsent("param", ParameterParser.convertParamMap(queryStringDecoder.parameters()));
+
+        if (httpRequest.method() == HttpMethod.POST) {
+            ObjectNode bodyDataNode = objectMapper.createObjectNode();
+            HttpPostRequestDecoder httpPostRequestDecoder = new HttpPostRequestDecoder(httpRequest);
+            for (InterfaceHttpData interfaceHttpData : httpPostRequestDecoder.getBodyHttpDatas()) {
+                if (interfaceHttpData.getHttpDataType() != InterfaceHttpData.HttpDataType.Attribute) {
+                    continue;
+                }
+                Attribute attribute = (Attribute) interfaceHttpData;
+                bodyDataNode.put(attribute.getName(), attribute.getValue());
+            }
+            requestDataNode.putIfAbsent("body", bodyDataNode);
+        }
+
+        HttpInvocation httpInvocation = ControllerManager.getHttpInvocation(path);
+        Object httpController = httpInvocation.getController();
+        Method handleMethod = httpInvocation.getMethod();
+        AtomicReference<Channel> channel = new AtomicReference<>(ctx.channel());

Review Comment:
   为什么要用AtomicReference<Channel>,而且为什么要对channel有个单独的入参,为什么不将它放入到requestDataNode中?
   Why use AtomicReference < Channel >, and why have a separate imported parameter for channel, and why not put it in requestDataNode?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: support http protocol [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1749098760


##########
server/src/main/java/org/apache/seata/server/controller/ClusterController.java:
##########
@@ -56,23 +57,16 @@
  */
 @RestController
 @RequestMapping("/metadata/v1")
-public class ClusterController {
+public class ClusterController implements HttpController {

Review Comment:
   为什么必须继承HttpController?可以设计成直接按RestController扫描吗?然后用一个适配器模式去设计吗?
   Why do I have to inherit HttpController? Can I design it to scan directly by RestController? Then use an adapter pattern to design it?



##########
server/src/main/java/org/apache/seata/server/console/controller/HttpControllerManager.java:
##########
@@ -0,0 +1,21 @@
+package org.apache.seata.server.console.controller;
+
+import org.apache.seata.core.rpc.netty.http.HttpController;
+import org.apache.seata.core.rpc.netty.http.HttpDispatchHandler;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.util.List;
+
+@Component
+public class HttpControllerManager {
+
+    @Autowired
+    private List<HttpController> httpControllerList;
+
+    @PostConstruct
+    private void init() {
+        httpControllerList.forEach(HttpDispatchHandler::addHttpController);

Review Comment:
   不应该采用List<HttpController>这种方式,应该继承AbstractAutoProxyCreator,去做controller的扫描,然后使用适配器等模式将其包装后,进行addHttpController



##########
core/src/main/java/org/apache/seata/core/rpc/netty/http/HttpDispatchHandler.java:
##########
@@ -0,0 +1,205 @@
+package org.apache.seata.core.rpc.netty.http;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.handler.codec.http.*;
+import io.netty.handler.codec.http.multipart.Attribute;
+import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder;
+import io.netty.handler.codec.http.multipart.InterfaceHttpData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.AsyncEvent;
+import javax.servlet.AsyncListener;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class HttpDispatchHandler extends SimpleChannelInboundHandler<HttpRequest> {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(HttpDispatchHandler.class);
+    private static final Map<String, HttpController> httpControllerMap = new ConcurrentHashMap<>();
+    private static final Map<String, Method> requestMethodMap = new ConcurrentHashMap<>();
+    private static final String INVALID_DEFAULT_VALUE = "\"\\n\\t\\t\\n\\t\\t\\n\\ue000\\ue001\\ue002\\n\\t\\t\\t\\t\\n";
+    private static final List<Class> mappingClass = new ArrayList<Class>() {{
+        add(GetMapping.class);
+        add(PostMapping.class);

Review Comment:
   put跟delete应该也要做适配
   Put and delete should also be adapted



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "PleaseGiveMeTheCoke (via GitHub)" <gi...@apache.org>.
PleaseGiveMeTheCoke commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1798208365


##########
core/src/main/java/org/apache/seata/core/rpc/netty/http2/Http2DispatchHandler.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.core.rpc.netty.http2;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.http.QueryStringDecoder;
+import io.netty.handler.codec.http2.DefaultHttp2DataFrame;
+import io.netty.handler.codec.http2.DefaultHttp2Headers;
+import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame;
+import io.netty.handler.codec.http2.Http2DataFrame;
+import io.netty.handler.codec.http2.Http2Headers;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
+import org.apache.seata.core.rpc.netty.grpc.GrpcHeaderEnum;
+import org.apache.seata.core.rpc.netty.http.ControllerManager;
+import org.apache.seata.core.rpc.netty.http.HttpInvocation;
+import org.apache.seata.core.rpc.netty.http.ParameterParser;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Http2DispatchHandler extends ChannelDuplexHandler {
+
+    private final AtomicBoolean headerSent = new AtomicBoolean(false);
+
+    private ObjectNode requestDataNode;
+
+    private String path;
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        if (msg instanceof Http2HeadersFrame) {
+            if (headerSent.compareAndSet(false, true)) {

Review Comment:
   unary模式的话,每次都会开启一条新的流,channel和handler都会创建新的



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1801315841


##########
server/src/main/java/org/apache/seata/server/cluster/manager/ClusterWatcherManager.java:
##########
@@ -86,14 +94,18 @@ public void onChangeEvent(ClusterChangeEvent event) {
     }
 
     private void notify(Watcher<?> watcher) {
-        AsyncContext asyncContext = (AsyncContext)watcher.getAsyncContext();
-        HttpServletResponse httpServletResponse = (HttpServletResponse)asyncContext.getResponse();
-        watcher.setDone(true);
+        Channel channel  = (Channel) watcher.getAsyncContext();
+        if (channel instanceof Http2StreamChannel) {
+            // http2
+            channel.writeAndFlush(new DefaultHttp2DataFrame(Unpooled.wrappedBuffer("changed\n".getBytes())));

Review Comment:
   > header在一开始建立双向流连接时就响应了
   
   能响应一个空body吗,而不是changed
   Can it respond to an empty body, rather than changed?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: seata-server support http protocol [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6801:
URL: https://github.com/apache/incubator-seata/pull/6801#discussion_r1806440497


##########
common/src/main/java/org/apache/seata/common/ConfigurationKeys.java:
##########
@@ -630,6 +630,11 @@ public interface ConfigurationKeys {
 
     String TRANSPORT_PROTOCOL = TRANSPORT_PREFIX + "protocol";
 
+    /**
+     * http1 or http2
+     */
+    String HTTP_VERSION = TRANSPORT_PREFIX + "httpVersion";

Review Comment:
   应该放到registry.raft下面,而不是transport



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org