Search in sources :

Example 41 with RollupInterval

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

the class TestMultiGetQuery method prepareRowBaseTimesRollup.

@Test
public void prepareRowBaseTimesRollup() throws Exception {
    RollupInterval interval = RollupInterval.builder().setTable("tsdb").setPreAggregationTable("tsdb_agg").setInterval("1m").setRowSpan("1h").build();
    RollupQuery rq = new RollupQuery(interval, aggregator, 0, aggregator);
    MultiGetQuery mgq = new MultiGetQuery(tsdb, query, METRIC_BYTES, q_tags, start_ts, end_ts, tsdb.dataTable(), spans, null, 0, rq, query_stats, 0, max_bytes, false, multiget_no_meta);
    List<Long> timestamps = mgq.prepareRowBaseTimesRollup();
    assertEquals(17, timestamps.size());
    long expected = 1481227200;
    for (final long ts : timestamps) {
        assertEquals(expected, ts);
        expected += 3600;
    }
    interval = RollupInterval.builder().setTable("tsdb").setPreAggregationTable("tsdb_agg").setInterval("1m").setRowSpan("1d").build();
    rq = new RollupQuery(interval, aggregator, 0, aggregator);
    mgq = new MultiGetQuery(tsdb, query, METRIC_BYTES, q_tags, start_ts, end_ts, tsdb.dataTable(), spans, null, 0, rq, query_stats, 0, max_bytes, false, multiget_no_meta);
    timestamps = mgq.prepareRowBaseTimesRollup();
    timestamps = mgq.prepareRowBaseTimesRollup();
    assertEquals(2, timestamps.size());
    expected = 1481155200;
    for (final long ts : timestamps) {
        assertEquals(expected, ts);
        expected += 86400;
    }
}
Also used : RollupQuery(net.opentsdb.rollup.RollupQuery) RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test)

Example 42 with RollupInterval

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

the class TestTSDBAddAggregatePoint method addAggregatePointRollupRouting.

@Test
public void addAggregatePointRollupRouting() throws Exception {
    RollupInterval interval = rollup_config.getRollupInterval("10m");
    tsdb.addAggregatePoint(METRIC_STRING, 1356998400, 42, tags, false, "10m", "sum", null).joinUninterruptibly();
    assertEquals(42, storage.getColumn(interval.getTemporalTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval))[0]);
    // make sure it didn't get into the tsdb table
    assertNull(storage.getColumn(TSDB_TABLE, row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval)));
    storage.flushStorage();
    interval = rollup_config.getRollupInterval("1h");
    tsdb.addAggregatePoint(METRIC_STRING, 1356998400, 42, tags, false, "1h", "sum", null).joinUninterruptibly();
    assertEquals(42, storage.getColumn(interval.getTemporalTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval))[0]);
    assertNull(storage.getColumn(TSDB_TABLE, row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval)));
    assertNull(storage.getColumn(rollup_config.getRollupInterval("10m").getTemporalTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, rollup_config.getRollupInterval("10m"))));
    storage.flushStorage();
    interval = rollup_config.getRollupInterval("1d");
    tsdb.addAggregatePoint(METRIC_STRING, 1356998400, 42, tags, false, "1d", "sum", null).joinUninterruptibly();
    assertEquals(42, storage.getColumn(interval.getTemporalTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval))[0]);
    assertNull(storage.getColumn(TSDB_TABLE, row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval)));
    assertNull(storage.getColumn(rollup_config.getRollupInterval("1h").getTemporalTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, rollup_config.getRollupInterval("1h"))));
    storage.flushStorage();
    // other aggs
    interval = rollup_config.getRollupInterval("1h");
    tsdb.addAggregatePoint(METRIC_STRING, 1356998400, 42, tags, false, "1h", "max", null).joinUninterruptibly();
    assertEquals(42, storage.getColumn(interval.getTemporalTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 2, interval))[0]);
    tsdb.addAggregatePoint(METRIC_STRING, 1356998400, 42, tags, false, "1h", "min", null).joinUninterruptibly();
    assertEquals(42, storage.getColumn(interval.getTemporalTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 3, interval))[0]);
    tsdb.addAggregatePoint(METRIC_STRING, 1356998400, 42, tags, false, "1h", "count", null).joinUninterruptibly();
    assertEquals(42, storage.getColumn(interval.getTemporalTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 1, interval))[0]);
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test)

Example 43 with RollupInterval

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

the class TestTSDBAddAggregatePoint method addAggregatePointGroupByRollupRouting.

@Test
public void addAggregatePointGroupByRollupRouting() throws Exception {
    row = getRowKey(METRIC_STRING, 1356998400, TAGK_STRING, TAGV_STRING, agg_tag_key, "SUM");
    assertNull(tags.get(agg_tag_key));
    RollupInterval interval = rollup_config.getRollupInterval("10m");
    tsdb.addAggregatePoint(METRIC_STRING, 1356998400, 42, tags, true, "10m", "sum", "sum").joinUninterruptibly();
    assertEquals(42, storage.getColumn(interval.getGroupbyTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval))[0]);
    // make sure it didn't get into the tsdb table OR rollup table
    assertNull(storage.getColumn(TSDB_TABLE, row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval)));
    assertNull(storage.getColumn(interval.getTemporalTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval)));
    storage.flushStorage();
    interval = rollup_config.getRollupInterval("1h");
    tsdb.addAggregatePoint(METRIC_STRING, 1356998400, 42, tags, true, "1h", "sum", "sum").joinUninterruptibly();
    assertEquals(42, storage.getColumn(interval.getGroupbyTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval))[0]);
    assertNull(storage.getColumn(TSDB_TABLE, row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval)));
    assertNull(storage.getColumn(interval.getTemporalTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval)));
    storage.flushStorage();
    interval = rollup_config.getRollupInterval("1d");
    tsdb.addAggregatePoint(METRIC_STRING, 1356998400, 42, tags, true, "1d", "sum", "sum").joinUninterruptibly();
    assertEquals(42, storage.getColumn(interval.getGroupbyTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval))[0]);
    assertNull(storage.getColumn(TSDB_TABLE, row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval)));
    assertNull(storage.getColumn(interval.getTemporalTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 0, interval)));
    storage.flushStorage();
    tags.remove(agg_tag_key);
    // other aggs
    row = getRowKey(METRIC_STRING, 1356998400, TAGK_STRING, TAGV_STRING, agg_tag_key, "MAX");
    RowKey.prefixKeyWithSalt(row);
    interval = rollup_config.getRollupInterval("1h");
    tsdb.addAggregatePoint(METRIC_STRING, 1356998400, 42, tags, true, "1h", "max", "max").joinUninterruptibly();
    assertEquals(42, storage.getColumn(interval.getGroupbyTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 2, interval))[0]);
    storage.flushStorage();
    tags.remove(agg_tag_key);
    row = getRowKey(METRIC_STRING, 1356998400, TAGK_STRING, TAGV_STRING, agg_tag_key, "MIN");
    RowKey.prefixKeyWithSalt(row);
    tsdb.addAggregatePoint(METRIC_STRING, 1356998400, 42, tags, true, "1h", "min", "min").joinUninterruptibly();
    assertEquals(42, storage.getColumn(interval.getGroupbyTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 3, interval))[0]);
    storage.flushStorage();
    tags.remove(agg_tag_key);
    row = getRowKey(METRIC_STRING, 1356998400, TAGK_STRING, TAGV_STRING, agg_tag_key, "COUNT");
    RowKey.prefixKeyWithSalt(row);
    tsdb.addAggregatePoint(METRIC_STRING, 1356998400, 42, tags, true, "1h", "count", "count").joinUninterruptibly();
    assertEquals(42, storage.getColumn(interval.getGroupbyTable(), row, FAMILY, RollupUtils.buildRollupQualifier(1356998400, (short) 0, 1, interval))[0]);
}
Also used : RollupInterval(net.opentsdb.rollup.RollupInterval) Test(org.junit.Test)

Example 44 with RollupInterval

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

the class TestFillingDownsampler method testDownsampler_rollupMissing.

@Test
public void testDownsampler_rollupMissing() {
    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.SUM, 3600000, Aggregators.SUM);
    final long baseTime = 500L;
    final SeekableView source = SeekableViewsForTest.fromArray(new DataPoint[] { MutableDataPoint.ofDoubleValue(baseTime + 25L * 4L, 1.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 5L, 1.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 7L, 1.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 12L, 1.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 15L, 1.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 24L, 1.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 25L, 1.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 26L, 1.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 27L, 1.) });
    specification = new DownsamplingSpecification("100ms-sum-nan");
    final Downsampler downsampler = new FillingDownsampler(source, baseTime, baseTime + 36 * 25L, specification, 0, 0, rollup_query);
    long timestamp = baseTime;
    step(downsampler, timestamp, Double.NaN);
    step(downsampler, timestamp += 100, 3.);
    step(downsampler, timestamp += 100, Double.NaN);
    step(downsampler, timestamp += 100, 2.);
    step(downsampler, timestamp += 100, Double.NaN);
    step(downsampler, timestamp += 100, Double.NaN);
    step(downsampler, timestamp += 100, 4.);
    step(downsampler, timestamp += 100, Double.NaN);
    step(downsampler, timestamp += 100, Double.NaN);
    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 45 with RollupInterval

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

the class TestFillingDownsampler method testDownsampler_rollup.

@Test
public void testDownsampler_rollup() {
    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.SUM, 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-sum-nan");
    final Downsampler downsampler = new FillingDownsampler(source, baseTime, baseTime + 12L * 25L, specification, 0, 0, rollup_query);
    long timestamp = baseTime;
    step(downsampler, timestamp, 42.);
    step(downsampler, timestamp += 100, 26.);
    step(downsampler, timestamp += 100, 10.);
    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)

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