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

ZOOKEEPER-2822: Wrong ObjectName about MBeanServer in JMX module #294

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion zookeeper-docs/src/main/resources/markdown/zookeeperJMX.md
Expand Up @@ -84,7 +84,10 @@ interest is the ability to dynamically change the logging levels
used by editing the appender and root thresholds. Log4j MBean
registration can be disabled by passing
_-Dzookeeper.jmx.log4j.disable=true_ to the JVM
when starting ZooKeeper.
when starting ZooKeeper. In addition, we can specify the name of
the MBean with the _-Dzookeeper.jmx.log4j.mbean=log4j:hierarchy=default_
option, in case we need to upgrade an integrated system
using the old MBean name (`log4j:hiearchy = default`).

<a name="ch_reference"></a>

Expand Down
Expand Up @@ -33,13 +33,13 @@
public class ManagedUtil {
private static final Logger LOG = LoggerFactory.getLogger(ManagedUtil.class);

private static final boolean isLog4jJmxEnabled() {
private static boolean isLog4jJmxEnabled() {
boolean enabled = false;

try {
Class.forName("org.apache.log4j.spi.LoggerRepository");

if (Boolean.getBoolean("zookeeper.jmx.log4j.disable") == true) {
if (Boolean.getBoolean("zookeeper.jmx.log4j.disable")) {
LOG.info("Log4j found but jmx support is disabled.");
} else {
enabled = true;
Expand Down Expand Up @@ -69,9 +69,10 @@ public static void registerLog4jMBeans() throws JMException {
try {
// Create and Register the top level Log4J MBean
// org.apache.log4j.jmx.HierarchyDynamicMBean hdm = new org.apache.log4j.jmx.HierarchyDynamicMBean();
Object hdm = Class.forName("org.apache.log4j.jmx.HierarchyDynamicMBean").getDeclaredConstructor().newInstance();
Object hdm = Class.forName("org.apache.log4j.jmx.HierarchyDynamicMBean").getConstructor().newInstance();

ObjectName mbo = new ObjectName("log4j:hiearchy=default");
String mbean = System.getProperty("zookeeper.jmx.log4j.mbean", "log4j:hierarchy=default");
ObjectName mbo = new ObjectName(mbean);
mbs.registerMBean(hdm, mbo);

// Add the root logger to the Hierarchy MBean
Expand Down