Search in sources :

Example 31 with RollupInterval

use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.

the class TestTsdbQueryRollup method oldStringPrefix.

@Test
public void oldStringPrefix() throws Exception {
    final RollupInterval interval = rollup_config.getRollupInterval("10m");
    final Aggregator aggr = Aggregators.SUM;
    long start_timestamp = 1356998400000L;
    storage.addColumn("tsdb-rollup-10m".getBytes(), getRowKey(METRIC_STRING, 1356998400, TAGK_STRING, TAGV_STRING), "t".getBytes(), new byte[] { 's', 'u', 'm', ':', 0, 0 }, new byte[] { 0x2A });
    final int time_interval = interval.getIntervalSeconds();
    setQuery(interval.getInterval(), aggr, tags, aggr);
    query.configureFromQuery(ts_query, 0);
    final DataPoints[] dps = query.run();
    assertEquals(1, dps.length);
    assertEquals(METRIC_STRING, dps[0].metricName());
    assertTrue(dps[0].getAggregatedTags().isEmpty());
    assertNull(dps[0].getAnnotations());
    assertEquals(TAGV_STRING, dps[0].getTags().get(TAGK_STRING));
    final DataPoint dp = dps[0].iterator().next();
    assertFalse(dp.isInteger());
    assertEquals(42, dp.doubleValue(), 0.001);
    assertEquals(start_timestamp, dp.timestamp());
    assertEquals(1, dps[0].size());
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 32 with RollupInterval

use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.

the class TestTsdbQueryRollup method run10mZimSumLongSingleTS.

// Zimsum == SUM when comparing qualifiers
@Test
public void run10mZimSumLongSingleTS() throws Exception {
    final RollupInterval interval = rollup_config.getRollupInterval("10m");
    // still have to write as sum
    Aggregator aggr = Aggregators.SUM;
    long start_timestamp = 1356998400L;
    long end_timestamp = 1357041599L;
    storeLongRollup(start_timestamp, end_timestamp, false, false, interval, aggr);
    aggr = Aggregators.ZIMSUM;
    setQuery(interval.getInterval(), aggr, tags, aggr);
    query.configureFromQuery(ts_query, 0);
    final DataPoints[] dps = query.run();
    assertEquals(1, dps.length);
    assertEquals(METRIC_STRING, dps[0].metricName());
    assertTrue(dps[0].getAggregatedTags().isEmpty());
    assertNull(dps[0].getAnnotations());
    assertEquals(TAGV_STRING, dps[0].getTags().get(TAGK_STRING));
    int i = 600;
    long ts = start_timestamp * 1000;
    for (final DataPoint dp : dps[0]) {
        assertFalse(dp.isInteger());
        assertEquals(i, dp.doubleValue(), 0.0001);
        assertEquals(ts, dp.timestamp());
        ts += interval.getIntervalSeconds() * 1000;
        i += interval.getIntervalSeconds();
    }
    assertEquals(72, dps[0].size());
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 33 with RollupInterval

use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.

the class TestTsdbQueryRollup method run10mSumFloatSingleTS.

@Test
public void run10mSumFloatSingleTS() throws Exception {
    final RollupInterval interval = rollup_config.getRollupInterval("10m");
    final Aggregator aggr = Aggregators.SUM;
    long start_timestamp = 1356998400L;
    final long end_timestamp = 1357041600;
    storeFloatRollup(start_timestamp, end_timestamp, true, false, interval, aggr);
    setQuery(interval.getInterval(), aggr, tags, aggr);
    query.configureFromQuery(ts_query, 0);
    final DataPoints[] dps = query.run();
    assertEquals(1, dps.length);
    assertEquals(METRIC_STRING, dps[0].metricName());
    assertTrue(dps[0].getAggregatedTags().isEmpty());
    assertNull(dps[0].getAnnotations());
    assertEquals(TAGV_STRING, dps[0].getTags().get(TAGK_STRING));
    double value = 600.5F;
    long expected_timestamp = start_timestamp * 1000;
    for (DataPoint dp : dps[0]) {
        assertEquals(value, dp.doubleValue(), 0.00001);
        assertEquals(expected_timestamp, dp.timestamp());
        value += interval.getIntervalSeconds();
        expected_timestamp += interval.getIntervalSeconds() * 1000;
    }
    assertEquals(73, dps[0].size());
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 34 with RollupInterval

use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.

the class TestTsdbQueryRollup method run10mSumLongDoubleTS.

@Test
public void run10mSumLongDoubleTS() throws Exception {
    final RollupInterval interval = rollup_config.getRollupInterval("10m");
    final Aggregator aggr = Aggregators.SUM;
    long start_timestamp = 1356998400L;
    long end_timestamp = 1357041600L;
    storeLongRollup(1356998400L, end_timestamp, true, false, interval, aggr);
    final int time_interval = interval.getIntervalSeconds();
    tags.clear();
    setQuery(interval.getInterval(), aggr, tags, aggr);
    ts_query.getQueries().get(0).getFilters().clear();
    ts_query.validateAndSetQuery();
    query.configureFromQuery(ts_query, 0);
    final DataPoints[] dps = query.run();
    assertEquals(1, dps.length);
    assertEquals(METRIC_STRING, dps[0].metricName());
    assertEquals(TAGK_STRING, dps[0].getAggregatedTags().get(0));
    assertNull(dps[0].getAnnotations());
    assertNull(dps[0].getTags().get(TAGK_STRING));
    long ts = start_timestamp * 1000;
    for (final DataPoint dp : dps[0]) {
        assertEquals(43800, dp.doubleValue(), 0.0001);
        assertEquals(ts, dp.timestamp());
        ts += time_interval * 1000;
    }
    assertEquals(73, dps[0].size());
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 35 with RollupInterval

use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.

the class TestTsdbQueryRollup method run10mSumLongSingleTSInMS.

@Test(expected = IllegalArgumentException.class)
public void run10mSumLongSingleTSInMS() throws Exception {
    RollupInterval ten_min_interval = rollup_config.getRollupInterval("10m");
    Aggregator aggr = Aggregators.SUM;
    long start_timestamp = 1356998400000L;
    // rollup doesn't accept timestamps in milliseconds
    tsdb.addAggregatePoint(METRIC_STRING, start_timestamp, 0, tags, false, ten_min_interval.getInterval(), aggr.toString(), null).joinUninterruptibly();
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

RollupInterval (net.opentsdb.rollup.RollupInterval)45 Test (org.junit.Test)42 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)26 RollupQuery (net.opentsdb.rollup.RollupQuery)14 MockSeekableView (net.opentsdb.core.SeekableViewsForTest.MockSeekableView)7 ArrayList (java.util.ArrayList)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Callback (com.stumbleupon.async.Callback)1 DeferredGroupException (com.stumbleupon.async.DeferredGroupException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 NoSuchElementException (java.util.NoSuchElementException)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 TagVLiteralOrFilter (net.opentsdb.query.filter.TagVLiteralOrFilter)1 RollupConfig (net.opentsdb.rollup.RollupConfig)1 HBaseException (org.hbase.async.HBaseException)1 PutRequest (org.hbase.async.PutRequest)1 TableNotFoundException (org.hbase.async.TableNotFoundException)1