Hadoop Common
  1. Hadoop Common
  2. HADOOP-8177

MBeans shouldn't try to register when it fails to create MBeanName

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.24.0
    • Fix Version/s: 3.0.0
    • Component/s: metrics
    • Labels:
      None
    • Target Version/s:
    • Hadoop Flags:
      Reviewed

      Description

      MBeans.java
        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.");
            }
          } catch (Exception e) {
            LOG.warn("Failed to register MBean \""+ name + "\"", e);
          }
          return null;
        }
      
        static private ObjectName getMBeanName(String serviceName, String nameName) {
          ObjectName name = null;
          String nameStr = "Hadoop:service="+ serviceName +",name="+ nameName;
          try {
            name = DefaultMetricsSystem.newMBeanName(nameStr);
          } catch (Exception e) {
            LOG.warn("Error creating MBean object name: "+ nameStr, e);
          }
          return name;
        }
      

      In getMBeanName() if DefaultMetricsSystem.newMBeanName(nameStr); fails with some reason like mbean already exists, getMBeanName() logs the exception and returns null and mbs.registerMBean(theMbean, name) in register() tries to register with null and throws exception with the message 'Failed to register MBean "null"'.

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Devaraj K
            Reporter:
            Devaraj K
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development