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/05/10 08:04:39 UTC

[GitHub] [dubbo] chickenlj opened a new pull request, #10023: [optimization]RestProtocol opt, share client pool among services and avoid potential memory leak.

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

   related issue https://github.com/apache/dubbo/issues/9629


-- 
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 #10023: [optimization]RestProtocol opt, share client pool among services and avoid potential memory leak.

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


##########
dubbo-common/src/main/java/org/apache/dubbo/common/reference/ReferenceCountedResource.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.dubbo.common.reference;
+
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+
+import java.util.concurrent.atomic.AtomicLongFieldUpdater;
+
+/**
+ * inspired by Netty
+ */
+public abstract class ReferenceCountedResource implements AutoCloseable {

Review Comment:
   I think what we need is just a common and simplified version for components across the framework to use, so better not rely on Netty.



-- 
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 #10023: [optimization]RestProtocol opt, share client pool among services and avoid potential memory leak.

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

   # [Codecov](https://codecov.io/gh/apache/dubbo/pull/10023?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 [#10023](https://codecov.io/gh/apache/dubbo/pull/10023?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (404a24c) into [3.0](https://codecov.io/gh/apache/dubbo/commit/bce439e6a3969d86fba595df33a71655cfa5ace7?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bce439e) will **decrease** coverage by `0.04%`.
   > The diff coverage is `65.07%`.
   
   > :exclamation: Current head 404a24c differs from pull request most recent head 8715fc3. Consider uploading reports for the commit 8715fc3 to get more accurate results
   
   ```diff
   @@             Coverage Diff              @@
   ##                3.0   #10023      +/-   ##
   ============================================
   - Coverage     65.69%   65.64%   -0.05%     
   - Complexity      294      295       +1     
   ============================================
     Files          1215     1222       +7     
     Lines         53040    53155     +115     
     Branches       8034     8054      +20     
   ============================================
   + Hits          34842    34892      +50     
   - Misses        14386    14440      +54     
   - Partials       3812     3823      +11     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo/pull/10023?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../org/apache/dubbo/metadata/ServiceNameMapping.java](https://codecov.io/gh/apache/dubbo/pull/10023/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-ZHViYm8tbWV0YWRhdGEvZHViYm8tbWV0YWRhdGEtYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9tZXRhZGF0YS9TZXJ2aWNlTmFtZU1hcHBpbmcuamF2YQ==) | `86.66% <ø> (ø)` | |
   | [...bbo/common/reference/ReferenceCountedResource.java](https://codecov.io/gh/apache/dubbo/pull/10023/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-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb21tb24vcmVmZXJlbmNlL1JlZmVyZW5jZUNvdW50ZWRSZXNvdXJjZS5qYXZh) | `45.00% <45.00%> (ø)` | |
   | [...ache/dubbo/rpc/protocol/AbstractProxyProtocol.java](https://codecov.io/gh/apache/dubbo/pull/10023/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-ZHViYm8tcnBjL2R1YmJvLXJwYy1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL3JwYy9wcm90b2NvbC9BYnN0cmFjdFByb3h5UHJvdG9jb2wuamF2YQ==) | `57.95% <66.66%> (-0.19%)` | :arrow_down: |
   | [...g/apache/dubbo/rpc/protocol/rest/RestProtocol.java](https://codecov.io/gh/apache/dubbo/pull/10023/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-ZHViYm8tcnBjL2R1YmJvLXJwYy1yZXN0L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9ycGMvcHJvdG9jb2wvcmVzdC9SZXN0UHJvdG9jb2wuamF2YQ==) | `64.58% <71.42%> (-2.60%)` | :arrow_down: |
   | [...ubbo/rpc/protocol/rest/ReferenceCountedClient.java](https://codecov.io/gh/apache/dubbo/pull/10023/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-ZHViYm8tcnBjL2R1YmJvLXJwYy1yZXN0L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9ycGMvcHJvdG9jb2wvcmVzdC9SZWZlcmVuY2VDb3VudGVkQ2xpZW50LmphdmE=) | `100.00% <100.00%> (ø)` | |
   | [.../remoting/api/SingleProtocolConnectionManager.java](https://codecov.io/gh/apache/dubbo/pull/10023/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-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9hcGkvU2luZ2xlUHJvdG9jb2xDb25uZWN0aW9uTWFuYWdlci5qYXZh) | `61.53% <0.00%> (-23.08%)` | :arrow_down: |
   | [...nt/metadata/ServiceInstanceHostPortCustomizer.java](https://codecov.io/gh/apache/dubbo/pull/10023/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-ZHViYm8tcmVnaXN0cnkvZHViYm8tcmVnaXN0cnktYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZWdpc3RyeS9jbGllbnQvbWV0YWRhdGEvU2VydmljZUluc3RhbmNlSG9zdFBvcnRDdXN0b21pemVyLmphdmE=) | `65.78% <0.00%> (-21.06%)` | :arrow_down: |
   | [...dubbo/common/status/support/LoadStatusChecker.java](https://codecov.io/gh/apache/dubbo/pull/10023/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-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb21tb24vc3RhdHVzL3N1cHBvcnQvTG9hZFN0YXR1c0NoZWNrZXIuamF2YQ==) | `46.15% <0.00%> (-15.39%)` | :arrow_down: |
   | [.../remoting/transport/netty4/NettyServerHandler.java](https://codecov.io/gh/apache/dubbo/pull/10023/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) | `62.79% <0.00%> (-9.31%)` | :arrow_down: |
   | [...ava/org/apache/dubbo/rpc/proxy/InvocationUtil.java](https://codecov.io/gh/apache/dubbo/pull/10023/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-ZHViYm8tcnBjL2R1YmJvLXJwYy1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL3JwYy9wcm94eS9JbnZvY2F0aW9uVXRpbC5qYXZh) | `81.81% <0.00%> (-9.10%)` | :arrow_down: |
   | ... and [50 more](https://codecov.io/gh/apache/dubbo/pull/10023/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) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo/pull/10023?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo/pull/10023?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bce439e...8715fc3](https://codecov.io/gh/apache/dubbo/pull/10023?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?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] JasonKai9527 commented on a diff in pull request #10023: [optimization]RestProtocol opt, share client pool among services and avoid potential memory leak.

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


##########
dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java:
##########
@@ -136,65 +133,77 @@ protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcExcept
 
     @Override
     protected <T> T doRefer(Class<T> serviceType, URL url) throws RpcException {
+        ReferenceCountedClient referenceCountedClient = clients.computeIfAbsent(url.getAddress(), _key -> {

Review Comment:
   if the ip:port is the same,but httpclient config properties are different, how to fix this situation?
   i think you should create one object to keep them as the clients cache's key, at least adress and httpclient configuration should be included. 



-- 
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] guohao commented on a diff in pull request #10023: [optimization]RestProtocol opt, share client pool among services and avoid potential memory leak.

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


##########
dubbo-common/src/main/java/org/apache/dubbo/common/reference/ReferenceCountedResource.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.dubbo.common.reference;
+
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+
+import java.util.concurrent.atomic.AtomicLongFieldUpdater;
+
+/**
+ * inspired by Netty
+ */
+public abstract class ReferenceCountedResource implements AutoCloseable {

Review Comment:
   Why not just use netty's `io.netty.util.ReferenceCounted`?



-- 
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] JasonKai9527 commented on a diff in pull request #10023: [optimization]RestProtocol opt, share client pool among services and avoid potential memory leak.

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


##########
dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java:
##########
@@ -136,65 +133,77 @@ protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcExcept
 
     @Override
     protected <T> T doRefer(Class<T> serviceType, URL url) throws RpcException {
+        ReferenceCountedClient referenceCountedClient = clients.computeIfAbsent(url.getAddress(), _key -> {

Review Comment:
   if the ip:port is the same,but httpclient config properties are different, how to fix th is situation?



##########
dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java:
##########
@@ -136,65 +133,77 @@ protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcExcept
 
     @Override
     protected <T> T doRefer(Class<T> serviceType, URL url) throws RpcException {
+        ReferenceCountedClient referenceCountedClient = clients.computeIfAbsent(url.getAddress(), _key -> {

Review Comment:
   if the ip:port is the same,but httpclient config properties are different, how to fix this 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] CrazyHZM commented on a diff in pull request #10023: [optimization]RestProtocol opt, share client pool among services and avoid potential memory leak.

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


##########
dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/ReferenceCountedClient.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.dubbo.rpc.protocol.rest;
+
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.reference.ReferenceCountedResource;
+
+import org.jboss.resteasy.client.jaxrs.ResteasyClient;
+
+public class ReferenceCountedClient extends ReferenceCountedResource {
+    private static final Logger logger = LoggerFactory.getLogger(ReferenceCountedClient.class);
+
+    private final ResteasyClient resteasyClient;
+
+    public ReferenceCountedClient(ResteasyClient resteasyClient) {
+        this.resteasyClient = resteasyClient;
+    }
+
+    public ResteasyClient getClient() {
+        return resteasyClient;
+    }
+
+    public boolean isDestroyed() {
+        return resteasyClient.isClosed();
+    }
+
+    @Override
+    protected void destroy() {
+        try {
+            resteasyClient.close();

Review Comment:
   Add some log output, others look good to me.



-- 
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] AlbumenJ merged pull request #10023: [optimization]RestProtocol opt, share client pool among services and avoid potential memory leak.

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


-- 
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