kenliao94 commented on PR #1288:
URL: https://github.com/apache/activemq/pull/1288#issuecomment-3341439512

   Actually thanks for the comment. I caught a bug. The TotalManaged counts 
suppressed one as well. I,E `safeGetBroker().getTopicViews().size()` returns 
suppressed ones as well
   However, when I do more deep dive, It turns out that there is no map that 
stores managed destinations. The getQueues()  and getTopics()  are doing the 
filtering everytime it is called because of that. When a MBean is registered, 
it internally invokes isAllowedToRegister to check if a given MBean can be 
registered and register it if allowed. But instead of storing different maps 
categorized by destination, it is a single map of all registered MBeans. Hence, 
to get the total number of managed queue or topic, we need to iterate a list of 
queue or topic and invoke isAllowedToRegister again every time (similar to how 
onlyNonSuppressed work, it is not retrieving a cached value, but iterate over a 
set and check everytime).
   
   For now, I agree with your suggestion on exposing the APIs and what do that 
suppose to mean. I changed the name of those metrics "NonSuppressed" -> 
"Managed" and added the testcase to test for suppressed destination. The only 
thing I rollback to, is that I need to first generate the array first and reads 
the size, the inefficiency you initially pointed out.
   ```
     @Override
     public int getTotalManagedTopicsCount() {
         return safeGetBroker().getTopicsNonSuppressed().length;
     }
   ```
   
   That said, I can follow up with another PR that changes the way how the 
ManagementContext stores the registered destination, such that 
getTotalManagedQueuesCount and getTotalManagedTopicsCount can be done by 
reading a map size and it won't be a API / breaking change, so it can be done 
in a patch version. WDYT? @mattrpav 


-- 
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: gitbox-unsubscr...@activemq.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org
For additional commands, e-mail: gitbox-h...@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact


Reply via email to