@Test public void testGetTSDRLogKeyWithAttributes() { String key = FormatUtil.getTSDRLogKeyWithRecordAttributes(createLogRecord()); Assert.assertEquals("[NID=Test][DC=EXTERNAL][RK=Test2:Test1][RA=RATest:RAValue]", key); }
public static String getTSDRLogKeyWithRecordAttributes(TSDRLog log) { StringBuilder sb = new StringBuilder(getTSDRLogKey(log)); sb.append(KEY_RECORD_ATTRIBUTES); if (log.getRecordAttributes() != null) { boolean isFirst = true; for (RecordAttributes rec : log.getRecordAttributes()) { if (!isFirst) { sb.append(","); } if (rec.getName() != null && rec.getValue() != null) { if (rec.getName().equals(rec.getValue())) { sb.append(rec.getName()); } else { sb.append(rec.getName()); sb.append(":"); sb.append(rec.getValue()); } } isFirst = false; } } sb.append("]"); return sb.toString(); }
FormatUtil { public static String getTSDRLogKeyWithRecordAttributes(TSDRLog log) { StringBuilder sb = new StringBuilder(getTSDRLogKey(log)); sb.append(KEY_RECORD_ATTRIBUTES); if (log.getRecordAttributes() != null) { boolean isFirst = true; for (RecordAttributes rec : log.getRecordAttributes()) { if (!isFirst) { sb.append(","); } if (rec.getName() != null && rec.getValue() != null) { if (rec.getName().equals(rec.getValue())) { sb.append(rec.getName()); } else { sb.append(rec.getName()); sb.append(":"); sb.append(rec.getValue()); } } isFirst = false; } } sb.append("]"); return sb.toString(); } }
FormatUtil { public static String getTSDRLogKeyWithRecordAttributes(TSDRLog log) { StringBuilder sb = new StringBuilder(getTSDRLogKey(log)); sb.append(KEY_RECORD_ATTRIBUTES); if (log.getRecordAttributes() != null) { boolean isFirst = true; for (RecordAttributes rec : log.getRecordAttributes()) { if (!isFirst) { sb.append(","); } if (rec.getName() != null && rec.getValue() != null) { if (rec.getName().equals(rec.getValue())) { sb.append(rec.getName()); } else { sb.append(rec.getName()); sb.append(":"); sb.append(rec.getValue()); } } isFirst = false; } } sb.append("]"); return sb.toString(); } private  FormatUtil(); }
FormatUtil { public static String getTSDRLogKeyWithRecordAttributes(TSDRLog log) { StringBuilder sb = new StringBuilder(getTSDRLogKey(log)); sb.append(KEY_RECORD_ATTRIBUTES); if (log.getRecordAttributes() != null) { boolean isFirst = true; for (RecordAttributes rec : log.getRecordAttributes()) { if (!isFirst) { sb.append(","); } if (rec.getName() != null && rec.getValue() != null) { if (rec.getName().equals(rec.getValue())) { sb.append(rec.getName()); } else { sb.append(rec.getName()); sb.append(":"); sb.append(rec.getValue()); } } 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 getTSDRLogKeyWithRecordAttributes(TSDRLog log) { StringBuilder sb = new StringBuilder(getTSDRLogKey(log)); sb.append(KEY_RECORD_ATTRIBUTES); if (log.getRecordAttributes() != null) { boolean isFirst = true; for (RecordAttributes rec : log.getRecordAttributes()) { if (!isFirst) { sb.append(","); } if (rec.getName() != null && rec.getValue() != null) { if (rec.getName().equals(rec.getValue())) { sb.append(rec.getName()); } else { sb.append(rec.getName()); sb.append(":"); sb.append(rec.getValue()); } } 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; }