use of net.opentsdb.rollup.RollupQuery in project opentsdb by OpenTSDB.
the class TestTsdbQuery method needsSplittingReturnsFalseIfNoSLAConfigured.
@Test
public void needsSplittingReturnsFalseIfNoSLAConfigured() {
Whitebox.setInternalState(tsdb, "rollups_split_queries", true);
RollupInterval oneHourWithDelay = RollupInterval.builder().setTable("fake-rollup-table").setPreAggregationTable("fake-preagg-table").setInterval("1h").setRowSpan("1d").setDelaySla(null).build();
RollupQuery rollup_query = new RollupQuery(oneHourWithDelay, Aggregators.SUM, 3600000, Aggregators.SUM);
Whitebox.setInternalState(query, "rollup_query", rollup_query);
assertTrue(query.isRollupQuery());
assertFalse(query.needsSplitting());
}
use of net.opentsdb.rollup.RollupQuery in project opentsdb by OpenTSDB.
the class BaseTsdbTest method makeRollupQuery.
RollupQuery makeRollupQuery() {
Whitebox.setInternalState(tsdb, "rollups_split_queries", true);
final RollupInterval oneHourWithDelay = RollupInterval.builder().setTable("fake-rollup-table").setPreAggregationTable("fake-preagg-table").setInterval("1h").setRowSpan("1d").setDelaySla("2d").build();
return new RollupQuery(oneHourWithDelay, Aggregators.SUM, 3600000, Aggregators.SUM);
}
use of net.opentsdb.rollup.RollupQuery in project opentsdb by OpenTSDB.
the class TestDownsampler method testDownsampler_rollupSum.
@Test
public void testDownsampler_rollupSum() {
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);
source = spy(SeekableViewsForTest.fromArray(new DataPoint[] { MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 0, 1), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 1, 2), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 2, 4), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 3, 8), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 4, 16), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 5, 32), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 6, 64), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 7, 128), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 8, 256), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 9, 512), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 10, 1024) }));
specification = new DownsamplingSpecification("10s-sum");
downsampler = new Downsampler(source, specification, 0, 0, rollup_query);
verify(source, never()).next();
List<Double> values = Lists.newArrayList();
List<Long> timestamps_in_millis = Lists.newArrayList();
while (downsampler.hasNext()) {
DataPoint dp = downsampler.next();
assertFalse(dp.isInteger());
values.add(dp.doubleValue());
timestamps_in_millis.add(dp.timestamp());
}
assertEquals(6, values.size());
assertEquals(3, values.get(0), 0.0000001);
assertEquals(BASE_TIME + 00000L, timestamps_in_millis.get(0).longValue());
assertEquals(12, values.get(1), 0.0000001);
assertEquals(BASE_TIME + 10000L, timestamps_in_millis.get(1).longValue());
assertEquals(48, values.get(2), 0.0000001);
assertEquals(BASE_TIME + 20000L, timestamps_in_millis.get(2).longValue());
assertEquals(192, values.get(3), 0.0000001);
assertEquals(BASE_TIME + 30000L, timestamps_in_millis.get(3).longValue());
assertEquals(768, values.get(4), 0.0000001);
assertEquals(BASE_TIME + 40000L, timestamps_in_millis.get(4).longValue());
assertEquals(1024, values.get(5), 0.0000001);
assertEquals(BASE_TIME + 50000L, timestamps_in_millis.get(5).longValue());
}
use of net.opentsdb.rollup.RollupQuery in project opentsdb by OpenTSDB.
the class TestDownsampler method testDownsampler_rollupCount.
@Test
public void testDownsampler_rollupCount() {
final RollupInterval interval = RollupInterval.builder().setTable("tsdb-rollup-1h").setPreAggregationTable("tsdb-agg-rollup-1h").setInterval("1h").setRowSpan("1d").build();
// This query, in combination with the configuration/interval above, is asking for rolled up COUNTs (i.e. already
// downsampled). These COUNTs should then be SUMmed over some interval we'll define later in a DownsamplingSpecification
final RollupQuery rollup_query = new RollupQuery(interval, Aggregators.COUNT, 3600000, Aggregators.SUM);
// These points represent rolled up COUNTs that would be stored in the rollup table (e.g. tsdb-rollup-1h) and as
// such we don't expect these to be COUNTed again on retrieval. These points are at 5s intervals
source = spy(SeekableViewsForTest.fromArray(new DataPoint[] { MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 0, 1), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 1, 2), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 2, 4), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 3, 8) }));
// The rolled up points above are at 5s intervals but we want to downsample these further so that we only get
// points at 10s intervals
specification = new DownsamplingSpecification("10s-count");
downsampler = new Downsampler(source, specification, 0, 0, rollup_query);
verify(source, never()).next();
List<Double> values = Lists.newArrayList();
List<Long> timestamps_in_millis = Lists.newArrayList();
while (downsampler.hasNext()) {
DataPoint dp = downsampler.next();
assertFalse(dp.isInteger());
values.add(dp.doubleValue());
timestamps_in_millis.add(dp.timestamp());
}
// Asserts here different to upstream as there is a bug upstream and the original test was written to pass with the bug.
// 2 points are expected because the 4 points at 5s intervals will be downsampled to 2 points at 10s intervals
assertEquals(2, values.size());
// Expect the SUM of points 1 and 2
assertEquals(3, values.get(0), 0.0000001);
assertEquals(BASE_TIME + 00000L, timestamps_in_millis.get(0).longValue());
// Expect the SUM of points 3 and 4
assertEquals(12, values.get(1), 0.0000001);
assertEquals(BASE_TIME + 10000L, timestamps_in_millis.get(1).longValue());
}
use of net.opentsdb.rollup.RollupQuery in project opentsdb by OpenTSDB.
the class TestDownsampler 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);
source = spy(SeekableViewsForTest.fromArray(new DataPoint[] { MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 0, 1), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 1, 2), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 2, 4), MutableDataPoint.ofDoubleValue(BASE_TIME + 5000L * 3, 8) }));
specification = new DownsamplingSpecification("10s-avg");
downsampler = new Downsampler(source, specification, 0, 0, rollup_query);
verify(source, never()).next();
List<Double> values = Lists.newArrayList();
List<Long> timestamps_in_millis = Lists.newArrayList();
while (downsampler.hasNext()) {
DataPoint dp = downsampler.next();
assertFalse(dp.isInteger());
values.add(dp.doubleValue());
timestamps_in_millis.add(dp.timestamp());
}
assertEquals(2, values.size());
assertEquals(1.5, values.get(0), 0.0000001);
assertEquals(BASE_TIME + 00000L, timestamps_in_millis.get(0).longValue());
assertEquals(6, values.get(1), 0.0000001);
assertEquals(BASE_TIME + 10000L, timestamps_in_millis.get(1).longValue());
}
Aggregations