@Test public void testIsDataCategoryKey() { String key = "[NID=][MN=][DC=][RK=]"; Assert.assertFalse(FormatUtil.isDataCategoryKey(key)); key = "[NID=][MN=]DC=[RK=]"; Assert.assertFalse(FormatUtil.isDataCategoryKey(key)); key = "[DC=PORTSTATS][MN=][RK=]"; Assert.assertFalse(FormatUtil.isDataCategoryKey(key)); key = "[NID=][DC=PORTSTATS][MN=]"; Assert.assertFalse(FormatUtil.isDataCategoryKey(key)); key = "[NID=][DC=][RK=]"; Assert.assertFalse(FormatUtil.isDataCategoryKey(key)); key = "[NID=]DC=[RK=]"; Assert.assertFalse(FormatUtil.isDataCategoryKey(key)); key = "[DC=][RK=]"; Assert.assertFalse(FormatUtil.isDataCategoryKey(key)); key = "[NID=][DC=PORTSTATS]"; Assert.assertFalse(FormatUtil.isDataCategoryKey(key)); key = FormatUtil.getTSDRMetricKey(createMetricRecordWithDCAndNID()); Assert.assertFalse(FormatUtil.isDataCategoryKey(key)); key = FormatUtil.getTSDRMetricKey(createMetricRecordWithDCAndMN()); Assert.assertFalse(FormatUtil.isDataCategoryKey(key)); key = FormatUtil.getTSDRMetricKey(createMetricRecordWithDCAndRK()); Assert.assertFalse(FormatUtil.isDataCategoryKey(key)); key = FormatUtil.getTSDRMetricKey(createDataCategoryMetricRecord()); Assert.assertTrue(FormatUtil.isDataCategoryKey(key)); key = FormatUtil.getTSDRLogKey(createLogRecordWithDCAndNID()); Assert.assertFalse(FormatUtil.isDataCategory(key)); key = FormatUtil.getTSDRLogKey(createLogRecordWithDCAndRK()); Assert.assertFalse(FormatUtil.isDataCategoryKey(key)); Assert.assertFalse(FormatUtil.isDataCategory(key)); key = FormatUtil.getTSDRLogKey(createDataCategoryLogRecord()); Assert.assertTrue(FormatUtil.isDataCategoryKey(key)); }
public static boolean isDataCategoryKey(String tsdrKey) { if (isValidTSDRKey(tsdrKey)) { if (getNodeIdFromTSDRKey(tsdrKey).length() == 0 && getMetriNameFromTSDRKey(tsdrKey).length() == 0 && getRecordKeysFromTSDRKey(tsdrKey).size() == 0 && getDataCategoryFromTSDRKey(tsdrKey).length() != 0) { return true; } else { return false; } } else if (isValidTSDRLogKey(tsdrKey)) { if (getNodeIdFromTSDRKey(tsdrKey).length() == 0 && getRecordKeysFromTSDRKey(tsdrKey).size() == 0 && getDataCategoryFromTSDRKey(tsdrKey).length() != 0) { return true; } else { return false; } } else { return false; } }
FormatUtil { public static boolean isDataCategoryKey(String tsdrKey) { if (isValidTSDRKey(tsdrKey)) { if (getNodeIdFromTSDRKey(tsdrKey).length() == 0 && getMetriNameFromTSDRKey(tsdrKey).length() == 0 && getRecordKeysFromTSDRKey(tsdrKey).size() == 0 && getDataCategoryFromTSDRKey(tsdrKey).length() != 0) { return true; } else { return false; } } else if (isValidTSDRLogKey(tsdrKey)) { if (getNodeIdFromTSDRKey(tsdrKey).length() == 0 && getRecordKeysFromTSDRKey(tsdrKey).size() == 0 && getDataCategoryFromTSDRKey(tsdrKey).length() != 0) { return true; } else { return false; } } else { return false; } } }
FormatUtil { public static boolean isDataCategoryKey(String tsdrKey) { if (isValidTSDRKey(tsdrKey)) { if (getNodeIdFromTSDRKey(tsdrKey).length() == 0 && getMetriNameFromTSDRKey(tsdrKey).length() == 0 && getRecordKeysFromTSDRKey(tsdrKey).size() == 0 && getDataCategoryFromTSDRKey(tsdrKey).length() != 0) { return true; } else { return false; } } else if (isValidTSDRLogKey(tsdrKey)) { if (getNodeIdFromTSDRKey(tsdrKey).length() == 0 && getRecordKeysFromTSDRKey(tsdrKey).size() == 0 && getDataCategoryFromTSDRKey(tsdrKey).length() != 0) { return true; } else { return false; } } else { return false; } } private  FormatUtil(); }
FormatUtil { public static boolean isDataCategoryKey(String tsdrKey) { if (isValidTSDRKey(tsdrKey)) { if (getNodeIdFromTSDRKey(tsdrKey).length() == 0 && getMetriNameFromTSDRKey(tsdrKey).length() == 0 && getRecordKeysFromTSDRKey(tsdrKey).size() == 0 && getDataCategoryFromTSDRKey(tsdrKey).length() != 0) { return true; } else { return false; } } else if (isValidTSDRLogKey(tsdrKey)) { if (getNodeIdFromTSDRKey(tsdrKey).length() == 0 && getRecordKeysFromTSDRKey(tsdrKey).size() == 0 && getDataCategoryFromTSDRKey(tsdrKey).length() != 0) { return true; } else { return false; } } else { return false; } } 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 boolean isDataCategoryKey(String tsdrKey) { if (isValidTSDRKey(tsdrKey)) { if (getNodeIdFromTSDRKey(tsdrKey).length() == 0 && getMetriNameFromTSDRKey(tsdrKey).length() == 0 && getRecordKeysFromTSDRKey(tsdrKey).size() == 0 && getDataCategoryFromTSDRKey(tsdrKey).length() != 0) { return true; } else { return false; } } else if (isValidTSDRLogKey(tsdrKey)) { if (getNodeIdFromTSDRKey(tsdrKey).length() == 0 && getRecordKeysFromTSDRKey(tsdrKey).size() == 0 && getDataCategoryFromTSDRKey(tsdrKey).length() != 0) { return true; } else { return false; } } else { return false; } } 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; }