Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern objectname #30

Closed
wants to merge 3 commits into from
Closed

Pattern objectname #30

wants to merge 3 commits into from

Conversation

ngzhian
Copy link
Contributor

@ngzhian ngzhian commented Aug 17, 2014

Merge the HEAD of ganglia:master into this fix for #3.
Malformed patterns are ignored and valid patterns are expanded into ObjectNames and added to the sampler one-by-one.

List<MBeanAttribute> getAttributesForMBean(Node mBean, String sampleDMax)
throws Exception {
String mBeanName = selectParameterFromNode(mBean, "name", null);
String mBeanPublishName = selectParameterFromNode(mBean, "pname", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the mBean name contained a wildcard and multiple MBeans matched the wildcard, we can't have all of them using an identical pname. Somehow, the pname needs to be changed for each. As suggested in my comment #3 (comment) in June, this can probably be implemented using regex groups. This involves two things:

  • one or more wildcard(s) in the mBeanName would be wrapped in parentheses
  • the pname attribute would contain some kind of placeholder for inserting the groups

The MessageFormat class may be suitable for expanding placeholders in pname.

Then the XML would contain something like:

<mbean name='org.hornetq:module=Core,type=Queue,address="jms.queue.(*)",name="jms.queue.*"' pname="queue_{0}">
                        <attribute name="MessageCount" type="int32" slope="both"/>
                        <attribute name="ConsumerCount" type="int32" slope="both"/>
                </mbean>

and then if there were three queues with names like jms.queue.testA, jms.queue.testB and jms.queue.testC, the derived mBeanPublishName values, after replacement of the {0} placeholder would be queue_testA, queue_testB and queue_testC

Each mbean name given in the XML configuration file is expanded using
the query method of MBeanServer.

The query method takes in an ObjectName and returns all registered MBeans that
matches it.

If there is an error, for example a typo in the configuration, the malformed
MBean isn't added to the MBeanSampler.
Properly formed patterns are expanded into ObjectName
 and queried individually.
@ngzhian
Copy link
Contributor Author

ngzhian commented Aug 18, 2014

@dpocock i looked at your suggestion and tweaked it a bit.
Instead of adding a new attribute to the xml node, address, I used the name instead.
The method of interest is buildPname, which takes in the queried name (the full unique mbean name that fits the wildcard patten, the pattern that was searched for i.e. name attribute in config, and the pname from the node i.e. pname attribute in config.

@ngzhian ngzhian closed this Mar 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants