@Test public void testInsertTagIntoMetricName() { Assert.assertEquals("rpc.rpc.client.CallQueueLength", PropertyHelper.insertTagInToMetricName("client", "rpc.rpc.CallQueueLength", "metrics/rpc/")); Assert.assertEquals("rpc.rpc.client.CallQueueLength", PropertyHelper.insertTagInToMetricName("client", "rpc.rpc.CallQueueLength", "metrics/rpc/")); Assert.assertEquals("metrics/rpc/client/CallQueueLen", PropertyHelper.insertTagInToMetricName("client", "metrics/rpc/CallQueueLen", "metrics/rpc/")); Assert.assertEquals("metrics/rpc/client/CallQueueLen", PropertyHelper.insertTagInToMetricName("client", "metrics/rpc/CallQueueLen", "metrics/rpc/")); Assert.assertEquals("rpcdetailed.rpcdetailed.client.FsyncAvgTime", PropertyHelper.insertTagInToMetricName("client", "rpcdetailed.rpcdetailed.FsyncAvgTime", "metrics/rpc/")); Assert.assertEquals("metrics/rpcdetailed/client/fsync_avg_time", PropertyHelper.insertTagInToMetricName("client", "metrics/rpcdetailed/fsync_avg_time", "metrics/rpc/")); }
static String insertTagInToMetricName(String tag, String metricName, String prefix) { String sepExpr = "\\."; String seperator = "."; if (metricName.indexOf(EXTERNAL_PATH_SEP) != -1) { sepExpr = Character.toString(EXTERNAL_PATH_SEP); seperator = sepExpr; } String prefixSep = prefix.contains(".") ? "\\." : "" + EXTERNAL_PATH_SEP; if (prefix.substring(prefix.length() - 1).equals(prefixSep)) { prefix = prefix.substring(0, prefix.length() - 1); } int pos = prefix.split(prefixSep).length - 1; String[] parts = metricName.split(sepExpr); StringBuilder sb = new StringBuilder(); for (int i = 0; i < parts.length; i++) { sb.append(parts[i]); if (i < parts.length - 1) { sb.append(seperator); } if (i == pos) { sb.append(tag); sb.append(seperator); } } return sb.toString(); }
PropertyHelper { static String insertTagInToMetricName(String tag, String metricName, String prefix) { String sepExpr = "\\."; String seperator = "."; if (metricName.indexOf(EXTERNAL_PATH_SEP) != -1) { sepExpr = Character.toString(EXTERNAL_PATH_SEP); seperator = sepExpr; } String prefixSep = prefix.contains(".") ? "\\." : "" + EXTERNAL_PATH_SEP; if (prefix.substring(prefix.length() - 1).equals(prefixSep)) { prefix = prefix.substring(0, prefix.length() - 1); } int pos = prefix.split(prefixSep).length - 1; String[] parts = metricName.split(sepExpr); StringBuilder sb = new StringBuilder(); for (int i = 0; i < parts.length; i++) { sb.append(parts[i]); if (i < parts.length - 1) { sb.append(seperator); } if (i == pos) { sb.append(tag); sb.append(seperator); } } return sb.toString(); } }
PropertyHelper { static String insertTagInToMetricName(String tag, String metricName, String prefix) { String sepExpr = "\\."; String seperator = "."; if (metricName.indexOf(EXTERNAL_PATH_SEP) != -1) { sepExpr = Character.toString(EXTERNAL_PATH_SEP); seperator = sepExpr; } String prefixSep = prefix.contains(".") ? "\\." : "" + EXTERNAL_PATH_SEP; if (prefix.substring(prefix.length() - 1).equals(prefixSep)) { prefix = prefix.substring(0, prefix.length() - 1); } int pos = prefix.split(prefixSep).length - 1; String[] parts = metricName.split(sepExpr); StringBuilder sb = new StringBuilder(); for (int i = 0; i < parts.length; i++) { sb.append(parts[i]); if (i < parts.length - 1) { sb.append(seperator); } if (i == pos) { sb.append(tag); sb.append(seperator); } } return sb.toString(); }  }
PropertyHelper { static String insertTagInToMetricName(String tag, String metricName, String prefix) { String sepExpr = "\\."; String seperator = "."; if (metricName.indexOf(EXTERNAL_PATH_SEP) != -1) { sepExpr = Character.toString(EXTERNAL_PATH_SEP); seperator = sepExpr; } String prefixSep = prefix.contains(".") ? "\\." : "" + EXTERNAL_PATH_SEP; if (prefix.substring(prefix.length() - 1).equals(prefixSep)) { prefix = prefix.substring(0, prefix.length() - 1); } int pos = prefix.split(prefixSep).length - 1; String[] parts = metricName.split(sepExpr); StringBuilder sb = new StringBuilder(); for (int i = 0; i < parts.length; i++) { sb.append(parts[i]); if (i < parts.length - 1) { sb.append(seperator); } if (i == pos) { sb.append(tag); sb.append(seperator); } } return sb.toString(); }  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 { static String insertTagInToMetricName(String tag, String metricName, String prefix) { String sepExpr = "\\."; String seperator = "."; if (metricName.indexOf(EXTERNAL_PATH_SEP) != -1) { sepExpr = Character.toString(EXTERNAL_PATH_SEP); seperator = sepExpr; } String prefixSep = prefix.contains(".") ? "\\." : "" + EXTERNAL_PATH_SEP; if (prefix.substring(prefix.length() - 1).equals(prefixSep)) { prefix = prefix.substring(0, prefix.length() - 1); } int pos = prefix.split(prefixSep).length - 1; String[] parts = metricName.split(sepExpr); StringBuilder sb = new StringBuilder(); for (int i = 0; i < parts.length; i++) { sb.append(parts[i]); if (i < parts.length - 1) { sb.append(seperator); } if (i == pos) { sb.append(tag); sb.append(seperator); } } return sb.toString(); }  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; }