@Test public void testGetPropertyCategory() { String propertyId = "metrics/yarn/Queue/$1.replaceAll(\",q(\\d+)=\",\"/\").substring(1)/AppsRunning"; String category = PropertyHelper.getPropertyCategory(propertyId); Assert.assertEquals("metrics/yarn/Queue/$1", category); category = PropertyHelper.getPropertyCategory(category); Assert.assertEquals("metrics/yarn/Queue", category); category = PropertyHelper.getPropertyCategory(category); Assert.assertEquals("metrics/yarn", category); category = PropertyHelper.getPropertyCategory(category); Assert.assertEquals("metrics", category); category = PropertyHelper.getPropertyCategory(category); Assert.assertNull(category); }
public static String getPropertyCategory(String property) { int lastPathSep = -1; if( !containsArguments(property) ){ lastPathSep = property.lastIndexOf(EXTERNAL_PATH_SEP); return lastPathSep == -1 ? null : property.substring(0, lastPathSep); } String[] tokens = METRIC_CATEGORY_TOKENIZE_REGEX.split(property); if (null == tokens || tokens.length == 0) { return null; } StringBuilder categoryBuilder = new StringBuilder(); for (int i = 0; i < tokens.length - 1; i++) { String token = tokens[i]; if (containsArguments(token)) { int methodIndex = token.indexOf('.'); if (methodIndex != -1) { int parensIndex = token.lastIndexOf(')'); if (parensIndex < token.length() - 1) { String temp = token.substring(0, methodIndex); temp += token.substring(parensIndex + 1); token = temp; } else { token = token.substring(0, methodIndex); } } } categoryBuilder.append(token); if (i < tokens.length - 2) { categoryBuilder.append('/'); } } String category = categoryBuilder.toString(); return category; }
PropertyHelper { public static String getPropertyCategory(String property) { int lastPathSep = -1; if( !containsArguments(property) ){ lastPathSep = property.lastIndexOf(EXTERNAL_PATH_SEP); return lastPathSep == -1 ? null : property.substring(0, lastPathSep); } String[] tokens = METRIC_CATEGORY_TOKENIZE_REGEX.split(property); if (null == tokens || tokens.length == 0) { return null; } StringBuilder categoryBuilder = new StringBuilder(); for (int i = 0; i < tokens.length - 1; i++) { String token = tokens[i]; if (containsArguments(token)) { int methodIndex = token.indexOf('.'); if (methodIndex != -1) { int parensIndex = token.lastIndexOf(')'); if (parensIndex < token.length() - 1) { String temp = token.substring(0, methodIndex); temp += token.substring(parensIndex + 1); token = temp; } else { token = token.substring(0, methodIndex); } } } categoryBuilder.append(token); if (i < tokens.length - 2) { categoryBuilder.append('/'); } } String category = categoryBuilder.toString(); return category; } }
PropertyHelper { public static String getPropertyCategory(String property) { int lastPathSep = -1; if( !containsArguments(property) ){ lastPathSep = property.lastIndexOf(EXTERNAL_PATH_SEP); return lastPathSep == -1 ? null : property.substring(0, lastPathSep); } String[] tokens = METRIC_CATEGORY_TOKENIZE_REGEX.split(property); if (null == tokens || tokens.length == 0) { return null; } StringBuilder categoryBuilder = new StringBuilder(); for (int i = 0; i < tokens.length - 1; i++) { String token = tokens[i]; if (containsArguments(token)) { int methodIndex = token.indexOf('.'); if (methodIndex != -1) { int parensIndex = token.lastIndexOf(')'); if (parensIndex < token.length() - 1) { String temp = token.substring(0, methodIndex); temp += token.substring(parensIndex + 1); token = temp; } else { token = token.substring(0, methodIndex); } } } categoryBuilder.append(token); if (i < tokens.length - 2) { categoryBuilder.append('/'); } } String category = categoryBuilder.toString(); return category; }  }
PropertyHelper { public static String getPropertyCategory(String property) { int lastPathSep = -1; if( !containsArguments(property) ){ lastPathSep = property.lastIndexOf(EXTERNAL_PATH_SEP); return lastPathSep == -1 ? null : property.substring(0, lastPathSep); } String[] tokens = METRIC_CATEGORY_TOKENIZE_REGEX.split(property); if (null == tokens || tokens.length == 0) { return null; } StringBuilder categoryBuilder = new StringBuilder(); for (int i = 0; i < tokens.length - 1; i++) { String token = tokens[i]; if (containsArguments(token)) { int methodIndex = token.indexOf('.'); if (methodIndex != -1) { int parensIndex = token.lastIndexOf(')'); if (parensIndex < token.length() - 1) { String temp = token.substring(0, methodIndex); temp += token.substring(parensIndex + 1); token = temp; } else { token = token.substring(0, methodIndex); } } } categoryBuilder.append(token); if (i < tokens.length - 2) { categoryBuilder.append('/'); } } String category = categoryBuilder.toString(); return category; }  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 String getPropertyCategory(String property) { int lastPathSep = -1; if( !containsArguments(property) ){ lastPathSep = property.lastIndexOf(EXTERNAL_PATH_SEP); return lastPathSep == -1 ? null : property.substring(0, lastPathSep); } String[] tokens = METRIC_CATEGORY_TOKENIZE_REGEX.split(property); if (null == tokens || tokens.length == 0) { return null; } StringBuilder categoryBuilder = new StringBuilder(); for (int i = 0; i < tokens.length - 1; i++) { String token = tokens[i]; if (containsArguments(token)) { int methodIndex = token.indexOf('.'); if (methodIndex != -1) { int parensIndex = token.lastIndexOf(')'); if (parensIndex < token.length() - 1) { String temp = token.substring(0, methodIndex); temp += token.substring(parensIndex + 1); token = temp; } else { token = token.substring(0, methodIndex); } } } categoryBuilder.append(token); if (i < tokens.length - 2) { categoryBuilder.append('/'); } } String category = categoryBuilder.toString(); return category; }  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; }