public static Points<BluefloodTimerRollup> generateFakeTimerRollups() { Points<BluefloodTimerRollup> points = new Points<BluefloodTimerRollup>(); long startTime = 1234567L; for (int i = 0; i < 5; i++) { long timeNow = startTime + i*1000; BluefloodTimerRollup rollup = new BluefloodTimerRollup() .withAverage(i) .withCount(i) .withCountPS(i*0.1d) .withMaxValue(i) .withMinValue(i) .withSum(Double.valueOf(i+i)) .withVariance(i); rollup.setPercentile("50", i); rollup.setPercentile("99", i * 2 + 1); Points.Point<BluefloodTimerRollup> point = new Points.Point<BluefloodTimerRollup>(timeNow, rollup); points.add(point); } return points; } }
@Override Object convertRollupToObject(Rollup rollup) throws UnsupportedOperationException { if (rollup instanceof BasicRollup) return ((BasicRollup) rollup).getAverage(); else if (rollup instanceof BluefloodTimerRollup) return ((BluefloodTimerRollup) rollup).getAverage(); else // counters, sets throw new UnsupportedOperationException( String.format("average not supported for this type: %s", rollup.getClass().getSimpleName())); }
@Override Object convertRollupToObject(Rollup rollup) throws UnsupportedOperationException { if (rollup instanceof BasicRollup) return ((BasicRollup) rollup).getMaxValue(); else if (rollup instanceof BluefloodTimerRollup) return ((BluefloodTimerRollup) rollup).getMaxValue(); else // counters, sets. throw new UnsupportedOperationException( String.format("min not supported for this type: %s", rollup.getClass().getSimpleName())); }
@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())); }
@Override Object convertRollupToObject(Rollup rollup) throws UnsupportedOperationException { if (rollup instanceof BluefloodTimerRollup) return ((BluefloodTimerRollup) rollup).getPercentiles(); else // every other type. throw new UnsupportedOperationException( String.format("percentiles 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())); }
@Override Object convertRollupToObject(Rollup rollup) throws UnsupportedOperationException { if (rollup instanceof BasicRollup) return ((BasicRollup) rollup).getVariance(); else if (rollup instanceof BluefloodTimerRollup) return ((BluefloodTimerRollup) rollup).getVariance(); else // counters, sets. throw new UnsupportedOperationException( String.format("variance not supported for this type: %s", rollup.getClass().getSimpleName())); }
@Override Object convertRollupToObject(Rollup rollup) throws UnsupportedOperationException { if (rollup instanceof BasicRollup) return ((BasicRollup) rollup).getMinValue(); else if (rollup instanceof BluefloodTimerRollup) return ((BluefloodTimerRollup) rollup).getMinValue(); else // counters, sets. throw new UnsupportedOperationException( String.format("min not supported for this type: %s", rollup.getClass().getSimpleName())); }
@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())); }
} else if (point.getData() instanceof BluefloodTimerRollup) { BluefloodTimerRollup rollup = (BluefloodTimerRollup)point.getData(); numPoints += rollup.getCount(); filterStatsObject = getFilteredStatsForRollup(rollup, filterStats); } else if (point.getData() instanceof BluefloodCounterRollup) {
public static Collection<PreaggregatedMetric> convertTimers(String tenant, long timestamp, Collection<BluefloodTimer> timers) { List<PreaggregatedMetric> list = new ArrayList<PreaggregatedMetric>(timers.size()); for (BluefloodTimer timer : timers) { Locator locator = Locator.createLocatorFromPathComponents(tenant, timer.getName().split(NAME_DELIMITER, -1)); BluefloodTimerRollup rollup = new BluefloodTimerRollup() .withCount(timer.getCount().longValue()) .withSampleCount(1) .withAverage(resolveNumber(timer.getAvg() == null ? 0.0d : timer.getAvg())) .withMaxValue(resolveNumber(timer.getMax() == null ? 0.0d : timer.getMax())) .withMinValue(resolveNumber(timer.getMin() == null ? 0.0d : timer.getMin())) .withCountPS(timer.getRate() == null ? 0.0d : timer.getRate().doubleValue()) .withSum(timer.getSum() == null ? 0L : timer.getSum().doubleValue()) .withVariance(Math.pow(timer.getStd() == null ? 0.0d : timer.getStd().doubleValue(), 2d)); for (Map.Entry<String, Percentile> entry : timer.getPercentiles().entrySet()) { // throw away max and sum. if (entry.getValue().getAvg() != null) { rollup.setPercentile(entry.getKey(), resolveNumber(entry.getValue().getAvg())); } } PreaggregatedMetric metric = new PreaggregatedMetric(timestamp, locator, DEFAULT_TTL, rollup); list.add(metric); } return list; }