You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/07/22 08:02:38 UTC

[GitHub] [dubbo] conghuhu opened a new pull request, #10356: feat: add mesh enable config and process url in mesh mode

conghuhu opened a new pull request, #10356:
URL: https://github.com/apache/dubbo/pull/10356

   ## What is the purpose of the change
   
   ApplicationConfig adds meshEnable configuration, ReferenceConfig adds providerPort configuration, and at the same time, api configuration, xml configuration, attribute configuration, and annotation configuration are modified.
   
   After meshEnable is true, the registry is set to N/A, at least one tri protocol needs to be configured, and the ports configured by the default consumer and provider are the same. DubboReference only needs to configure providedBy (K8S Service name == provider application name) to call.
   
   ```properties
   # dubbo-consumer.properties
   dubbo.application.name=dubbo-samples-mesh-consumer
   dubbo.registry.address=N/A
   dubbo.protocol.name=tri
   dubbo.protocol.port=50052
   # enable mesh
   dubbo.application.meshEnable=true
   ```
   ```java
   // consumer
   @DubboReference(providedBy = "dubbo-samples-mesh-provider")
   private Greeter greeter;
   ```
   If the provider and consumer service ports are inconsistent, you need to configure the port exposed by the provider in DubboReference, as follows:
   ```java
   // consumer
   @DubboReference(providedBy = "dubbo-samples-mesh-provider", providerPort = 50052)
   private Greeter greeter;
   ```
   
   ## Brief changelog
   
   
   ## Verifying this change
   
   
   <!-- Follow this checklist to help us incorporate your contribution quickly and easily: -->
   
   ## Checklist
   - [x] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues) 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](https://github.com/apache/dubbo-samples) project.
   - [ ] Add some description to [dubbo-website](https://github.com/apache/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](https://github.com/apache/dubbo/wiki/Software-donation-guide).
   


-- 
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@dubbo.apache.org

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


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


[GitHub] [dubbo] CrazyHZM commented on a diff in pull request #10356: feat: add mesh enable config and process url in mesh mode

Posted by GitBox <gi...@apache.org>.
CrazyHZM commented on code in PR #10356:
URL: https://github.com/apache/dubbo/pull/10356#discussion_r934186090


##########
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java:
##########
@@ -439,6 +448,65 @@ private T createProxy(Map<String, String> referenceParameters) {
         return (T) proxyFactory.getProxy(invoker, ProtocolUtils.isGeneric(generic));
     }
 
+    /**
+     * if enable mesh mode, handle url.
+     *
+     * @param referenceParameters referenceParameters
+     */
+    private void meshModeHandleUrl(Map<String, String> referenceParameters) {
+        if (!checkMeshConfig(referenceParameters)) {
+            return;
+        }
+        if (StringUtils.isNotEmpty(url)) {
+            // user specified URL, could be peer-to-peer address, or register center's address.
+            if (logger.isInfoEnabled()) {
+                logger.info("The url already exists, mesh no longer processes url: " + url);
+            }
+            return;
+        }
+
+        // get pod namespace
+        String podNamespace;
+        if (StringUtils.isEmpty(System.getenv("POD_NAMESPACE"))) {
+            if (logger.isWarnEnabled()) {
+                logger.warn("Can not get env variable: POD_NAMESPACE, it may not be running in the K8S environment , " +
+                        "finally use 'default' replace");
+            }
+            podNamespace = "default";
+        } else {
+            podNamespace = System.getenv("POD_NAMESPACE");
+        }
+
+        // url port, default 80.
+        AtomicInteger port = new AtomicInteger(DEFAULT_MESH_PORT);

Review Comment:
   Why use `AtomicInteger`?



##########
dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/reference/ReferenceBeanBuilder.java:
##########
@@ -198,6 +198,11 @@ public ReferenceBeanBuilder setProvidedBy(String providedBy) {
         return this;
     }
 
+    public ReferenceBeanBuilder setProviderPort(Integer providerPort) {
+        attributes.put(ReferenceAttributes.PROVIDER_PORT, providerPort);
+        return this;
+    }
+

Review Comment:
   Remove useless code.



##########
dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/reference/ReferenceAttributes.java:
##########
@@ -52,6 +52,8 @@ public interface ReferenceAttributes {
 
     String PROVIDED_BY = "providedBy";
 
+    String PROVIDER_PORT = "providerPort";
+

Review Comment:
   Remove useless code.



-- 
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@dubbo.apache.org

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


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


[GitHub] [dubbo] codecov-commenter commented on pull request #10356: feat: add mesh enable config and process url in mesh mode

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #10356:
URL: https://github.com/apache/dubbo/pull/10356#issuecomment-1192342335

   # [Codecov](https://codecov.io/gh/apache/dubbo/pull/10356?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#10356](https://codecov.io/gh/apache/dubbo/pull/10356?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8e798e5) into [3.1](https://codecov.io/gh/apache/dubbo/commit/9e6517a14575ce8d8a957ae08dd4d84450645243?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9e6517a) will **decrease** coverage by `0.13%`.
   > The diff coverage is `30.23%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##                3.1   #10356      +/-   ##
   ============================================
   - Coverage     65.64%   65.50%   -0.14%     
   + Complexity      318      296      -22     
   ============================================
     Files          1248     1248              
     Lines         54248    54279      +31     
     Branches       8190     8192       +2     
   ============================================
   - Hits          35611    35557      -54     
   - Misses        14778    14858      +80     
   - Partials       3859     3864       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo/pull/10356?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...apache/dubbo/common/constants/CommonConstants.java](https://codecov.io/gh/apache/dubbo/pull/10356/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb21tb24vY29uc3RhbnRzL0NvbW1vbkNvbnN0YW50cy5qYXZh) | `100.00% <ø> (ø)` | |
   | [.../config/spring/reference/ReferenceBeanBuilder.java](https://codecov.io/gh/apache/dubbo/pull/10356/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tY29uZmlnL2R1YmJvLWNvbmZpZy1zcHJpbmcvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL2NvbmZpZy9zcHJpbmcvcmVmZXJlbmNlL1JlZmVyZW5jZUJlYW5CdWlsZGVyLmphdmE=) | `8.91% <0.00%> (-0.19%)` | :arrow_down: |
   | [.../java/org/apache/dubbo/config/ReferenceConfig.java](https://codecov.io/gh/apache/dubbo/pull/10356/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tY29uZmlnL2R1YmJvLWNvbmZpZy1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL2NvbmZpZy9SZWZlcmVuY2VDb25maWcuamF2YQ==) | `75.00% <31.42%> (-5.59%)` | :arrow_down: |
   | [...g/apache/dubbo/config/AbstractReferenceConfig.java](https://codecov.io/gh/apache/dubbo/pull/10356/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb25maWcvQWJzdHJhY3RSZWZlcmVuY2VDb25maWcuamF2YQ==) | `85.48% <33.33%> (-2.66%)` | :arrow_down: |
   | [...ava/org/apache/dubbo/config/ApplicationConfig.java](https://codecov.io/gh/apache/dubbo/pull/10356/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb25maWcvQXBwbGljYXRpb25Db25maWcuamF2YQ==) | `81.81% <33.33%> (-0.90%)` | :arrow_down: |
   | [.../dubbo/rpc/protocol/tri/command/QueuedCommand.java](https://codecov.io/gh/apache/dubbo/pull/10356/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tcnBjL2R1YmJvLXJwYy10cmlwbGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL3JwYy9wcm90b2NvbC90cmkvY29tbWFuZC9RdWV1ZWRDb21tYW5kLmphdmE=) | `64.28% <0.00%> (-14.29%)` | :arrow_down: |
   | [...in/java/org/apache/dubbo/common/utils/JVMUtil.java](https://codecov.io/gh/apache/dubbo/pull/10356/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb21tb24vdXRpbHMvSlZNVXRpbC5qYXZh) | `79.59% <0.00%> (-12.25%)` | :arrow_down: |
   | [...bo/rpc/protocol/dubbo/DecodeableRpcInvocation.java](https://codecov.io/gh/apache/dubbo/pull/10356/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tcnBjL2R1YmJvLXJwYy1kdWJiby9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZHViYm8vcnBjL3Byb3RvY29sL2R1YmJvL0RlY29kZWFibGVScGNJbnZvY2F0aW9uLmphdmE=) | `70.19% <0.00%> (-10.58%)` | :arrow_down: |
   | [.../remoting/transport/netty4/NettyServerHandler.java](https://codecov.io/gh/apache/dubbo/pull/10356/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctbmV0dHk0L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy90cmFuc3BvcnQvbmV0dHk0L05ldHR5U2VydmVySGFuZGxlci5qYXZh) | `58.13% <0.00%> (-9.31%)` | :arrow_down: |
   | [...dubbo/remoting/exchange/support/DefaultFuture.java](https://codecov.io/gh/apache/dubbo/pull/10356/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9leGNoYW5nZS9zdXBwb3J0L0RlZmF1bHRGdXR1cmUuamF2YQ==) | `87.06% <0.00%> (-5.18%)` | :arrow_down: |
   | ... and [17 more](https://codecov.io/gh/apache/dubbo/pull/10356/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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@dubbo.apache.org

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


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


[GitHub] [dubbo] chickenlj merged pull request #10356: feat: add mesh enable config and process url in mesh mode

Posted by GitBox <gi...@apache.org>.
chickenlj merged PR #10356:
URL: https://github.com/apache/dubbo/pull/10356


-- 
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@dubbo.apache.org

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


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


[GitHub] [dubbo] CrazyHZM commented on a diff in pull request #10356: feat: add mesh enable config and process url in mesh mode

Posted by GitBox <gi...@apache.org>.
CrazyHZM commented on code in PR #10356:
URL: https://github.com/apache/dubbo/pull/10356#discussion_r928827030


##########
dubbo-common/src/main/java/org/apache/dubbo/config/ApplicationConfig.java:
##########
@@ -203,6 +204,12 @@ public class ApplicationConfig extends AbstractConfig {
 
     private Boolean enableEmptyProtection;
 
+    /**
+     * enable mesh mode
+     * @since 3.1.0
+     */
+    private Boolean meshEnable;

Review Comment:
   `meshEnable` should be the behavior of the consumer and should be placed in the configuration of the consumer level
   



##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java:
##########
@@ -82,6 +83,15 @@ public abstract class AbstractReferenceConfig extends AbstractInterfaceConfig {
      */
     protected String providedBy;
 
+    /**
+     * The service port of the provider, the default is the triple port of the {@link ProtocolConfig#port}.
+     * In mesh mode: by default, dubbo will think that the ports of the consumer and the provider are the same.
+     * If the tri port of the consumer and the provider are inconsistent, please specify the tri port of provider on the consumer side
+     *
+     * @since 3.1.0
+     */
+    protected Integer providerPort;

Review Comment:
   Need to consider the multi-port situation.
   



-- 
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@dubbo.apache.org

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


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


[GitHub] [dubbo] chickenlj commented on a diff in pull request #10356: feat: add mesh enable config and process url in mesh mode

Posted by GitBox <gi...@apache.org>.
chickenlj commented on code in PR #10356:
URL: https://github.com/apache/dubbo/pull/10356#discussion_r940820599


##########
dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java:
##########
@@ -546,4 +546,26 @@ public interface CommonConstants {
 
     String PREFER_JSON_FRAMEWORK_NAME = "dubbo.json-framework.prefer";
 
+    /**
+     * @since 3.1.0
+     */
+    String MESH_ENABLE = "mesh-enable";
+
+    /**
+     * @since 3.1.0
+     */
+    Integer DEFAULT_MESH_PORT = 80;

Review Comment:
   Can we make the default mesh port the same as triple's default port? I think the default `80` port is not helpful for users using Triple, which is probably the most common case.



-- 
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@dubbo.apache.org

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


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