HADOOP-8177. MBeans shouldn't try to register when it fails to create MBeanName. (Contributed by Devaraj K).

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1302067 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uma Maheswara Rao G 2012-03-18 05:54:33 +00:00
parent 0ac5e89419
commit a019a6f7c9
2 changed files with 17 additions and 12 deletions

View File

@ -54,6 +54,9 @@ Trunk (unreleased changes)
BUG FIXES
HADOOP-8177. MBeans shouldn't try to register when it fails to create MBeanName.
(Devaraj K via umamahesh)
HADOOP-7900. LocalDirAllocator confChanged() accesses conf.get() twice
(Ravi Gummadi via Uma Maheswara Rao G)

View File

@ -53,19 +53,21 @@ static public ObjectName register(String serviceName, String nameName,
Object theMbean) {
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName name = getMBeanName(serviceName, nameName);
try {
mbs.registerMBean(theMbean, name);
LOG.debug("Registered "+ name);
return name;
} catch (InstanceAlreadyExistsException iaee) {
if (LOG.isTraceEnabled()) {
LOG.trace("Failed to register MBean \""+ name + "\"", iaee);
} else {
LOG.warn("Failed to register MBean \""+ name
+ "\": Instance already exists.");
if (name != null) {
try {
mbs.registerMBean(theMbean, name);
LOG.debug("Registered " + name);
return name;
} catch (InstanceAlreadyExistsException iaee) {
if (LOG.isTraceEnabled()) {
LOG.trace("Failed to register MBean \"" + name + "\"", iaee);
} else {
LOG.warn("Failed to register MBean \"" + name
+ "\": Instance already exists.");
}
} catch (Exception e) {
LOG.warn("Failed to register MBean \"" + name + "\"", e);
}
} catch (Exception e) {
LOG.warn("Failed to register MBean \""+ name + "\"", e);
}
return null;
}