use of net.opentsdb.core.IncomingDataPoint in project opentsdb by OpenTSDB.
the class PutDataPointRpc method getDataPointFromString.
/**
* Converts the string array to an IncomingDataPoint. WARNING: This method
* does not perform validation. It should only be used by the Telnet style
* {@code execute} above within the error callback. At that point it means
* the array parsed correctly as per {@code importDataPoint}.
* @param words The array of strings representing a data point
* @return An incoming data point object.
*/
private final IncomingDataPoint getDataPointFromString(final String[] words) {
final IncomingDataPoint dp = new IncomingDataPoint();
dp.setMetric(words[1]);
if (words[2].contains(".")) {
dp.setTimestamp(Tags.parseLong(words[2].replace(".", "")));
} else {
dp.setTimestamp(Tags.parseLong(words[2]));
}
dp.setValue(words[3]);
final HashMap<String, String> tags = new HashMap<String, String>();
for (int i = 4; i < words.length; i++) {
if (!words[i].isEmpty()) {
Tags.parse(tags, words[i]);
}
}
dp.setTags(tags);
return dp;
}
use of net.opentsdb.core.IncomingDataPoint in project opentsdb by OpenTSDB.
the class TestTSUIDQuery method getLastPointTSUIDZeroBackscanRecent.
@Test
public void getLastPointTSUIDZeroBackscanRecent() throws Exception {
Whitebox.setInternalState(config, "enable_tsuid_incrementing", false);
Whitebox.setInternalState(config, "enable_realtime_ts", false);
storage.flushStorage();
tsdb.addPoint(METRIC_STRING, 1356998400L, 42, tags);
PowerMockito.mockStatic(DateTime.class);
PowerMockito.when(DateTime.currentTimeMillis()).thenReturn(1356998400000L);
query = new TSUIDQuery(tsdb, TSUID);
final IncomingDataPoint dp = query.getLastPoint(false, 0).join();
assertEquals(1356998400000L, dp.getTimestamp());
assertNull(dp.getMetric());
assertNull(dp.getTags());
assertEquals("42", dp.getValue());
assertEquals(UniqueId.uidToString(TSUID), dp.getTSUID());
}
use of net.opentsdb.core.IncomingDataPoint in project opentsdb by OpenTSDB.
the class TestTSUIDQuery method getLastPointMetricManyBackscanInRange.
@Test
public void getLastPointMetricManyBackscanInRange() throws Exception {
Whitebox.setInternalState(config, "enable_tsuid_incrementing", false);
Whitebox.setInternalState(config, "enable_realtime_ts", false);
storage.flushStorage();
tsdb.addPoint(METRIC_STRING, 1356998400L, 42, tags);
PowerMockito.mockStatic(DateTime.class);
PowerMockito.when(DateTime.currentTimeMillis()).thenReturn(1360681200000L);
query = new TSUIDQuery(tsdb, METRIC_STRING, tags);
final IncomingDataPoint dp = query.getLastPoint(false, 1024).join();
assertEquals(1356998400000L, dp.getTimestamp());
assertNull(dp.getMetric());
assertNull(dp.getTags());
assertEquals("42", dp.getValue());
assertEquals(UniqueId.uidToString(TSUID), dp.getTSUID());
}
use of net.opentsdb.core.IncomingDataPoint in project opentsdb by OpenTSDB.
the class TestTSUIDQuery method getLastPointMetricResolve.
@Test
public void getLastPointMetricResolve() throws Exception {
Whitebox.setInternalState(config, "enable_tsuid_incrementing", false);
Whitebox.setInternalState(config, "enable_realtime_ts", false);
storage.flushStorage();
tsdb.addPoint(METRIC_STRING, 1356998400L, 42, tags);
PowerMockito.mockStatic(DateTime.class);
PowerMockito.when(DateTime.currentTimeMillis()).thenReturn(1356998400000L);
query = new TSUIDQuery(tsdb, METRIC_STRING, tags);
final IncomingDataPoint dp = query.getLastPoint(true, 0).join();
assertEquals(1356998400000L, dp.getTimestamp());
assertEquals(METRIC_STRING, dp.getMetric());
assertSame(tags, dp.getTags());
assertEquals("42", dp.getValue());
assertEquals(UniqueId.uidToString(TSUID), dp.getTSUID());
}
use of net.opentsdb.core.IncomingDataPoint in project opentsdb by OpenTSDB.
the class TestTSUIDQuery method getLastPointMetricZeroBackscanOnePoint.
@Test
public void getLastPointMetricZeroBackscanOnePoint() throws Exception {
Whitebox.setInternalState(config, "enable_tsuid_incrementing", false);
Whitebox.setInternalState(config, "enable_realtime_ts", false);
storage.flushStorage();
tsdb.addPoint(METRIC_STRING, 1356998400L, 42, tags);
PowerMockito.mockStatic(DateTime.class);
PowerMockito.when(DateTime.currentTimeMillis()).thenReturn(1356998400000L);
query = new TSUIDQuery(tsdb, METRIC_STRING, tags);
final IncomingDataPoint dp = query.getLastPoint(false, 0).join();
assertEquals(1356998400000L, dp.getTimestamp());
assertNull(dp.getMetric());
assertNull(dp.getTags());
assertEquals("42", dp.getValue());
assertEquals(UniqueId.uidToString(TSUID), dp.getTSUID());
}
Aggregations