You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/03/02 02:14:38 UTC

[GitHub] [incubator-inlong] pocozh opened a new pull request #2811: [INLONG-2802][DataProxy] Fix mx.properties local file updating too often

pocozh opened a new pull request #2811:
URL: https://github.com/apache/incubator-inlong/pull/2811


   ### Title Name: [INLONG-2802][DataProxy] Fix mx.properties local file updating too often
   
   Fixes #2802 
   
   ### Motivation
   
   *Explain here the context, and why you're making that change. What is the problem you're trying to solve.*
   
   ### Modifications
   
   *Describe the modifications you've done.*
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2811: [INLONG-2802][DataProxy] Fix mx.properties local file updating too often

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2811:
URL: https://github.com/apache/incubator-inlong/pull/2811#discussion_r818285980



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/config/ConfigManager.java
##########
@@ -123,7 +123,8 @@ private boolean updatePropertiesHolder(Map<String, String> result,
             String oldValue = addElseRemove
                     ? tmpHolder.put(entry.getKey(), entry.getValue()) : tmpHolder.remove(entry.getKey());
             // if addElseRemove is false, that means removing item, changed is true.
-            if (oldValue == null || !oldValue.equals(entry.getValue()) || !addElseRemove) {
+            if ((oldValue == null && entry.getValue() != null) || !oldValue.equals(entry.getValue())
+                    || !addElseRemove) {

Review comment:
       Readability is not good. It is better for the example.
   ```
       private boolean updatePropertiesHolder(Map<String, String> result,
               PropertiesConfigHolder holder, boolean addElseRemove) {
           Map<String, String> tmpHolder = holder.forkHolder();
           boolean changed = false;
           for (Map.Entry<String, String> entry : result.entrySet()) {
               if (addElseRemove) {
                   String oldValue = tmpHolder.put(entry.getKey(), entry.getValue());
                   if (!ObjectUtils.equals(oldValue, entry.getValue())) {
                       changed = true;
                   }
               } else {
                   String oldValue = tmpHolder.remove(entry.getKey());
                   if (oldValue != null) {
                       changed = true;
                   }
               }
           }
           if (changed) {
               return holder.loadFromHolderToFile(tmpHolder);
           } else {
               return false;
           }
       }
   ```




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] baomingyu commented on a change in pull request #2811: [INLONG-2802][DataProxy] Fix mx.properties local file updating too often

Posted by GitBox <gi...@apache.org>.
baomingyu commented on a change in pull request #2811:
URL: https://github.com/apache/incubator-inlong/pull/2811#discussion_r817429774



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/config/ConfigManager.java
##########
@@ -308,8 +310,12 @@ private boolean checkWithManager(String host, String proxyClusterName) {
                     mqConfig.putAll(clusterSet.get(0).getParams());

Review comment:
       check. clusterSet  is or not empty, avoid exception.




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2811: [INLONG-2802][DataProxy] Fix mx.properties local file updating too often

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2811:
URL: https://github.com/apache/incubator-inlong/pull/2811#discussion_r818285980



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/config/ConfigManager.java
##########
@@ -123,7 +123,8 @@ private boolean updatePropertiesHolder(Map<String, String> result,
             String oldValue = addElseRemove
                     ? tmpHolder.put(entry.getKey(), entry.getValue()) : tmpHolder.remove(entry.getKey());
             // if addElseRemove is false, that means removing item, changed is true.
-            if (oldValue == null || !oldValue.equals(entry.getValue()) || !addElseRemove) {
+            if ((oldValue == null && entry.getValue() != null) || !oldValue.equals(entry.getValue())
+                    || !addElseRemove) {

Review comment:
       Readability is not good. It is better for the example.
   `
       private boolean updatePropertiesHolder(Map<String, String> result,
               PropertiesConfigHolder holder, boolean addElseRemove) {
           Map<String, String> tmpHolder = holder.forkHolder();
           boolean changed = false;
           for (Map.Entry<String, String> entry : result.entrySet()) {
               if (addElseRemove) {
                   String oldValue = tmpHolder.put(entry.getKey(), entry.getValue());
                   if (!ObjectUtils.equals(oldValue, entry.getValue())) {
                       changed = true;
                   }
               } else {
                   String oldValue = tmpHolder.remove(entry.getKey());
                   if (oldValue != null) {
                       changed = true;
                   }
               }
           }
           if (changed) {
               return holder.loadFromHolderToFile(tmpHolder);
           } else {
               return false;
           }
       }
   `




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2811: [INLONG-2802][DataProxy] Fix mx.properties local file updating too often

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2811:
URL: https://github.com/apache/incubator-inlong/pull/2811#discussion_r817471354



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/config/ConfigManager.java
##########
@@ -123,7 +123,8 @@ private boolean updatePropertiesHolder(Map<String, String> result,
             String oldValue = addElseRemove
                     ? tmpHolder.put(entry.getKey(), entry.getValue()) : tmpHolder.remove(entry.getKey());
             // if addElseRemove is false, that means removing item, changed is true.
-            if (oldValue == null || !oldValue.equals(entry.getValue()) || !addElseRemove) {
+            if ((oldValue == null && entry.getValue() != null) || !oldValue.equals(entry.getValue())
+                    || !addElseRemove) {

Review comment:
       oldValue.equals(entry.getValue()) maybe throw NullPointerException.
   (oldValue == null && entry.getValue() != null) maybe be false when oldValue == null and entry.getValue() == null.
   




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2811: [INLONG-2802][DataProxy] Fix mx.properties local file updating too often

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2811:
URL: https://github.com/apache/incubator-inlong/pull/2811#discussion_r818285980



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/config/ConfigManager.java
##########
@@ -123,7 +123,8 @@ private boolean updatePropertiesHolder(Map<String, String> result,
             String oldValue = addElseRemove
                     ? tmpHolder.put(entry.getKey(), entry.getValue()) : tmpHolder.remove(entry.getKey());
             // if addElseRemove is false, that means removing item, changed is true.
-            if (oldValue == null || !oldValue.equals(entry.getValue()) || !addElseRemove) {
+            if ((oldValue == null && entry.getValue() != null) || !oldValue.equals(entry.getValue())
+                    || !addElseRemove) {

Review comment:
       Readability is not good. It is better for the example.
   '''
       private boolean updatePropertiesHolder(Map<String, String> result,
               PropertiesConfigHolder holder, boolean addElseRemove) {
           Map<String, String> tmpHolder = holder.forkHolder();
           boolean changed = false;
           for (Map.Entry<String, String> entry : result.entrySet()) {
               if (addElseRemove) {
                   String oldValue = tmpHolder.put(entry.getKey(), entry.getValue());
                   if (!ObjectUtils.equals(oldValue, entry.getValue())) {
                       changed = true;
                   }
               } else {
                   String oldValue = tmpHolder.remove(entry.getKey());
                   if (oldValue != null) {
                       changed = true;
                   }
               }
           }
           if (changed) {
               return holder.loadFromHolderToFile(tmpHolder);
           } else {
               return false;
           }
       }
   '''




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] dockerzhang merged pull request #2811: [INLONG-2802][DataProxy] Fix mx.properties local file updating too often

Posted by GitBox <gi...@apache.org>.
dockerzhang merged pull request #2811:
URL: https://github.com/apache/incubator-inlong/pull/2811


   


-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2811: [INLONG-2802][DataProxy] Fix mx.properties local file updating too often

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2811:
URL: https://github.com/apache/incubator-inlong/pull/2811#discussion_r818285980



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/config/ConfigManager.java
##########
@@ -123,7 +123,8 @@ private boolean updatePropertiesHolder(Map<String, String> result,
             String oldValue = addElseRemove
                     ? tmpHolder.put(entry.getKey(), entry.getValue()) : tmpHolder.remove(entry.getKey());
             // if addElseRemove is false, that means removing item, changed is true.
-            if (oldValue == null || !oldValue.equals(entry.getValue()) || !addElseRemove) {
+            if ((oldValue == null && entry.getValue() != null) || !oldValue.equals(entry.getValue())
+                    || !addElseRemove) {

Review comment:
       Readability is not good. It is better for the example.
       private boolean updatePropertiesHolder(Map<String, String> result,
               PropertiesConfigHolder holder, boolean addElseRemove) {
           Map<String, String> tmpHolder = holder.forkHolder();
           boolean changed = false;
           for (Map.Entry<String, String> entry : result.entrySet()) {
               if (addElseRemove) {
                   String oldValue = tmpHolder.put(entry.getKey(), entry.getValue());
                   if (!ObjectUtils.equals(oldValue, entry.getValue())) {
                       changed = true;
                   }
               } else {
                   String oldValue = tmpHolder.remove(entry.getKey());
                   if (oldValue != null) {
                       changed = true;
                   }
               }
           }
   
           if (changed) {
               return holder.loadFromHolderToFile(tmpHolder);
           } else {
               return false;
           }
       }




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] pocozh commented on a change in pull request #2811: [INLONG-2802][DataProxy] Fix mx.properties local file updating too often

Posted by GitBox <gi...@apache.org>.
pocozh commented on a change in pull request #2811:
URL: https://github.com/apache/incubator-inlong/pull/2811#discussion_r817510990



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/config/ConfigManager.java
##########
@@ -308,8 +310,12 @@ private boolean checkWithManager(String host, String proxyClusterName) {
                     mqConfig.putAll(clusterSet.get(0).getParams());

Review comment:
       done

##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/config/ConfigManager.java
##########
@@ -123,7 +123,8 @@ private boolean updatePropertiesHolder(Map<String, String> result,
             String oldValue = addElseRemove
                     ? tmpHolder.put(entry.getKey(), entry.getValue()) : tmpHolder.remove(entry.getKey());
             // if addElseRemove is false, that means removing item, changed is true.
-            if (oldValue == null || !oldValue.equals(entry.getValue()) || !addElseRemove) {
+            if ((oldValue == null && entry.getValue() != null) || !oldValue.equals(entry.getValue())
+                    || !addElseRemove) {

Review comment:
       done




-- 
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: commits-unsubscribe@inlong.apache.org

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