public static Points<Rollup> generateFakeRollupPoints() { Points<Rollup> points = Points.create(Granularity.MIN_5); long baseTime = 1234567L; for (int count = 0; count < 5; count++) { final Rollup rollup = new Rollup(); rollup.setCount(count * 100); rollup.getAverage().setLongValue(count); Points.Point<Rollup> point = new Points.Point<Rollup>(baseTime + (count * 1000), rollup); points.add(point); } return points; }
@Override Object convertRollupToObject(Rollup rollup) throws Exception { if (rollup instanceof TimerRollup) return ((TimerRollup) rollup).getPercentiles(); else // every other type. throw new Exception( String.format( "percentiles supported for this type: %s", rollup.getClass().getSimpleName())); }
@Override Object convertRollupToObject(Rollup rollup) throws Exception { if (rollup instanceof BasicRollup) return ((BasicRollup) rollup).getMaxValue(); else if (rollup instanceof TimerRollup) return ((TimerRollup) rollup).getMaxValue(); else // counters, sets. throw new Exception( String.format( "min not supported for this type: %s", rollup.getClass().getSimpleName())); }
@Override Object convertRollupToObject(Rollup rollup) throws Exception { if (rollup instanceof TimerRollup) return ((TimerRollup) rollup).getRate(); else if (rollup instanceof CounterRollup) return ((CounterRollup) rollup).getRate(); else // gauge, set, basic throw new Exception( String.format( "rate not supported for this type: %s", rollup.getClass().getSimpleName())); }
@Override Object convertRollupToObject(Rollup rollup) throws Exception { if (rollup instanceof GaugeRollup) return ((GaugeRollup) rollup).getLatestValue().getValue(); else // every other type. throw new Exception( String.format( "latest value not supported for this type: %s", rollup.getClass().getSimpleName())); }
@Override Object convertRollupToObject(Rollup rollup) throws Exception { if (rollup instanceof BasicRollup) return ((BasicRollup) rollup).getCount(); else if (rollup instanceof TimerRollup) return ((TimerRollup) rollup).getCount(); else if (rollup instanceof CounterRollup) return ((CounterRollup) rollup).getCount(); else if (rollup instanceof SetRollup) return ((SetRollup) rollup).getCount(); else // gauge. throw new Exception( String.format( "numPoints not supported for this type: %s", rollup.getClass().getSimpleName())); }