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 2022/06/01 11:38:24 UTC

[GitHub] [rocketmq] caigy commented on a diff in pull request #4395: [iSSUE-4396] Support get all producer on one broker

caigy commented on code in PR #4395:
URL: https://github.com/apache/rocketmq/pull/4395#discussion_r886596318


##########
broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java:
##########
@@ -46,6 +50,32 @@ public ConcurrentHashMap<String, ConcurrentHashMap<Channel, ClientChannelInfo>>
         return groupChannelTable;
     }
 
+    public ProducerTableInfo getProducerTable(){
+        Map<String, List<ProducerInfo>> map = new HashMap<>();
+        for(String group: this.groupChannelTable.keySet()){
+            for(Entry<Channel, ClientChannelInfo> entry: this.groupChannelTable.get(group).entrySet()){
+                if(map.containsKey(group)){
+                    map.get(group).add(new ProducerInfo(
+                            entry.getValue().getClientId(),
+                            entry.getValue().getChannel().remoteAddress().toString(),
+                            entry.getValue().getLanguage(),
+                            entry.getValue().getVersion(),
+                            entry.getValue().getLastUpdateTimestamp()
+                    ));
+                }else{
+                    map.put(group, new ArrayList<ProducerInfo>(Collections.singleton(new ProducerInfo(
+                            entry.getValue().getClientId(),
+                            entry.getValue().getChannel().remoteAddress().toString(),
+                            entry.getValue().getLanguage(),
+                            entry.getValue().getVersion(),
+                            entry.getValue().getLastUpdateTimestamp()

Review Comment:
   It may be better to defining a variable for `entry.getValue()` and reuse it.



-- 
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: dev-unsubscribe@rocketmq.apache.org

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