Search in sources :

Example 1 with IncomingDataPoint

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;
}
Also used : HashMap(java.util.HashMap) IncomingDataPoint(net.opentsdb.core.IncomingDataPoint) IncomingDataPoint(net.opentsdb.core.IncomingDataPoint)

Example 2 with IncomingDataPoint

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());
}
Also used : IncomingDataPoint(net.opentsdb.core.IncomingDataPoint) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) BaseTsdbTest(net.opentsdb.core.BaseTsdbTest) Test(org.junit.Test)

Example 3 with IncomingDataPoint

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());
}
Also used : IncomingDataPoint(net.opentsdb.core.IncomingDataPoint) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) BaseTsdbTest(net.opentsdb.core.BaseTsdbTest) Test(org.junit.Test)

Example 4 with IncomingDataPoint

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());
}
Also used : IncomingDataPoint(net.opentsdb.core.IncomingDataPoint) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) BaseTsdbTest(net.opentsdb.core.BaseTsdbTest) Test(org.junit.Test)

Example 5 with IncomingDataPoint

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());
}
Also used : IncomingDataPoint(net.opentsdb.core.IncomingDataPoint) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) BaseTsdbTest(net.opentsdb.core.BaseTsdbTest) Test(org.junit.Test)

Aggregations

IncomingDataPoint (net.opentsdb.core.IncomingDataPoint)22 BaseTsdbTest (net.opentsdb.core.BaseTsdbTest)12 Test (org.junit.Test)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 HashMap (java.util.HashMap)7 ArrayList (java.util.ArrayList)5 RollUpDataPoint (net.opentsdb.rollup.RollUpDataPoint)5 Callback (com.stumbleupon.async.Callback)4 Deferred (com.stumbleupon.async.Deferred)3 IOException (java.io.IOException)3 TimeoutException (com.stumbleupon.async.TimeoutException)2 Map (java.util.Map)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 DataPoint (net.opentsdb.core.DataPoint)2 HistogramPojo (net.opentsdb.core.HistogramPojo)2 NoSuchUniqueName (net.opentsdb.uid.NoSuchUniqueName)2 HBaseException (org.hbase.async.HBaseException)2 Timeout (org.jboss.netty.util.Timeout)2 TimerTask (org.jboss.netty.util.TimerTask)2 DeferredGroupException (com.stumbleupon.async.DeferredGroupException)1