You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/02/23 02:45:30 UTC

[GitHub] [rocketmq] zhanghaou opened a new pull request #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

zhanghaou opened a new pull request #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786
 
 
   ## What is the purpose of the change
   
   Fix ISSUE 1689, remove unused statsItems when topic or group deleted.
   
   ## Brief changelog
   
   XX
   
   ## Verifying this change
   
   XXXX
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed 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. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) 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 integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
   - [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test`  to make sure integration-test pass.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] zhanghaou commented on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
zhanghaou commented on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#issuecomment-606454073
 
 
   > It would be better to provide an option for compatibility.
   
   Does it mean that we need to add a switch when call these interfaces?
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] zongtanghu commented on a change in pull request #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
zongtanghu commented on a change in pull request #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#discussion_r382961507
 
 

 ##########
 File path: common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
 ##########
 @@ -158,6 +158,43 @@ public void addValue(final String statsKey, final int incValue, final int incTim
         statsItem.getTimes().addAndGet(incTimes);
     }
 
+    public void delValue(final String statsKey) {
+        StatsItem statsItem = this.statsItemTable.get(statsKey);
+        if (null != statsItem) {
+            this.statsItemTable.remove(statsKey);
+        }
+    }
+
+    public void delValueByFirstKey(final String statsKey, String separator) {
 
 Review comment:
   I thinks the method name "delValueByFirstKey" may not be suitable.And may be you can rename it, such as "delValueByPrefixKey";
   
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] zongtanghu commented on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
zongtanghu commented on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#issuecomment-590023702
 
 
   @duhenglucky @RongtongJin please help to review this pr together.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] coveralls edited a comment on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#issuecomment-590021346
 
 
   
   [![Coverage Status](https://coveralls.io/builds/29880953/badge)](https://coveralls.io/builds/29880953)
   
   Coverage decreased (-0.1%) to 50.854% when pulling **f26195df79bbc973d7996c49975879650bd40eee on zhanghaou:develop** into **c5e5f8dd6e2ff22e6d433880cce2d789640cfa29 on apache:develop**.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] zongtanghu commented on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
zongtanghu commented on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#issuecomment-604829924
 
 
   It looks good, I approve this pr.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] zhanghaou commented on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
zhanghaou commented on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#issuecomment-610715954
 
 
   @duhenglucky Is something wrong with coverage test?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] coveralls edited a comment on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#issuecomment-590021346
 
 
   
   [![Coverage Status](https://coveralls.io/builds/29876967/badge)](https://coveralls.io/builds/29876967)
   
   Coverage decreased (-0.04%) to 50.945% when pulling **313a0249f77e4193e0aa1e8a80f6a11c7b3b131d on zhanghaou:develop** into **c5e5f8dd6e2ff22e6d433880cce2d789640cfa29 on apache:develop**.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] coveralls commented on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
coveralls commented on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#issuecomment-590021346
 
 
   
   [![Coverage Status](https://coveralls.io/builds/28900544/badge)](https://coveralls.io/builds/28900544)
   
   Coverage increased (+0.02%) to 51.024% when pulling **550f99682717bf3f8cb3081b6b1e763533995b8d on zhanghaou:develop** into **35c38888e0d5678fb4aaad5ba8534b7552d9a9a0 on apache:develop**.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] coveralls edited a comment on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#issuecomment-590021346
 
 
   
   [![Coverage Status](https://coveralls.io/builds/29877707/badge)](https://coveralls.io/builds/29877707)
   
   Coverage decreased (-0.1%) to 50.889% when pulling **9032e05975dab52fa764767345edb0a75561197c on zhanghaou:develop** into **c5e5f8dd6e2ff22e6d433880cce2d789640cfa29 on apache:develop**.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] codecov-io commented on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
codecov-io commented on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#issuecomment-609765102
 
 
   # [Codecov](https://codecov.io/gh/apache/rocketmq/pull/1786?src=pr&el=h1) Report
   > :exclamation: No coverage uploaded for pull request base (`develop@35c3888`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/rocketmq/pull/1786/graphs/tree.svg?width=650&height=150&src=pr&token=4w0sxP1wZv)](https://codecov.io/gh/apache/rocketmq/pull/1786?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##             develop    #1786   +/-   ##
   ==========================================
     Coverage           ?   45.12%           
     Complexity         ?     4205           
   ==========================================
     Files              ?      544           
     Lines              ?    35792           
     Branches           ?     4758           
   ==========================================
     Hits               ?    16150           
     Misses             ?    17597           
     Partials           ?     2045           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/rocketmq/pull/1786?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/rocketmq/pull/1786?src=pr&el=footer). Last update [35c3888...313a024](https://codecov.io/gh/apache/rocketmq/pull/1786?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] zongtanghu commented on a change in pull request #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
zongtanghu commented on a change in pull request #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#discussion_r382961532
 
 

 ##########
 File path: common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
 ##########
 @@ -158,6 +158,43 @@ public void addValue(final String statsKey, final int incValue, final int incTim
         statsItem.getTimes().addAndGet(incTimes);
     }
 
+    public void delValue(final String statsKey) {
+        StatsItem statsItem = this.statsItemTable.get(statsKey);
+        if (null != statsItem) {
+            this.statsItemTable.remove(statsKey);
+        }
+    }
+
+    public void delValueByFirstKey(final String statsKey, String separator) {
+        Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
+        while (it.hasNext()) {
+            Entry<String, StatsItem> next = it.next();
+            if (next.getKey().startsWith(statsKey + separator)) {
+                it.remove();
+            }
+        }
+    }
+
+    public void delValueByMidKey(final String statsKey, String separator) {
+        Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
+        while (it.hasNext()) {
+            Entry<String, StatsItem> next = it.next();
+            if (next.getKey().contains(separator + statsKey + separator)) {
+                it.remove();
+            }
+        }
+    }
+
+    public void delValueByLastKey(final String statsKey, String separator) {
 
 Review comment:
   the same as above.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] zhanghaou commented on a change in pull request #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
zhanghaou commented on a change in pull request #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#discussion_r382963181
 
 

 ##########
 File path: common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
 ##########
 @@ -158,6 +158,43 @@ public void addValue(final String statsKey, final int incValue, final int incTim
         statsItem.getTimes().addAndGet(incTimes);
     }
 
+    public void delValue(final String statsKey) {
+        StatsItem statsItem = this.statsItemTable.get(statsKey);
+        if (null != statsItem) {
+            this.statsItemTable.remove(statsKey);
+        }
+    }
+
+    public void delValueByFirstKey(final String statsKey, String separator) {
 
 Review comment:
   I have renamed all.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] zongtanghu commented on a change in pull request #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
zongtanghu commented on a change in pull request #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#discussion_r382961535
 
 

 ##########
 File path: common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
 ##########
 @@ -158,6 +158,43 @@ public void addValue(final String statsKey, final int incValue, final int incTim
         statsItem.getTimes().addAndGet(incTimes);
     }
 
+    public void delValue(final String statsKey) {
+        StatsItem statsItem = this.statsItemTable.get(statsKey);
+        if (null != statsItem) {
+            this.statsItemTable.remove(statsKey);
+        }
+    }
+
+    public void delValueByFirstKey(final String statsKey, String separator) {
+        Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
+        while (it.hasNext()) {
+            Entry<String, StatsItem> next = it.next();
+            if (next.getKey().startsWith(statsKey + separator)) {
+                it.remove();
+            }
+        }
+    }
+
+    public void delValueByMidKey(final String statsKey, String separator) {
 
 Review comment:
   the same as above

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] coveralls edited a comment on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on issue #1786: [ISSUE #1689]add interfaces to remove unused statsItems in BrokerStatsManager
URL: https://github.com/apache/rocketmq/pull/1786#issuecomment-590021346
 
 
   
   [![Coverage Status](https://coveralls.io/builds/28900862/badge)](https://coveralls.io/builds/28900862)
   
   Coverage increased (+0.02%) to 51.021% when pulling **45338147f2d61cdff4fd30dc89b5765e65220b85 on zhanghaou:develop** into **35c38888e0d5678fb4aaad5ba8534b7552d9a9a0 on apache:develop**.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services