-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
ZOOKEEPER-2822: Wrong ObjectName
about MBeanServer
in JMX module
#294
Conversation
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.
@@ -71,7 +71,7 @@ public static void registerLog4jMBeans() throws JMException { | |||
// org.apache.log4j.jmx.HierarchyDynamicMBean hdm = new org.apache.log4j.jmx.HierarchyDynamicMBean(); | |||
Object hdm = Class.forName("org.apache.log4j.jmx.HierarchyDynamicMBean").getDeclaredConstructor().newInstance(); | |||
|
|||
ObjectName mbo = new ObjectName("log4j:hiearchy=default"); | |||
ObjectName mbo = new ObjectName("log4j:hierarchy=default"); |
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.
Is change may have an impact on integrated systems.
Maybe we could make this name configurable so that people will be able to revert the name.
This change can be only in master (3.6.0) as it is a public configuration/API 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.
Hi, @eolivelli . Thanks for your reviewing. Indeed, turning it into a configurable one would be very helpful in upgrading an integrated system. So, let's be clear, should we add a new JVM option or add a new environment variable to the operating system?
I would go for a system property |
@eolivelli Yep, I agree with you. |
|
||
ObjectName mbo = new ObjectName("log4j:hiearchy=default"); | ||
String mbean = System.getenv("zookeeper.jmx.log4j.mbean"); |
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 should use System.getProperty(name,defaultvalue)
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 would go for a system property
FYI, System.getenv()
is for Operating System environment variables, whereas System.getProperty()
is for JVM arguments which are passed as -DpropName=value
to Java application launcher.
So, maybe use getenv()
would be more reasonable.
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.
As far as I know in ZK it is common to use System Properties and not environment variables.
I think that the launcher for the server process is setting as system property every configuration parameter.
Do you have any example of usages of getEnv in ZooKeeper ?
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.
@eolivelli Okay, I will modify it.
We should also add the property to the docs |
@eolivelli Thanks for your comment. I will describe this variable in |
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.
Nice catch @asdf2014 ! Thanks for providing the patch.
I support the idea of making it configurable and for that please use System.getProperty()
, it's standard across ZooKeeper.
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.
+1
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.
+1
awesome work @asdf2014
@eolivelli @anmolnar Thanks for your approval. |
retest this please |
1 similar comment
retest this please |
Hi, @anmolnar @eolivelli . Is there anything I need to do before we merge this PR? |
@anmolnar green lights from CI This is a trivial patch, do you need another committer ? |
The wrong `ObjectName` about `MBeanServer` in JMX module, should `log4j:hierarchy=default` rather than `log4j:hiearchy=default`. Author: asdf2014 <benedictjin2016@gmail.com> Reviewers: andor@apache.org Closes #294 from asdf2014/ZOOKEEPER-2822 and squashes the following commits: 294cf53 [asdf2014] Using `System.getProperty` instead of `System.getenv` & doc this change ed756a9 [asdf2014] Add `zookeeper.jmx.log4j.mbean` 82da83a [asdf2014] ZOOKEEPER-2822: Wrong `ObjectName` about `MBeanServer` in JMX module (cherry picked from commit 91c6cb2) Signed-off-by: Andor Molnar <andor@apache.org>
Committed to master and 3.5 branches. Thanks @asdf2014 ! |
You are welcome. |
The wrong `ObjectName` about `MBeanServer` in JMX module, should `log4j:hierarchy=default` rather than `log4j:hiearchy=default`. Author: asdf2014 <benedictjin2016@gmail.com> Reviewers: andor@apache.org Closes apache#294 from asdf2014/ZOOKEEPER-2822 and squashes the following commits: 294cf53 [asdf2014] Using `System.getProperty` instead of `System.getenv` & doc this change ed756a9 [asdf2014] Add `zookeeper.jmx.log4j.mbean` 82da83a [asdf2014] ZOOKEEPER-2822: Wrong `ObjectName` about `MBeanServer` in JMX module
The wrong
ObjectName
aboutMBeanServer
in JMX module, shouldlog4j:hierarchy=default
rather thanlog4j:hiearchy=default
.