@Test public void testGetTSDRMetricKey() { String key = FormatUtil.getTSDRMetricKey(createMetricRecord()); Assert.assertEquals("[NID=Test][DC=EXTERNAL][MN=Test][RK=Test2:Test1]", key); }
public static String getTSDRMetricKey(TSDRMetric metric) { StringBuilder sb = new StringBuilder(); sb.append(KEY_NODEID); if (metric.getNodeID() != null) { sb.append(metric.getNodeID()); } sb.append("]"); sb.append(KEY_CATEGORY); if (metric.getTSDRDataCategory() != null) { sb.append(metric.getTSDRDataCategory()); } sb.append("]"); sb.append(KEY_METRICNAME); if (metric.getMetricName() != null) { sb.append(metric.getMetricName()); } sb.append("]"); sb.append(KEY_RECORDKEYS); if (metric.getRecordKeys() != null) { boolean isFirst = true; for (RecordKeys rec : metric.getRecordKeys()) { if (!isFirst) { sb.append(","); } if (rec.getKeyName() != null && rec.getKeyValue() != null) { if (rec.getKeyName().equals(rec.getKeyValue())) { sb.append(rec.getKeyName()); } else { sb.append(rec.getKeyName()); sb.append(":"); sb.append(rec.getKeyValue()); } } isFirst = false; } } sb.append("]"); return sb.toString(); }
FormatUtil { public static String getTSDRMetricKey(TSDRMetric metric) { StringBuilder sb = new StringBuilder(); sb.append(KEY_NODEID); if (metric.getNodeID() != null) { sb.append(metric.getNodeID()); } sb.append("]"); sb.append(KEY_CATEGORY); if (metric.getTSDRDataCategory() != null) { sb.append(metric.getTSDRDataCategory()); } sb.append("]"); sb.append(KEY_METRICNAME); if (metric.getMetricName() != null) { sb.append(metric.getMetricName()); } sb.append("]"); sb.append(KEY_RECORDKEYS); if (metric.getRecordKeys() != null) { boolean isFirst = true; for (RecordKeys rec : metric.getRecordKeys()) { if (!isFirst) { sb.append(","); } if (rec.getKeyName() != null && rec.getKeyValue() != null) { if (rec.getKeyName().equals(rec.getKeyValue())) { sb.append(rec.getKeyName()); } else { sb.append(rec.getKeyName()); sb.append(":"); sb.append(rec.getKeyValue()); } } isFirst = false; } } sb.append("]"); return sb.toString(); } }
FormatUtil { public static String getTSDRMetricKey(TSDRMetric metric) { StringBuilder sb = new StringBuilder(); sb.append(KEY_NODEID); if (metric.getNodeID() != null) { sb.append(metric.getNodeID()); } sb.append("]"); sb.append(KEY_CATEGORY); if (metric.getTSDRDataCategory() != null) { sb.append(metric.getTSDRDataCategory()); } sb.append("]"); sb.append(KEY_METRICNAME); if (metric.getMetricName() != null) { sb.append(metric.getMetricName()); } sb.append("]"); sb.append(KEY_RECORDKEYS); if (metric.getRecordKeys() != null) { boolean isFirst = true; for (RecordKeys rec : metric.getRecordKeys()) { if (!isFirst) { sb.append(","); } if (rec.getKeyName() != null && rec.getKeyValue() != null) { if (rec.getKeyName().equals(rec.getKeyValue())) { sb.append(rec.getKeyName()); } else { sb.append(rec.getKeyName()); sb.append(":"); sb.append(rec.getKeyValue()); } } isFirst = false; } } sb.append("]"); return sb.toString(); } private  FormatUtil(); }
FormatUtil { public static String getTSDRMetricKey(TSDRMetric metric) { StringBuilder sb = new StringBuilder(); sb.append(KEY_NODEID); if (metric.getNodeID() != null) { sb.append(metric.getNodeID()); } sb.append("]"); sb.append(KEY_CATEGORY); if (metric.getTSDRDataCategory() != null) { sb.append(metric.getTSDRDataCategory()); } sb.append("]"); sb.append(KEY_METRICNAME); if (metric.getMetricName() != null) { sb.append(metric.getMetricName()); } sb.append("]"); sb.append(KEY_RECORDKEYS); if (metric.getRecordKeys() != null) { boolean isFirst = true; for (RecordKeys rec : metric.getRecordKeys()) { if (!isFirst) { sb.append(","); } if (rec.getKeyName() != null && rec.getKeyValue() != null) { if (rec.getKeyName().equals(rec.getKeyValue())) { sb.append(rec.getKeyName()); } else { sb.append(rec.getKeyName()); sb.append(":"); sb.append(rec.getKeyValue()); } } isFirst = false; } } sb.append("]"); return sb.toString(); } private  FormatUtil(); static boolean isDataCategory(String str); static boolean isDataCategoryKey(String tsdrKey); static String getFormattedTimeStamp(long timestamp, String formatString); static String getTSDRLogKeyWithTimeStamp(TSDRLog log); static String getTSDRLogKey(TSDRLog log); static String getTSDRBinaryKey(TSDRBinaryRecord record); static boolean isValidTSDRKey(String str); static boolean isValidTSDRLogKey(String str); static String getDataCategoryFromTSDRKey(String tsdrKey); static Long getTimeStampFromTSDRKey(String tsdrKey); static String getMetriNameFromTSDRKey(String tsdrKey); static String getNodeIdFromTSDRKey(String tsdrKey); static List<RecordKeys> getRecordKeysFromTSDRKey(String tsdrKey); static List<RecordAttributes> getRecordAttributesFromTSDRKey(String tsdrKey); static String getTSDRMetricKeyWithTimeStamp(TSDRMetric metric); static String getTSDRLogKeyWithRecordAttributes(TSDRLog log); static String getTSDRMetricKey(TSDRMetric metric); static BigDecimal toMetricValue(Counter32 counter32); static BigDecimal toMetricValue(Counter64 counter64); static BigDecimal toMetricValue(BigInteger bigInteger); static String getFixedFormatString(String value, long length); }
FormatUtil { public static String getTSDRMetricKey(TSDRMetric metric) { StringBuilder sb = new StringBuilder(); sb.append(KEY_NODEID); if (metric.getNodeID() != null) { sb.append(metric.getNodeID()); } sb.append("]"); sb.append(KEY_CATEGORY); if (metric.getTSDRDataCategory() != null) { sb.append(metric.getTSDRDataCategory()); } sb.append("]"); sb.append(KEY_METRICNAME); if (metric.getMetricName() != null) { sb.append(metric.getMetricName()); } sb.append("]"); sb.append(KEY_RECORDKEYS); if (metric.getRecordKeys() != null) { boolean isFirst = true; for (RecordKeys rec : metric.getRecordKeys()) { if (!isFirst) { sb.append(","); } if (rec.getKeyName() != null && rec.getKeyValue() != null) { if (rec.getKeyName().equals(rec.getKeyValue())) { sb.append(rec.getKeyName()); } else { sb.append(rec.getKeyName()); sb.append(":"); sb.append(rec.getKeyValue()); } } isFirst = false; } } sb.append("]"); return sb.toString(); } private  FormatUtil(); static boolean isDataCategory(String str); static boolean isDataCategoryKey(String tsdrKey); static String getFormattedTimeStamp(long timestamp, String formatString); static String getTSDRLogKeyWithTimeStamp(TSDRLog log); static String getTSDRLogKey(TSDRLog log); static String getTSDRBinaryKey(TSDRBinaryRecord record); static boolean isValidTSDRKey(String str); static boolean isValidTSDRLogKey(String str); static String getDataCategoryFromTSDRKey(String tsdrKey); static Long getTimeStampFromTSDRKey(String tsdrKey); static String getMetriNameFromTSDRKey(String tsdrKey); static String getNodeIdFromTSDRKey(String tsdrKey); static List<RecordKeys> getRecordKeysFromTSDRKey(String tsdrKey); static List<RecordAttributes> getRecordAttributesFromTSDRKey(String tsdrKey); static String getTSDRMetricKeyWithTimeStamp(TSDRMetric metric); static String getTSDRLogKeyWithRecordAttributes(TSDRLog log); static String getTSDRMetricKey(TSDRMetric metric); static BigDecimal toMetricValue(Counter32 counter32); static BigDecimal toMetricValue(Counter64 counter64); static BigDecimal toMetricValue(BigInteger bigInteger); static String getFixedFormatString(String value, long length); static final String QUERY_TIMESTAMP; static final String COMMAND_OUT_TIMESTAMP; static final String KEY_NODEID; static final String KEY_CATEGORY; static final String KEY_METRICNAME; static final String KEY_RECORDKEYS; static final String KEY_TIMESTAMP; static final String KEY_RECORD_ATTRIBUTES; }