@Test public void testProcessRpcMetricDefinition() { org.apache.ambari.server.state.stack.Metric metric = new org.apache.ambari.server.state.stack.Metric("rpcdetailed.rpcdetailed.FsyncAvgTime", false, true, false, "unitless"); Map<String, Metric> replacementMap = PropertyHelper.processRpcMetricDefinition("ganglia", "NAMENODE", "metrics/rpcdetailed/fsync_avg_time", metric); Assert.assertNotNull(replacementMap); Assert.assertEquals(3, replacementMap.size()); Assert.assertTrue(replacementMap.containsKey("metrics/rpcdetailed/client/fsync_avg_time")); Assert.assertTrue(replacementMap.containsKey("metrics/rpcdetailed/datanode/fsync_avg_time")); Assert.assertTrue(replacementMap.containsKey("metrics/rpcdetailed/healthcheck/fsync_avg_time")); Assert.assertEquals("rpcdetailed.rpcdetailed.client.FsyncAvgTime", replacementMap.get("metrics/rpcdetailed/client/fsync_avg_time").getName()); Assert.assertEquals("rpcdetailed.rpcdetailed.datanode.FsyncAvgTime", replacementMap.get("metrics/rpcdetailed/datanode/fsync_avg_time").getName()); Assert.assertEquals("rpcdetailed.rpcdetailed.healthcheck.FsyncAvgTime", replacementMap.get("metrics/rpcdetailed/healthcheck/fsync_avg_time").getName()); metric = new org.apache.ambari.server.state.stack.Metric("Hadoop:service=NameNode,name=RpcDetailedActivity.FsyncAvgTime", true, false, false, "unitless"); replacementMap = PropertyHelper.processRpcMetricDefinition("jmx", "NAMENODE", "metrics/rpcdetailed/fsync_avg_time", metric); Assert.assertNotNull(replacementMap); Assert.assertEquals(3, replacementMap.size()); Assert.assertTrue(replacementMap.containsKey("metrics/rpcdetailed/client/fsync_avg_time")); Assert.assertTrue(replacementMap.containsKey("metrics/rpcdetailed/datanode/fsync_avg_time")); Assert.assertTrue(replacementMap.containsKey("metrics/rpcdetailed/healthcheck/fsync_avg_time")); Assert.assertEquals("Hadoop:service=NameNode,name=RpcDetailedActivity,tag=client.FsyncAvgTime", replacementMap.get("metrics/rpcdetailed/client/fsync_avg_time").getName()); Assert.assertEquals("Hadoop:service=NameNode,name=RpcDetailedActivity,tag=datanode.FsyncAvgTime", replacementMap.get("metrics/rpcdetailed/datanode/fsync_avg_time").getName()); Assert.assertEquals("Hadoop:service=NameNode,name=RpcDetailedActivity,tag=healthcheck.FsyncAvgTime", replacementMap.get("metrics/rpcdetailed/healthcheck/fsync_avg_time").getName()); metric = new org.apache.ambari.server.state.stack.Metric("Hadoop:service=NameNode,name=RpcActivity.RpcQueueTime_avg_time", true, false, false, "unitless"); replacementMap = PropertyHelper.processRpcMetricDefinition("jmx", "NAMENODE", "metrics/rpc/RpcQueueTime_avg_time", metric); Assert.assertNotNull(replacementMap); Assert.assertEquals(3, replacementMap.size()); Assert.assertTrue(replacementMap.containsKey("metrics/rpc/client/RpcQueueTime_avg_time")); Assert.assertTrue(replacementMap.containsKey("metrics/rpc/datanode/RpcQueueTime_avg_time")); Assert.assertTrue(replacementMap.containsKey("metrics/rpc/healthcheck/RpcQueueTime_avg_time")); Assert.assertEquals("Hadoop:service=NameNode,name=RpcActivity,tag=client.RpcQueueTime_avg_time", replacementMap.get("metrics/rpc/client/RpcQueueTime_avg_time").getName()); Assert.assertEquals("Hadoop:service=NameNode,name=RpcActivity,tag=datanode.RpcQueueTime_avg_time", replacementMap.get("metrics/rpc/datanode/RpcQueueTime_avg_time").getName()); Assert.assertEquals("Hadoop:service=NameNode,name=RpcActivity,tag=healthcheck.RpcQueueTime_avg_time", replacementMap.get("metrics/rpc/healthcheck/RpcQueueTime_avg_time").getName()); }
public static Map<String, org.apache.ambari.server.state.stack.Metric> processRpcMetricDefinition(String metricType, String componentName, String propertyId, org.apache.ambari.server.state.stack.Metric metric) { Map<String, org.apache.ambari.server.state.stack.Metric> replacementMap = null; if (componentName.equalsIgnoreCase("NAMENODE")) { for (Map.Entry<String, List<String>> entry : RPC_METRIC_SUFFIXES.entrySet()) { String prefix = entry.getKey(); if (propertyId.startsWith(prefix)) { replacementMap = new HashMap<>(); for (String suffix : entry.getValue()) { String newMetricName; if ("jmx".equals(metricType)) { newMetricName = insertTagIntoCategoty(suffix, metric.getName()); } else { newMetricName = insertTagInToMetricName(suffix, metric.getName(), prefix); } org.apache.ambari.server.state.stack.Metric newMetric = new org.apache.ambari.server.state.stack.Metric( newMetricName, metric.isPointInTime(), metric.isTemporal(), metric.isAmsHostMetric(), metric.getUnit() ); replacementMap.put(insertTagInToMetricName(suffix, propertyId, prefix), newMetric); } } } } return replacementMap; }
PropertyHelper { public static Map<String, org.apache.ambari.server.state.stack.Metric> processRpcMetricDefinition(String metricType, String componentName, String propertyId, org.apache.ambari.server.state.stack.Metric metric) { Map<String, org.apache.ambari.server.state.stack.Metric> replacementMap = null; if (componentName.equalsIgnoreCase("NAMENODE")) { for (Map.Entry<String, List<String>> entry : RPC_METRIC_SUFFIXES.entrySet()) { String prefix = entry.getKey(); if (propertyId.startsWith(prefix)) { replacementMap = new HashMap<>(); for (String suffix : entry.getValue()) { String newMetricName; if ("jmx".equals(metricType)) { newMetricName = insertTagIntoCategoty(suffix, metric.getName()); } else { newMetricName = insertTagInToMetricName(suffix, metric.getName(), prefix); } org.apache.ambari.server.state.stack.Metric newMetric = new org.apache.ambari.server.state.stack.Metric( newMetricName, metric.isPointInTime(), metric.isTemporal(), metric.isAmsHostMetric(), metric.getUnit() ); replacementMap.put(insertTagInToMetricName(suffix, propertyId, prefix), newMetric); } } } } return replacementMap; } }
PropertyHelper { public static Map<String, org.apache.ambari.server.state.stack.Metric> processRpcMetricDefinition(String metricType, String componentName, String propertyId, org.apache.ambari.server.state.stack.Metric metric) { Map<String, org.apache.ambari.server.state.stack.Metric> replacementMap = null; if (componentName.equalsIgnoreCase("NAMENODE")) { for (Map.Entry<String, List<String>> entry : RPC_METRIC_SUFFIXES.entrySet()) { String prefix = entry.getKey(); if (propertyId.startsWith(prefix)) { replacementMap = new HashMap<>(); for (String suffix : entry.getValue()) { String newMetricName; if ("jmx".equals(metricType)) { newMetricName = insertTagIntoCategoty(suffix, metric.getName()); } else { newMetricName = insertTagInToMetricName(suffix, metric.getName(), prefix); } org.apache.ambari.server.state.stack.Metric newMetric = new org.apache.ambari.server.state.stack.Metric( newMetricName, metric.isPointInTime(), metric.isTemporal(), metric.isAmsHostMetric(), metric.getUnit() ); replacementMap.put(insertTagInToMetricName(suffix, propertyId, prefix), newMetric); } } } } return replacementMap; }  }
PropertyHelper { public static Map<String, org.apache.ambari.server.state.stack.Metric> processRpcMetricDefinition(String metricType, String componentName, String propertyId, org.apache.ambari.server.state.stack.Metric metric) { Map<String, org.apache.ambari.server.state.stack.Metric> replacementMap = null; if (componentName.equalsIgnoreCase("NAMENODE")) { for (Map.Entry<String, List<String>> entry : RPC_METRIC_SUFFIXES.entrySet()) { String prefix = entry.getKey(); if (propertyId.startsWith(prefix)) { replacementMap = new HashMap<>(); for (String suffix : entry.getValue()) { String newMetricName; if ("jmx".equals(metricType)) { newMetricName = insertTagIntoCategoty(suffix, metric.getName()); } else { newMetricName = insertTagInToMetricName(suffix, metric.getName(), prefix); } org.apache.ambari.server.state.stack.Metric newMetric = new org.apache.ambari.server.state.stack.Metric( newMetricName, metric.isPointInTime(), metric.isTemporal(), metric.isAmsHostMetric(), metric.getUnit() ); replacementMap.put(insertTagInToMetricName(suffix, propertyId, prefix), newMetric); } } } } return replacementMap; }  static String getPropertyId(String category, String name); static Set<String> getPropertyIds(Resource.Type resourceType); static Set<String> getPropertyIds(Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap ); static Map<String, Map<String, PropertyInfo>> getMetricPropertyIds(Resource.Type resourceType); static Map<String, Map<String, PropertyInfo>> getSQLServerPropertyIds(Resource.Type resourceType); static Map<String, Map<String, PropertyInfo>> getJMXPropertyIds(Resource.Type resourceType); static Map<Resource.Type, String> getKeyPropertyIds(Resource.Type resourceType); static String getPropertyName(String absProperty); static String getPropertyCategory(String property); static Set<String> getCategories(Set<String> propertyIds); static boolean containsProperty(Set<String> propertyIds, String propertyId); static boolean containsArguments(String propertyId); static Set<String> getAssociatedPropertyIds(Request request); static Map<String, Object> getProperties(Resource resource); static Request getCreateRequest(Set<Map<String, Object>> properties,
                                         Map<String, String> requestInfoProperties); static Request getReadRequest(Set<String> propertyIds); static Request getReadRequest(Set<String> propertyIds, Map<String,
      TemporalInfo> mapTemporalInfo); static Request getReadRequest(Set<String> propertyIds,
      Map<String, String> requestInfoProperties,
      Map<String, TemporalInfo> mapTemporalInfo, PageRequest pageRequest,
      SortRequest sortRequest); static Request getReadRequest(String ... propertyIds); static Request getUpdateRequest(Map<String, Object> properties,
                                         Map<String, String> requestInfoProperties); static void updateMetricsWithAggregateFunctionSupport(Map<String, Map<String, PropertyInfo>> metrics); static boolean hasAggregateFunctionSuffix(String propertyId); static Map<String, org.apache.ambari.server.state.stack.Metric> processRpcMetricDefinition(String metricType,
      String componentName, String propertyId, org.apache.ambari.server.state.stack.Metric metric); }
PropertyHelper { public static Map<String, org.apache.ambari.server.state.stack.Metric> processRpcMetricDefinition(String metricType, String componentName, String propertyId, org.apache.ambari.server.state.stack.Metric metric) { Map<String, org.apache.ambari.server.state.stack.Metric> replacementMap = null; if (componentName.equalsIgnoreCase("NAMENODE")) { for (Map.Entry<String, List<String>> entry : RPC_METRIC_SUFFIXES.entrySet()) { String prefix = entry.getKey(); if (propertyId.startsWith(prefix)) { replacementMap = new HashMap<>(); for (String suffix : entry.getValue()) { String newMetricName; if ("jmx".equals(metricType)) { newMetricName = insertTagIntoCategoty(suffix, metric.getName()); } else { newMetricName = insertTagInToMetricName(suffix, metric.getName(), prefix); } org.apache.ambari.server.state.stack.Metric newMetric = new org.apache.ambari.server.state.stack.Metric( newMetricName, metric.isPointInTime(), metric.isTemporal(), metric.isAmsHostMetric(), metric.getUnit() ); replacementMap.put(insertTagInToMetricName(suffix, propertyId, prefix), newMetric); } } } } return replacementMap; }  static String getPropertyId(String category, String name); static Set<String> getPropertyIds(Resource.Type resourceType); static Set<String> getPropertyIds(Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap ); static Map<String, Map<String, PropertyInfo>> getMetricPropertyIds(Resource.Type resourceType); static Map<String, Map<String, PropertyInfo>> getSQLServerPropertyIds(Resource.Type resourceType); static Map<String, Map<String, PropertyInfo>> getJMXPropertyIds(Resource.Type resourceType); static Map<Resource.Type, String> getKeyPropertyIds(Resource.Type resourceType); static String getPropertyName(String absProperty); static String getPropertyCategory(String property); static Set<String> getCategories(Set<String> propertyIds); static boolean containsProperty(Set<String> propertyIds, String propertyId); static boolean containsArguments(String propertyId); static Set<String> getAssociatedPropertyIds(Request request); static Map<String, Object> getProperties(Resource resource); static Request getCreateRequest(Set<Map<String, Object>> properties,
                                         Map<String, String> requestInfoProperties); static Request getReadRequest(Set<String> propertyIds); static Request getReadRequest(Set<String> propertyIds, Map<String,
      TemporalInfo> mapTemporalInfo); static Request getReadRequest(Set<String> propertyIds,
      Map<String, String> requestInfoProperties,
      Map<String, TemporalInfo> mapTemporalInfo, PageRequest pageRequest,
      SortRequest sortRequest); static Request getReadRequest(String ... propertyIds); static Request getUpdateRequest(Map<String, Object> properties,
                                         Map<String, String> requestInfoProperties); static void updateMetricsWithAggregateFunctionSupport(Map<String, Map<String, PropertyInfo>> metrics); static boolean hasAggregateFunctionSuffix(String propertyId); static Map<String, org.apache.ambari.server.state.stack.Metric> processRpcMetricDefinition(String metricType,
      String componentName, String propertyId, org.apache.ambari.server.state.stack.Metric metric); static final List<String> AGGREGATE_FUNCTION_IDENTIFIERS; }