public static Points<BasicRollup> generateFakeRollupPoints() { Points<BasicRollup> points = new Points<BasicRollup>(); long baseTime = 1234567L; for (int count = 0; count < 5; count++) { final BasicRollup basicRollup = new BasicRollup(); basicRollup.setCount(count * 100); basicRollup.getAverage().setLongValue(count); Points.Point<BasicRollup> point = new Points.Point<BasicRollup>(baseTime + (count * 1000), basicRollup); points.add(point); } return points; }
/** * Create a single {@link com.rackspacecloud.blueflood.service.SingleRollupWriteContext} from the * given {@link com.rackspacecloud.blueflood.types.IMetric} and Granularity. * * @param destGran * @param metric * @return * @throws IOException */ protected SingleRollupWriteContext createSingleRollupWriteContext( Granularity destGran, IMetric metric) throws IOException { Locator locator = metric.getLocator(); Points<SimpleNumber> points = new Points<SimpleNumber>(); points.add( new Points.Point<SimpleNumber>( metric.getCollectionTime(), new SimpleNumber(metric.getMetricValue()))); BasicRollup rollup = BasicRollup.buildRollupFromRawSamples(points); return new SingleRollupWriteContext( rollup, locator, destGran, CassandraModel.getBasicColumnFamily(destGran), metric.getCollectionTime()); }
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; }