@Test public void testGenerateMetricMappingTca() { System.out.println("metrics mapping for TCA"); String rawString = "--watermark=\"NRTG Alpha 1.0\" --slope-mode --width=960 --height=400 --title=\"TCA Delay\" --vertical-label=\"Microseconds\" DEF:in={rrd1}:inboundDelay:AVERAGE DEF:out={rrd2}:outboundDelay:AVERAGE AREA:in#00ff00:\"Inbound \" GPRINT:in:AVERAGE:\" Avg \\: %8.2lf %s\" GPRINT:in:MIN:\"Min \\: %8.2lf %s\" GPRINT:in:MAX:\"Max \\: %8.2lf %s\\n\" LINE1:out#0000ff:\"Outbound\" GPRINT:out:AVERAGE:\" Avg \\: %8.2lf %s\" GPRINT:out:MIN:\"Min \\: %8.2lf %s\" GPRINT:out:MAX:\"Max \\: %8.2lf %s\\n\""; String expectedResult = "'.1.3.6.1.4.1.27091.3.1.6.1.2.171.19.37.60_inboundDelay': '{rrd1}:inboundDelay', \n'.1.3.6.1.4.1.27091.3.1.6.1.2.171.19.37.60_outboundDelay': '{rrd2}:outboundDelay'"; Map<String, String> rrdGraphAttributesToMetricIds = new LinkedHashMap<String, String>(); rrdGraphAttributesToMetricIds.put("inboundDelay", ".1.3.6.1.4.1.27091.3.1.6.1.2.171.19.37.60_inboundDelay"); rrdGraphAttributesToMetricIds.put("outboundDelay", ".1.3.6.1.4.1.27091.3.1.6.1.2.171.19.37.60_outboundDelay"); String mappingResult = nrtHelper.generateJsMappingObject(rawString, rrdGraphAttributesToMetricIds); assertTrue(mappingResult.contains(".1.3.6.1.4.1.27091.3.1.6.1.2.171.19.37.60_inboundDelay")); assertFalse(mappingResult.contains("TCA_.1.3.6.1.4.1.27091.3.1.6.1.2.171.19.37.60_inboundDelay")); assertEquals(expectedResult, mappingResult); }
public String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds) { final StringBuilder stringBuilder = new StringBuilder(); final String command = rrdCommand; final Pattern pattern = Pattern.compile("DEF:.*?=(\\{.*?\\}):(.*?):"); final Matcher matcher = pattern.matcher(command); final Map<String, String> rrdFileMapping = new HashMap<String, String>(); while (matcher.find()) { rrdFileMapping.put(matcher.group(2), matcher.group(1)); } for (final Map.Entry<String,String> entry : rrdGraphAttributesToMetricIds.entrySet()) { final String row = String.format("'%s': '%s:%s', \n", entry.getValue(), rrdFileMapping.get(entry.getKey()), entry.getKey()); stringBuilder.append(row); } return stringBuilder.toString().substring(0,stringBuilder.toString().length() - ", \n".length()); }
NrtHelper { public String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds) { final StringBuilder stringBuilder = new StringBuilder(); final String command = rrdCommand; final Pattern pattern = Pattern.compile("DEF:.*?=(\\{.*?\\}):(.*?):"); final Matcher matcher = pattern.matcher(command); final Map<String, String> rrdFileMapping = new HashMap<String, String>(); while (matcher.find()) { rrdFileMapping.put(matcher.group(2), matcher.group(1)); } for (final Map.Entry<String,String> entry : rrdGraphAttributesToMetricIds.entrySet()) { final String row = String.format("'%s': '%s:%s', \n", entry.getValue(), rrdFileMapping.get(entry.getKey()), entry.getKey()); stringBuilder.append(row); } return stringBuilder.toString().substring(0,stringBuilder.toString().length() - ", \n".length()); } }
NrtHelper { public String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds) { final StringBuilder stringBuilder = new StringBuilder(); final String command = rrdCommand; final Pattern pattern = Pattern.compile("DEF:.*?=(\\{.*?\\}):(.*?):"); final Matcher matcher = pattern.matcher(command); final Map<String, String> rrdFileMapping = new HashMap<String, String>(); while (matcher.find()) { rrdFileMapping.put(matcher.group(2), matcher.group(1)); } for (final Map.Entry<String,String> entry : rrdGraphAttributesToMetricIds.entrySet()) { final String row = String.format("'%s': '%s:%s', \n", entry.getValue(), rrdFileMapping.get(entry.getKey()), entry.getKey()); stringBuilder.append(row); } return stringBuilder.toString().substring(0,stringBuilder.toString().length() - ", \n".length()); }  }
NrtHelper { public String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds) { final StringBuilder stringBuilder = new StringBuilder(); final String command = rrdCommand; final Pattern pattern = Pattern.compile("DEF:.*?=(\\{.*?\\}):(.*?):"); final Matcher matcher = pattern.matcher(command); final Map<String, String> rrdFileMapping = new HashMap<String, String>(); while (matcher.find()) { rrdFileMapping.put(matcher.group(2), matcher.group(1)); } for (final Map.Entry<String,String> entry : rrdGraphAttributesToMetricIds.entrySet()) { final String row = String.format("'%s': '%s:%s', \n", entry.getValue(), rrdFileMapping.get(entry.getKey()), entry.getKey()); stringBuilder.append(row); } return stringBuilder.toString().substring(0,stringBuilder.toString().length() - ", \n".length()); }  String cleanUpRrdGraphStringForWebUi(final PrefabGraph prefabGraph, final Map<String,String> externalPropertyAttributes, final Map<String,String> stringPropertyAttributes); String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds); }
NrtHelper { public String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds) { final StringBuilder stringBuilder = new StringBuilder(); final String command = rrdCommand; final Pattern pattern = Pattern.compile("DEF:.*?=(\\{.*?\\}):(.*?):"); final Matcher matcher = pattern.matcher(command); final Map<String, String> rrdFileMapping = new HashMap<String, String>(); while (matcher.find()) { rrdFileMapping.put(matcher.group(2), matcher.group(1)); } for (final Map.Entry<String,String> entry : rrdGraphAttributesToMetricIds.entrySet()) { final String row = String.format("'%s': '%s:%s', \n", entry.getValue(), rrdFileMapping.get(entry.getKey()), entry.getKey()); stringBuilder.append(row); } return stringBuilder.toString().substring(0,stringBuilder.toString().length() - ", \n".length()); }  String cleanUpRrdGraphStringForWebUi(final PrefabGraph prefabGraph, final Map<String,String> externalPropertyAttributes, final Map<String,String> stringPropertyAttributes); String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds); final static List<String> RRD_KEYWORDS; }