@Test public void testChunkIngestion() { final String testMetricName1 = "testMetric1"; final String expectedMetricName1 = testMetricName1 + " dc=dc1 host=h1"; final String queryTagString = " host=h1 dc=dc1"; String inputTagString = "host=h1 dc=dc1"; parseAndAddOpenTSDBMetric(makeMetricString(testMetricName1, inputTagString, testTs, testValue), chunk); assertTrue(chunk.query(Query.parse("test")).isEmpty()); assertTrue(chunk.query(Query.parse("test host=h1")).isEmpty()); assertTrue(chunk.query(Query.parse("test host=h1 dc=dc1")).isEmpty()); final List<TimeSeries> series1 = chunk.query(Query.parse(testMetricName1 + queryTagString)); assertEquals(1, series1.size()); assertEquals(expectedMetricName1, series1.get(0).getMetric()); assertEquals(1, series1.get(0).getPoints().size()); Assert.assertThat(series1.get(0).getPoints(), IsIterableContainingInOrder.contains(new Point(testTs, testValue))); parseAndAddOpenTSDBMetric( makeMetricString(testMetricName1, inputTagString, testTs * 2, testValue * 2), chunk); assertTrue(chunk.query(Query.parse("test")).isEmpty()); assertTrue(chunk.query(Query.parse("test host=h1")).isEmpty()); assertTrue(chunk.query(Query.parse("test host=h1 dc=dc1")).isEmpty()); final List<TimeSeries> series2 = chunk.query(Query.parse(testMetricName1 + queryTagString)); assertEquals(1, series2.size()); assertEquals(expectedMetricName1, series2.get(0).getMetric()); assertEquals(2, series2.get(0).getPoints().size()); List<Point> expectedPoints2 = Arrays.asList(new Point(testTs, testValue), new Point(testTs * 2, testValue * 2)); final TimeSeries timeseries12 = new TimeSeries(expectedMetricName1, expectedPoints2); Assert.assertThat(series2, IsIterableContainingInOrder.contains(timeseries12)); final String testMetricName2 = "testMetric2"; final String expectedMetricName2 = testMetricName2 + " dc=dc1 host=h1"; parseAndAddOpenTSDBMetric( makeMetricString(testMetricName2, inputTagString, testTs * 3, testValue * 3), chunk); assertTrue(chunk.query(Query.parse("test")).isEmpty()); assertTrue(chunk.query(Query.parse("test host=h1")).isEmpty()); assertTrue(chunk.query(Query.parse("test host=h1 dc=dc1")).isEmpty()); final Point point21 = new Point(testTs * 3, testValue * 3); Assert.assertThat(chunk.query(Query.parse(testMetricName2 + queryTagString)), IsIterableContainingInOrder.contains(new TimeSeries(expectedMetricName2, Collections.singletonList(point21)))); Assert.assertThat(chunk.query(Query.parse(testMetricName1 + queryTagString)), IsIterableContainingInOrder.contains(timeseries12)); parseAndAddOpenTSDBMetric( makeMetricString(testMetricName2, inputTagString, testTs * 3, testValue * 3), chunk); List<Point> expectedPoints4 = Arrays.asList(point21, point21); Assert.assertThat(chunk.query(Query.parse(testMetricName2 + queryTagString)), IsIterableContainingInOrder.contains(new TimeSeries(expectedMetricName2, expectedPoints4))); Assert.assertThat(chunk.query(Query.parse(testMetricName1 + queryTagString)), IsIterableContainingInOrder.contains(timeseries12)); parseAndAddOpenTSDBMetric( makeMetricString(testMetricName2, inputTagString, testTs * 4, testValue * 4), chunk); List<Point> expectedPoints5 = Arrays.asList(point21, point21, new Point(testTs * 4, testValue * 4)); Assert.assertThat(chunk.query(Query.parse(testMetricName2 + queryTagString)), IsIterableContainingInOrder.contains(new TimeSeries(expectedMetricName2, expectedPoints5))); Assert.assertThat(chunk.query(Query.parse(testMetricName1 + queryTagString)), IsIterableContainingInOrder.contains(timeseries12)); assertTrue(chunk.query(Query.parse("test")).isEmpty()); assertTrue(chunk.query(Query.parse("test host=h1")).isEmpty()); assertTrue(chunk.query(Query.parse("test host=h1 dc=dc1")).isEmpty()); }
@Override public List<TimeSeries> query(Query query) { return store.getSeries(query); }
ChunkImpl implements Chunk { @Override public List<TimeSeries> query(Query query) { return store.getSeries(query); } }
ChunkImpl implements Chunk { @Override public List<TimeSeries> query(Query query) { return store.getSeries(query); } ChunkImpl(MetricAndTagStore store, ChunkInfo chunkInfo); }
ChunkImpl implements Chunk { @Override public List<TimeSeries> query(Query query) { return store.getSeries(query); } ChunkImpl(MetricAndTagStore store, ChunkInfo chunkInfo); @Override List<TimeSeries> query(Query query); @Override void addPoint(Metric metric, long ts, double value); @Override ChunkInfo info(); @Override boolean isReadOnly(); @Override boolean containsDataInTimeRange(long startTs, long endTs); @Override Map<String, Object> getStats(); @Override void close(); @Override void setReadOnly(boolean readOnly); MetricAndTagStore getStore(); @Override String toString(); }
ChunkImpl implements Chunk { @Override public List<TimeSeries> query(Query query) { return store.getSeries(query); } ChunkImpl(MetricAndTagStore store, ChunkInfo chunkInfo); @Override List<TimeSeries> query(Query query); @Override void addPoint(Metric metric, long ts, double value); @Override ChunkInfo info(); @Override boolean isReadOnly(); @Override boolean containsDataInTimeRange(long startTs, long endTs); @Override Map<String, Object> getStats(); @Override void close(); @Override void setReadOnly(boolean readOnly); MetricAndTagStore getStore(); @Override String toString();  }