public static Points<BluefloodCounterRollup> generateFakeCounterRollupPoints() { Points<BluefloodCounterRollup> points = new Points<BluefloodCounterRollup>(); long startTime = 1234567L; for (int i = 0; i < 5; i++) { long timeNow = startTime + i*1000; Points.Point<BluefloodCounterRollup> point = new Points.Point<BluefloodCounterRollup>(timeNow, new BluefloodCounterRollup() .withCount(i + 1000) .withRate((double) i) .withSampleCount(i+1)); points.add(point); } return points; }
@Override Object convertRollupToObject(Rollup rollup) throws UnsupportedOperationException { if( rollup instanceof BasicRollup ) return ((BasicRollup) rollup).getSum(); else if (rollup instanceof BluefloodTimerRollup) return ((BluefloodTimerRollup) rollup).getSum(); else if (rollup instanceof BluefloodCounterRollup) return ((BluefloodCounterRollup) rollup).getCount(); else // every other type. throw new UnsupportedOperationException( String.format("sum not supported for this type: %s", rollup.getClass().getSimpleName())); }
@Override Object convertRollupToObject(Rollup rollup) throws UnsupportedOperationException { if (rollup instanceof BluefloodTimerRollup) return ((BluefloodTimerRollup) rollup).getRate(); else if (rollup instanceof BluefloodCounterRollup) return ((BluefloodCounterRollup) rollup).getRate(); else // gauge, set, basic throw new UnsupportedOperationException( String.format("rate not supported for this type: %s", rollup.getClass().getSimpleName())); }
protected static List<IMetric> createTestMetricsFromInterface(String tenantId) { IMetric metric; List<IMetric> metrics = new ArrayList<>(); BluefloodCounterRollup counter = new BluefloodCounterRollup(); List<Locator> locators = createComplexTestLocators(tenantId); for (Locator locator : locators) { metric = new PreaggregatedMetric(0, locator, new TimeValue(1, TimeUnit.DAYS), counter); metrics.add(metric); } return metrics; }
@Override Object convertRollupToObject(Rollup rollup) throws UnsupportedOperationException { if (rollup instanceof BaseRollup) return ((BaseRollup) rollup).getCount(); else if (rollup instanceof BluefloodTimerRollup) return ((BluefloodTimerRollup) rollup).getCount(); else if (rollup instanceof BluefloodCounterRollup) return ((BluefloodCounterRollup) rollup).getSampleCount(); else if (rollup instanceof BluefloodSetRollup) return ((BluefloodSetRollup) rollup).getCount(); else // gauge. throw new UnsupportedOperationException( String.format("numPoints not supported for this type: %s", rollup.getClass().getSimpleName())); }
public static Collection<PreaggregatedMetric> convertCounters(String tenant, long timestamp, long flushIntervalMillis, Collection<BluefloodCounter> counters) { List<PreaggregatedMetric> list = new ArrayList<PreaggregatedMetric>(counters.size()); for (BluefloodCounter counter : counters) { Locator locator = Locator.createLocatorFromPathComponents(tenant, counter.getName().split(NAME_DELIMITER, -1)); // flushIntervalMillis could be zero (if not specified in the statsD config). long sampleCount = flushIntervalMillis > 0 ? (long)(counter.getRate().doubleValue() * ((double)flushIntervalMillis/1000d)) : 1; Rollup rollup = new BluefloodCounterRollup() .withCount(resolveNumber(counter.getValue())) .withRate(counter.getRate().doubleValue()) .withSampleCount((int)sampleCount); PreaggregatedMetric metric = new PreaggregatedMetric(timestamp, locator, DEFAULT_TTL, rollup); list.add(metric); } return list; }
} else if (point.getData() instanceof BluefloodCounterRollup) { BluefloodCounterRollup rollup = (BluefloodCounterRollup)point.getData(); numPoints += rollup.getCount().longValue(); filterStatsObject = getFilteredStatsForRollup(rollup, filterStats); } else {