Search in sources :

Example 16 with IncomingDataPoint

use of net.opentsdb.core.IncomingDataPoint in project opentsdb by OpenTSDB.

the class TestTSUIDQuery method getLastPointTSUIDMetricNSUINotResolved.

// While these NSUI shouldn't happen, it's possible if someone deletes a metric
// or tag but not the actual data.
@Test
public void getLastPointTSUIDMetricNSUINotResolved() throws Exception {
    Whitebox.setInternalState(config, "enable_tsuid_incrementing", false);
    Whitebox.setInternalState(config, "enable_realtime_ts", false);
    storage.flushStorage();
    storage.addColumn(MockBase.stringToBytes("00000350E22700000001000001"), QUAL, VAL);
    final byte[] tsuid = new byte[] { 0, 0, 3, 0, 0, 1, 0, 0, 1 };
    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 17 with IncomingDataPoint

use of net.opentsdb.core.IncomingDataPoint in project opentsdb by OpenTSDB.

the class TestTSUIDQuery method getLastPointTSUIDTagvNSUINotResolved.

@Test
public void getLastPointTSUIDTagvNSUINotResolved() throws Exception {
    Whitebox.setInternalState(config, "enable_tsuid_incrementing", false);
    Whitebox.setInternalState(config, "enable_realtime_ts", false);
    storage.flushStorage();
    storage.addColumn(MockBase.stringToBytes("00000150E22700000001000003"), QUAL, VAL);
    final byte[] tsuid = new byte[] { 0, 0, 1, 0, 0, 1, 0, 0, 3 };
    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 18 with IncomingDataPoint

use of net.opentsdb.core.IncomingDataPoint in project opentsdb by OpenTSDB.

the class TestTSUIDQuery method getLastPointMetricOneBackscanInRange.

@Test
public void getLastPointMetricOneBackscanInRange() 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(1357002000000L);
    query = new TSUIDQuery(tsdb, METRIC_STRING, tags);
    final IncomingDataPoint dp = query.getLastPoint(false, 1).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 19 with IncomingDataPoint

use of net.opentsdb.core.IncomingDataPoint in project opentsdb by OpenTSDB.

the class TestTSUIDQuery method getLastPointTSUIDManyBackscanInRange.

@Test
public void getLastPointTSUIDManyBackscanInRange() 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, TSUID);
    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 20 with IncomingDataPoint

use of net.opentsdb.core.IncomingDataPoint in project opentsdb by OpenTSDB.

the class TestTSUIDQuery method getLastPointTSUIDTagkNSUINotResolved.

@Test
public void getLastPointTSUIDTagkNSUINotResolved() throws Exception {
    Whitebox.setInternalState(config, "enable_tsuid_incrementing", false);
    Whitebox.setInternalState(config, "enable_realtime_ts", false);
    storage.flushStorage();
    storage.addColumn(MockBase.stringToBytes("00000150E22700000003000001"), QUAL, VAL);
    final byte[] tsuid = new byte[] { 0, 0, 1, 0, 0, 3, 0, 0, 1 };
    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)

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