Search in sources :

Example 26 with RollupInterval

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

the class TestFillingDownsampler method testDownsampler_rollupAvg.

@Test
public void testDownsampler_rollupAvg() {
    final RollupInterval interval = RollupInterval.builder().setTable("tsdb-rollup-1h").setPreAggregationTable("tsdb-agg-rollup-1h").setInterval("1h").setRowSpan("1d").build();
    final RollupQuery rollup_query = new RollupQuery(interval, Aggregators.AVG, 3600000, Aggregators.SUM);
    final long baseTime = 1000L;
    final SeekableView source = SeekableViewsForTest.fromArray(new DataPoint[] { MutableDataPoint.ofDoubleValue(baseTime + 25L * 0L, 12.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 1L, 11.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 2L, 10.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 3L, 9.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 4L, 8.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 5L, 7.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 6L, 6.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 7L, 5.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 8L, 4.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 9L, 3.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 10L, 2.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 11L, 1.) });
    specification = new DownsamplingSpecification("100ms-avg-nan");
    final Downsampler downsampler = new FillingDownsampler(source, baseTime, baseTime + 12L * 25L, specification, 0, 0, rollup_query);
    long timestamp = baseTime;
    step(downsampler, timestamp, 10.5);
    step(downsampler, timestamp += 100, 6.5);
    step(downsampler, timestamp += 100, 2.5);
    assertFalse(downsampler.hasNext());
}
Also used : MockSeekableView(net.opentsdb.core.SeekableViewsForTest.MockSeekableView) RollupQuery(net.opentsdb.rollup.RollupQuery) RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test)

Example 27 with RollupInterval

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

the class TestTsdbQueryRollup method run10mAvgLongSingleTSMissingToZero.

@Test
public void run10mAvgLongSingleTSMissingToZero() throws Exception {
    final RollupInterval interval = rollup_config.getRollupInterval("10m");
    storePoint(1356998400, 20, Aggregators.SUM, interval);
    // storePoint(1356998400, 2, Aggregators.COUNT, interval);
    // storePoint(1356999000, 40, Aggregators.SUM, interval);
    storePoint(1356999000, 5, Aggregators.COUNT, interval);
    storePoint(1356999600, 60, Aggregators.SUM, interval);
    // storePoint(1356999600, 3, Aggregators.COUNT, interval);
    // storePoint(1357000200, 80, Aggregators.SUM, interval);
    storePoint(1357000200, 4, Aggregators.COUNT, interval);
    Aggregator aggr = Aggregators.AVG;
    setQuery(interval.getInterval(), aggr, tags, aggr);
    query.configureFromQuery(ts_query, 0);
    final DataPoints[] dps = query.run();
    assertEquals(1, dps.length);
    assertEquals("", dps[0].metricName());
    assertTrue(dps[0].getAggregatedTags().isEmpty());
    assertNull(dps[0].getAnnotations());
    assertNull(dps[0].getTags().get(TAGK_STRING));
    final SeekableView it = dps[0].iterator();
    assertFalse(it.hasNext());
    assertEquals(0, dps[0].size());
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 28 with RollupInterval

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

the class TestTsdbQueryRollup method runDupes.

@Test
public void runDupes() throws Exception {
    storage.flushStorage();
    final RollupInterval interval = rollup_config.getRollupInterval("10m");
    final Aggregator aggr = Aggregators.SUM;
    tsdb.addAggregatePoint(METRIC_STRING, 1357026600L, Integer.MAX_VALUE, tags, false, interval.getInterval(), aggr.toString(), null).joinUninterruptibly();
    tsdb.addAggregatePoint(METRIC_STRING, 1357026600L, 42.5F, tags, false, interval.getInterval(), aggr.toString(), null).joinUninterruptibly();
    setQuery(interval.getInterval(), aggr, tags, aggr);
    query.configureFromQuery(ts_query, 0);
    try {
        query.run();
        fail("Expected IllegalDataException");
    } catch (IllegalDataException e) {
    }
    config.setFixDuplicates(true);
    DataPoints[] dps = query.run();
    DataPoint dp = dps[0].iterator().next();
    assertEquals(1357026600000L, dp.timestamp());
    assertEquals(42.5F, dp.toDouble(), 0.0001);
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 29 with RollupInterval

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

the class TestTsdbQueryRollup method run10mAvgLongSingleTSMissingASum.

@Test
public void run10mAvgLongSingleTSMissingASum() throws Exception {
    final RollupInterval interval = rollup_config.getRollupInterval("10m");
    storePoint(1356998400, 20, Aggregators.SUM, interval);
    storePoint(1356998400, 2, Aggregators.COUNT, interval);
    // storePoint(1356999000, 40, Aggregators.SUM, interval);
    storePoint(1356999000, 5, Aggregators.COUNT, interval);
    storePoint(1356999600, 60, Aggregators.SUM, interval);
    storePoint(1356999600, 3, Aggregators.COUNT, interval);
    storePoint(1357000200, 80, Aggregators.SUM, interval);
    storePoint(1357000200, 4, Aggregators.COUNT, interval);
    Aggregator aggr = Aggregators.AVG;
    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 SeekableView it = dps[0].iterator();
    DataPoint dp = it.next();
    assertEquals(1356998400000L, dp.timestamp());
    assertEquals(10, dp.doubleValue(), 0.0001);
    dp = it.next();
    assertEquals(1356999600000L, dp.timestamp());
    assertEquals(20, dp.doubleValue(), 0.0001);
    dp = it.next();
    assertEquals(1357000200000L, dp.timestamp());
    assertEquals(20, dp.doubleValue(), 0.0001);
    assertFalse(it.hasNext());
    assertEquals(3, dps[0].size());
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 30 with RollupInterval

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

the class TestTsdbQueryRollup method run10mSumLongSingleTSRate.

@Test
public void run10mSumLongSingleTSRate() throws Exception {
    final RollupInterval interval = rollup_config.getRollupInterval("10m");
    final Aggregator aggr = Aggregators.SUM;
    final long start_timestamp = 1356998400;
    final long end_timestamp = 1357041600;
    storeLongRollup(start_timestamp, end_timestamp, false, false, interval, aggr);
    setQuery(interval.getInterval(), aggr, tags, aggr);
    ts_query.getQueries().get(0).setRate(true);
    query.configureFromQuery(ts_query, 0);
    final DataPoints[] dps = query.run();
    assertNotNull(dps);
    assertEquals(METRIC_STRING, dps[0].metricName());
    assertTrue(dps[0].getAggregatedTags().isEmpty());
    assertNull(dps[0].getAnnotations());
    assertEquals(TAGV_STRING, dps[0].getTags().get(TAGK_STRING));
    long expected_timestamp = (start_timestamp + interval.getIntervalSeconds()) * 1000;
    for (DataPoint dp : dps[0]) {
        assertEquals(1.0F, dp.doubleValue(), 0.00001);
        assertEquals(expected_timestamp, dp.timestamp());
        expected_timestamp += interval.getIntervalSeconds() * 1000;
    }
    assertEquals(72, dps[0].size());
}
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