private int getNumberOfPointsViaHTTPHandler( HttpRollupsQueryHandler handler, Locator locator, long from, long to, Resolution resolution) throws Exception { final MetricData values = handler.GetDataByResolution( locator.getTenantId(), locator.getMetricName(), from, to, resolution); return values.getData().getPoints().size(); }
private void testHTTPRollupHandlerGetByPoints( Map<Locator, Map<Granularity, Integer>> answers, Map<Granularity, Integer> points, long from, long to) throws Exception { for (Locator locator : locators) { for (Granularity g2 : Granularity.granularities()) { MetricData data = httpHandler.GetDataByPoints( locator.getTenantId(), locator.getMetricName(), baseMillis, baseMillis + 86400000, points.get(g2)); Assert.assertEquals((int) answers.get(locator).get(g2), data.getData().getPoints().size()); Assert.assertEquals(locatorToUnitMap.get(locator), data.getUnit()); } } }
boolean hasAllZeroData(MetricData dataPoints) { boolean allZeroFlag = true; // Points should be of type BasicRollup. Will throw an exception if they are not. Map<Long, Points.Point<BasicRollup>> points = dataPoints.getData().getPoints(); for (Map.Entry<Long, Points.Point<BasicRollup>> entry : points.entrySet()) { BasicRollup basicRollup = entry.getValue().getData(); if ((basicRollup.getMaxValue().isFloatingPoint() ? basicRollup.getMaxValue().toDouble() != 0.0 : basicRollup.getMaxValue().toLong() != 0) && (basicRollup.getMinValue().isFloatingPoint() ? basicRollup.getMinValue().toDouble() != 0.0 : basicRollup.getMinValue().toLong() != 0) && (basicRollup.getAverage().isFloatingPoint() ? basicRollup.getAverage().toDouble() != 0.0 : basicRollup.getAverage().toLong() != 0)) { allZeroFlag = false; break; } } return allZeroFlag; }