MBeans { public static String getMbeanNameName(final ObjectName objectName) { Matcher matcher = MBEAN_NAME_PATTERN.matcher(objectName.toString()); if (matcher.matches()) { return matcher.group(2); } else { throw new IllegalArgumentException( objectName + " is not a valid Hadoop mbean"); } } private  MBeans(); static ObjectName register(String serviceName, String nameName,
                                    Object theMbean); static ObjectName register(String serviceName, String nameName,
                                    Map<String, String> properties,
                                    Object theMbean); static String getMbeanNameService(final ObjectName objectName); static String getMbeanNameName(final ObjectName objectName); static void unregister(ObjectName mbeanName);  }
@Test public void testGetMbeanNameName() { HashMap<String, String> properties = new HashMap<>(); ObjectName mBeanName = MBeans.getMBeanName("Service", "Name", properties); Assert.assertEquals("Service", MBeans.getMbeanNameService(mBeanName)); properties.put("key", "value"); mBeanName = MBeans.getMBeanName( "Service", "Name", properties); Assert.assertEquals("Service", MBeans.getMbeanNameService(mBeanName)); }