Package com.rackspacecloud.blueflood.types

Examples of com.rackspacecloud.blueflood.types.CounterRollup


                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.
                sz += 1; // numeric type.
                if (counter.getCount() instanceof Long || counter.getCount() instanceof Integer)
                    sz += CodedOutputStream.computeRawVarint64Size(counter.getCount().longValue());
                else if (counter.getCount() instanceof Double || counter.getCount() instanceof Float)
                    sz += CodedOutputStream.computeDoubleSizeNoTag(counter.getCount().doubleValue());
                sz += CodedOutputStream.computeDoubleSizeNoTag(counter.getRate());
                sz += CodedOutputStream.computeRawVarint32Size(counter.getSampleCount());
                return sz;
            default:
                throw new IOException("Unexpected type: " + type);
        }
        return sz;
View Full Code Here


   
    private static CounterRollup deserializeV1CounterRollup(CodedInputStream in) throws IOException {
        Number value = getUnversionedDoubleOrLong(in);
        double rate = in.readDouble();
        int sampleCount = in.readRawVarint32();
        return new CounterRollup().withCount(value.longValue()).withRate(rate).withSampleCount(sampleCount);
    }
View Full Code Here

        for (Counter c : counters) {
            Locator locator = Locator.createLocatorFromPathComponents(tenantId == null ? c.getTenant() : tenantId, splitForLocator(c.getName()));
            long sampleCount = bundle.getFlushInterval() > 0
                    ? (long)(c.getRate().doubleValue() * ((double)bundle.getFlushInterval()/1000d))
                    : 1;
            Rollup rollup = new CounterRollup()
                    .withCount(c.getValue())
                    .withRate(c.getRate().doubleValue())
                    .withCount(sampleCount);
            PreaggregatedMetric metric = new PreaggregatedMetric(bundle.getCollectionTime(), locator, DEFAULT_PREAG_TTL, rollup);
            metrics.add(metric);
View Full Code Here

public class CounterRollupSerializationTest {

    @Test
    public void testCounterV1RoundTrip() throws IOException {
        CounterRollup c0 = new CounterRollup().withCount(7442245).withSampleCount(1);
        CounterRollup c1 = new CounterRollup().withCount(34454722343L).withSampleCount(10);
       
        if (System.getProperty("GENERATE_COUNTER_SERIALIZATION") != null) {
            OutputStream os = new FileOutputStream("src/test/resources/serializations/counter_version_" + Constants.VERSION_1_COUNTER_ROLLUP + ".bin", false);
            os.write(Base64.encodeBase64(new NumericSerializer.CounterRollupSerializer().toByteBuffer(c0).array()));
            os.write("\n".getBytes());
            os.write(Base64.encodeBase64(new NumericSerializer.CounterRollupSerializer().toByteBuffer(c1).array()));
            os.write("\n".getBytes());
            os.close();
        }
       
        Assert.assertTrue(new File("src/test/resources/serializations").exists());
               
        int count = 0;
        int version = 0;
        final int maxVersion = Constants.VERSION_1_COUNTER_ROLLUP;
        while (version <= maxVersion) {
            BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/serializations/counter_version_" + version + ".bin"));
           
            ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
            CounterRollup cc0 = NumericSerializer.serializerFor(CounterRollup.class).fromByteBuffer(bb);
            Assert.assertEquals(c0, cc0);
           
            bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
            CounterRollup cc1 = NumericSerializer.serializerFor(CounterRollup.class).fromByteBuffer(bb);
            Assert.assertEquals(c1, cc1);
           
            Assert.assertFalse(cc0.equals(cc1));
            version++;
            count++;
View Full Code Here

            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 CounterRollup()
                    .withCount(resolveNumber(counter.getValue()))
                    .withRate(counter.getRate().doubleValue())
                    .withCount(sampleCount);
            PreaggregatedMetric metric = new PreaggregatedMetric(timestamp, locator, DEFAULT_TTL, rollup);
            list.add(metric);
View Full Code Here

    public static Points<CounterRollup> generateFakeCounterRollupPoints() {
        Points<CounterRollup> points = new Points<CounterRollup>();
        long startTime = 1234567L;
        for (int i = 0; i < 5; i++) {
            long timeNow = startTime + i*1000;
            Points.Point<CounterRollup> point = new Points.Point<CounterRollup>(timeNow, new CounterRollup()
                    .withCount(i + 1000)
                    .withRate((double) i)
                    .withSampleCount(1));
            points.add(point);
        }
View Full Code Here

        } 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.CounterRollup

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.