Package com.rackspacecloud.blueflood.types

Examples of com.rackspacecloud.blueflood.types.GaugeRollup


    public GaugeRollup deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
        Integer count = 0;
        Long timestamp = null;
        Number latest = null;

        GaugeRollup g = new GaugeRollup();

        String fieldName = "";
        while (!jp.getCurrentToken().equals(JsonToken.END_OBJECT)) {
            if (jp.getCurrentToken().equals(JsonToken.FIELD_NAME)) {
                fieldName = jp.getText();
            }
            jp.nextToken();

            if (fieldName.equals("type")) {
                if (!jp.getText().equals("gauge")) {
                    throw new IOException("Gauge rollup must have type of 'gauge'.");
                }
            } else if (fieldName.equals("mean")) {
                g.setAverage(jp.getNumberValue());
            } else if (fieldName.equals("var")) {
                g.setVariance(jp.getNumberValue());
            } else if (fieldName.equals("min")) {
                g.setMin(jp.getNumberValue());
            } else if (fieldName.equals("max")) {
                g.setMax(jp.getNumberValue());
            } else if (fieldName.equals("count")) {
                count = jp.getIntValue();
            } else if (fieldName.equals("timestamp")) {
                timestamp = jp.getLongValue();
            } else if (fieldName.equals("latestNumericValue")) {
                latest = jp.getNumberValue();
            }

            jp.nextToken();
        }
        if (timestamp == null || latest == null || count == null) {
            if (timestamp == null)
                throw new IOException("timestamp cannot be null.");
            else if (latest == null)
                throw new IOException("latestNumericValue cannot be null.");
            else if (count == null)
                throw new IOException("count cannot be null.");
        }
        g.withLatest(timestamp, latest);
        g.setCount(count); // must come after 'withLatest' since that increments count.

        return g;
    }
View Full Code Here


            case Type.B_GAUGE:
                // just like rollup up until a point.
                sz += sizeOf(o, Type.B_ROLLUP);
               
                // here's where it gets different.
                GaugeRollup gauge = (GaugeRollup)o;
                sz += CodedOutputStream.computeRawVarint64Size(gauge.getTimestamp());
                sz += 1; // type of latest value.
                if (gauge.getLatestNumericValue() instanceof Long || gauge.getLatestNumericValue() instanceof Integer)
                    sz += CodedOutputStream.computeRawVarint64Size(gauge.getLatestNumericValue().longValue());
                else if (gauge.getLatestNumericValue() instanceof Double || gauge.getLatestNumericValue() instanceof Float)
                    sz += CodedOutputStream.computeDoubleSizeNoTag(gauge.getLatestNumericValue().doubleValue());
                return sz;
               
            case Type.B_COUNTER:
                CounterRollup counter = (CounterRollup)o;
                sz += 1; // version + rollup type.
View Full Code Here

    public static Points<GaugeRollup> generateFakeGaugeRollups() {
        Points<GaugeRollup> points = new Points<GaugeRollup>();
        long startTime = 1234567L;
        for (int i = 0; i < 5; i++) {
            long timeNow = startTime + i*1000;
            Points.Point<GaugeRollup> point = new Points.Point<GaugeRollup>(timeNow, new GaugeRollup()
                .withLatest(timeNow, i));
            points.add(point);
        }
        return points;
    }
View Full Code Here

       
       
        // todo: adding getCount() to Rollup interface will simplify this block.
        // because of inheritance, GaugeRollup needs to come before BasicRollup. sorry.
        if (point.getData() instanceof GaugeRollup) {
            GaugeRollup rollup = (GaugeRollup)point.getData();
            numPoints += rollup.getCount();
            filterStatsObject = getFilteredStatsForRollup(rollup, filterStats);
        } else if (point.getData() instanceof BasicRollup) {
            numPoints = ((BasicRollup) point.getData()).getCount();
            filterStatsObject = getFilteredStatsForRollup((BasicRollup) point.getData(), filterStats);
        } else if (point.getData() instanceof SimpleNumber) {
            numPoints = 1;
            filterStatsObject = getFilteredStatsForFullRes(point.getData(), filterStats);
        } else if (point.getData() instanceof String) {
            numPoints = 1;
            filterStatsObject = getFilteredStatsForString((String) point.getData());
        } else if (point.getData() instanceof Boolean) {
            numPoints = 1;
            filterStatsObject = getFilteredStatsForBoolean((Boolean) point.getData());
        } else if (point.getData() instanceof SetRollup) {
            SetRollup rollup = (SetRollup)point.getData();
            numPoints += rollup.getCount();
            filterStatsObject = getFilteredStatsForRollup(rollup, filterStats);
        } else if (point.getData() instanceof TimerRollup) {
            TimerRollup rollup = (TimerRollup)point.getData();
            numPoints += rollup.getCount();
            filterStatsObject = getFilteredStatsForRollup(rollup, filterStats);
        } else if (point.getData() instanceof CounterRollup) {
            CounterRollup rollup = (CounterRollup)point.getData();
            numPoints += rollup.getCount().longValue();
            filterStatsObject = getFilteredStatsForRollup(rollup, filterStats);
        } else {
            throw new SerializationException("Unsupported data type for Point");
        }
View Full Code Here

TOP

Related Classes of com.rackspacecloud.blueflood.types.GaugeRollup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.