Search in sources :

Example 36 with RollupInterval

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

the class TestTsdbQueryRollup method run30mSumLongSingleTS.

// In this case we're downsampling rolled up values
@Test
public void run30mSumLongSingleTS() throws Exception {
    final RollupInterval interval = rollup_config.getRollupInterval("10m");
    final Aggregator aggr = Aggregators.SUM;
    long start_timestamp = 1356998400L;
    long end_timestamp = 1357041599L;
    storeLongRollup(start_timestamp, end_timestamp, false, false, interval, aggr);
    setQuery("30m", aggr, tags, aggr);
    query.configureFromQuery(ts_query, 0);
    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 = 3600;
    long ts = start_timestamp * 1000;
    for (DataPoint dp : dps[0]) {
        assertEquals(value, dp.doubleValue(), 0);
        assertEquals(ts, dp.timestamp());
        value += 5400;
        ts += (interval.getIntervalSeconds() * 3) * 1000;
    }
    assertEquals(24, dps[0].size());
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 37 with RollupInterval

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

the class TestTsdbQueryRollup method run10mMaxLongSingleTS.

@Test
public void run10mMaxLongSingleTS() throws Exception {
    final RollupInterval interval = rollup_config.getRollupInterval("10m");
    final Aggregator aggr = Aggregators.MAX;
    long start_timestamp = 1356998400L;
    long end_timestamp = 1357041600L;
    storeLongRollup(1356998400L, end_timestamp, false, false, interval, aggr);
    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));
    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 += time_interval * 1000;
        i += time_interval;
    }
    assertEquals(73, dps[0].size());
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 38 with RollupInterval

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

the class TestTsdbQueryRollup method run10mSumLongDoubleTSFilter.

// Make sure filtering on time series still operates
@Test
public void run10mSumLongDoubleTSFilter() 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();
    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 += time_interval * 1000;
        i += time_interval;
    }
    assertEquals(73, dps[0].size());
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 39 with RollupInterval

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

the class TestTsdbQueryRollup method run10mAvgLongSingleTSMissingCount.

@Test
public void run10mAvgLongSingleTSMissingCount() throws Exception {
    final RollupInterval interval = rollup_config.getRollupInterval("10m");
    Aggregator aggr = Aggregators.SUM;
    long start_timestamp = 1356998400L;
    long end_timestamp = 1357041600L;
    storeLongRollup(start_timestamp, end_timestamp, false, false, interval, aggr);
    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));
    assertFalse(dps[0].iterator().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 40 with RollupInterval

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

the class MultiGetQuery method prepareRowBaseTimesRollup.

/**
 * Generates a list of Unix Epoch Timestamps for the row key base times given
 * the start and end times of the query and rollup interval given.
 * @return A non-null list of at least one base row.
 */
@VisibleForTesting
List<Long> prepareRowBaseTimesRollup() {
    final RollupInterval interval = rollup_query.getRollupInterval();
    // standard TSDB table format, i.e. we're using the default table and schema
    if (interval.getUnits() == 'h') {
        return prepareRowBaseTimes();
    } else {
        final List<Long> row_base_times = new ArrayList<Long>((int) ((end_row_time - start_row_time) / interval.getIntervals()));
        long ts = RollupUtils.getRollupBasetime(start_row_time, interval);
        while (ts <= end_row_time) {
            row_base_times.add(ts);
            // TODO - possible this could overshoot in some cases. It shouldn't
            // if the rollups are properly configured, but... you know. Check it.
            ts = RollupUtils.getRollupBasetime(ts + (interval.getIntervalSeconds() * interval.getIntervals()), interval);
        }
        return row_base_times;
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) ArrayList(java.util.ArrayList) RollupInterval(net.opentsdb.rollup.RollupInterval) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

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