-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-25002 Create simple pattern matching query for retrieving metri… #2370
Conversation
…cs matching the pattern
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@@ -125,11 +130,13 @@ public int write(MBeanServer mBeanServer, ObjectName qry, String attribute, | |||
*/ | |||
private static int write(JsonWriter writer, MBeanServer mBeanServer, ObjectName qry, | |||
String attribute, boolean description) throws IOException { | |||
LOG.trace("Listing beans for " + qry); | |||
LOG.debug("Listing beans for " + qry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted this log level change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it so that later we can debug it to know what is the query. Generally setting debug level is what we do for debugging so I just changed it. I can revert it if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to change. Can u also change to use {} format log line. Anyways that will be nice to have
Set<ObjectName> names = null; | ||
names = mBeanServer.queryNames(qry, null); | ||
writer.name("beans").beginArray(); | ||
Iterator<ObjectName> it = names.iterator(); | ||
boolean pattern = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can avoid this boolean. Just use String[] and check for null value and call diff write methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
if (pattern != null) { | ||
boolean matchFound = false; | ||
for (String patt : pattern) { | ||
Pattern compile = Pattern.compile(patt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are compiling this pattern for each and every MBean attribute. This will be costly. we could have compiled the attribute and kept that in an Array at 1st step itself (instead of keeping the regex patterns in String[])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya ok . I did not do it thinking we are not doing this thing much often. May be once a while. I can change it though.
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few nits
@@ -125,11 +130,13 @@ public int write(MBeanServer mBeanServer, ObjectName qry, String attribute, | |||
*/ | |||
private static int write(JsonWriter writer, MBeanServer mBeanServer, ObjectName qry, | |||
String attribute, boolean description) throws IOException { | |||
LOG.trace("Listing beans for " + qry); | |||
LOG.debug("Listing beans for " + qry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to change. Can u also change to use {} format log line. Anyways that will be nice to have
@@ -216,7 +239,12 @@ private static int write(JsonWriter writer, MBeanServer mBeanServer, ObjectName | |||
} else { | |||
MBeanAttributeInfo[] attrs = minfo.getAttributes(); | |||
for (int i = 0; i < attrs.length; i++) { | |||
writeAttribute(writer, mBeanServer, oname, description, attrs[i]); | |||
if (matchingPattern != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Infact u can see we dont need such if else, end of the day we call same writeAttribute which is having Pattern[] arg and we have null check there anyways.
@@ -225,8 +253,14 @@ private static int write(JsonWriter writer, MBeanServer mBeanServer, ObjectName | |||
return 0; | |||
} | |||
|
|||
private static void writeAttribute(final JsonWriter jg, final MBeanServer mBeanServer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya even this also not needed.
|
||
if (pattern != null) { | ||
boolean matchFound = false; | ||
for (Pattern compile : pattern) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call its pattern : patterns?
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
Thanks for the reviews @saintstack and @anoopsjohn . |
apache#2370) * HBASE-25002 Create simple pattern matching query for retrieving metrics matching the pattern * Address review comments * Final set of comments addressed * Address checkstyle comments
#2370) (#2398) * HBASE-25002 Create simple pattern matching query for retrieving metrics matching the pattern * Address review comments * Final set of comments addressed * Address checkstyle comments
apache#2370) (apache#2398) * HBASE-25002 Create simple pattern matching query for retrieving metrics matching the pattern * Address review comments * Final set of comments addressed * Address checkstyle comments
Supports a pattern for getting a JMX metrics. This is helpful when we have multiple metrics under a the Tables category, then fetching the entire metric under Tables may be very big. So this helps to fetch a certain pattern of metrics alone and returns them as JSON.
The format is
http://../jmx?get=Hadoop:service=HBase,name=RegionServer,sub=Tables::[a-zA-z_0-9]*memStoreSize,[a-zA-z_0-9]*storeFileSize