@Test public void testGetTimeStampFromTSDRKey() { long time = System.currentTimeMillis(); String key = FormatUtil.getTSDRMetricKeyWithTimeStamp(createMetricRecord()); long timeStamp = FormatUtil.getTimeStampFromTSDRKey(key); Assert.assertTrue(timeStamp >= time && timeStamp <= time + 1000); }
public static Long getTimeStampFromTSDRKey(String tsdrKey) { int index1 = tsdrKey.indexOf(KEY_TIMESTAMP); if (index1 == -1) { return null; } int index2 = findSubkeyClosingBracket(tsdrKey, index1); if (index2 == -1) { return null; } return Long.parseLong(tsdrKey.substring(index1 + KEY_TIMESTAMP.length(), index2)); }
FormatUtil { public static Long getTimeStampFromTSDRKey(String tsdrKey) { int index1 = tsdrKey.indexOf(KEY_TIMESTAMP); if (index1 == -1) { return null; } int index2 = findSubkeyClosingBracket(tsdrKey, index1); if (index2 == -1) { return null; } return Long.parseLong(tsdrKey.substring(index1 + KEY_TIMESTAMP.length(), index2)); } }
FormatUtil { public static Long getTimeStampFromTSDRKey(String tsdrKey) { int index1 = tsdrKey.indexOf(KEY_TIMESTAMP); if (index1 == -1) { return null; } int index2 = findSubkeyClosingBracket(tsdrKey, index1); if (index2 == -1) { return null; } return Long.parseLong(tsdrKey.substring(index1 + KEY_TIMESTAMP.length(), index2)); } private  FormatUtil(); }
FormatUtil { public static Long getTimeStampFromTSDRKey(String tsdrKey) { int index1 = tsdrKey.indexOf(KEY_TIMESTAMP); if (index1 == -1) { return null; } int index2 = findSubkeyClosingBracket(tsdrKey, index1); if (index2 == -1) { return null; } return Long.parseLong(tsdrKey.substring(index1 + KEY_TIMESTAMP.length(), index2)); } 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 Long getTimeStampFromTSDRKey(String tsdrKey) { int index1 = tsdrKey.indexOf(KEY_TIMESTAMP); if (index1 == -1) { return null; } int index2 = findSubkeyClosingBracket(tsdrKey, index1); if (index2 == -1) { return null; } return Long.parseLong(tsdrKey.substring(index1 + KEY_TIMESTAMP.length(), index2)); } 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; }