Explorar o código

AMBARI-6325. HA Wizard: can't initialize JournalNodes. (swagle)

Siddharth Wagle %!s(int64=11) %!d(string=hai) anos
pai
achega
996b4d6b9e

+ 6 - 1
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java

@@ -316,8 +316,13 @@ public abstract class AbstractPropertyProvider extends BaseProvider implements P
    * Verify if the property category is supported
    */
   protected boolean checkPropertyCategory(String propertyId) {
-    String category = PropertyHelper.getPropertyCategory(propertyId);
     Set<String> categoryIds = getCategoryIds();
+    // Support query by category
+    if (categoryIds.contains(propertyId)) {
+      return true;
+    }
+
+    String category = PropertyHelper.getPropertyCategory(propertyId);
     while (category != null) {
       if(categoryIds.contains(category)) {
         return true;

+ 20 - 0
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractPropertyProviderTest.java

@@ -59,6 +59,26 @@ public class AbstractPropertyProviderTest {
     Assert.assertTrue(propertyInfoMap.containsKey("metrics/disk/part_max_used"));
   }
 
+  @Test
+  public void testGetJMXPropertyInfoMap() {
+    AbstractPropertyProvider provider = new TestPropertyProvider(
+      PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent));
+
+    // top level category
+    Map<String, PropertyInfo> propertyInfoMap = provider.getPropertyInfoMap("DATANODE", "metrics");
+    Assert.assertEquals(86, propertyInfoMap.size());
+
+    // specific property
+    propertyInfoMap = provider.getPropertyInfoMap("DATANODE", "metrics/rpc/RpcQueueTime_avg_time");
+    Assert.assertEquals(1, propertyInfoMap.size());
+    Assert.assertTrue(propertyInfoMap.containsKey("metrics/rpc/RpcQueueTime_avg_time"));
+
+    // category
+    propertyInfoMap = provider.getPropertyInfoMap("DATANODE", "metrics/rpc/");
+    Assert.assertEquals(12, propertyInfoMap.size());
+    Assert.assertTrue(propertyInfoMap.containsKey("metrics/rpc/RpcQueueTime_avg_time"));
+  }
+
   @Test
   public void testSubstituteArguments() throws Exception
   {