Package com.rackspacecloud.blueflood.types

Examples of com.rackspacecloud.blueflood.types.Metric


        if (metricValue == null || collectionTime == null || ttlInSeconds == null || unit == null || tenantId == null || metricName == null) {
            throw new IOException("A required field was not found."); // TODO: specificity
        }

        Locator locator = Locator.createLocatorFromPathComponents(tenantId, metricName);
        Metric m = new Metric(locator, metricValue, collectionTime, new TimeValue(ttlInSeconds, TimeUnit.SECONDS), unit);
        return m;
    }
View Full Code Here


    }

    protected Metric writeMetric(String name, Object value) throws Exception {
        final List<Metric> metrics = new ArrayList<Metric>();
        final Locator locator = Locator.createLocatorFromPathComponents("acctId", name);
        Metric metric = new Metric(locator, value, System.currentTimeMillis(),
                new TimeValue(1, TimeUnit.DAYS), "unknown");
        metrics.add(metric);
        AstyanaxWriter.getInstance().insertFull(metrics);
        Cache<String, Boolean> insertedLocators = (Cache<String, Boolean>) Whitebox.getInternalState(AstyanaxWriter.getInstance(), "insertedLocators");
        insertedLocators.invalidateAll();
View Full Code Here

    protected String getRandomStringMetricValue() {
        return "str" + String.valueOf(getRandomIntMetricValue());
    }

    protected Metric getRandomIntMetric(final Locator locator, long timestamp) {
        return new Metric(locator, getRandomIntMetricValue(), timestamp, new TimeValue(1, TimeUnit.DAYS), "unknown");
    }
View Full Code Here

    protected Metric getRandomIntMetric(final Locator locator, long timestamp) {
        return new Metric(locator, getRandomIntMetricValue(), timestamp, new TimeValue(1, TimeUnit.DAYS), "unknown");
    }

    protected Metric getRandomStringmetric(final Locator locator, long timestamp) {
        return new Metric(locator, getRandomStringMetricValue(), timestamp, new TimeValue(1, TimeUnit.DAYS), "unknown");
    }
View Full Code Here

    // in the database
    public void testShouldPersistForFirstInsertOfLocator() throws Exception {
        final Locator dummyLocator = Locator.createLocatorFromPathComponents("acctId", "entityId", "checkId", "dim", "metric");
        final long collectionTimeInSecs = 45678;
        final int testMetric = 789;
        final Metric newMetric = new Metric(dummyLocator, testMetric, collectionTimeInSecs,
                new TimeValue(2, TimeUnit.DAYS), "unknown");

        boolean shouldPersist = metricsOptimizer.shouldPersist(newMetric);

        // shouldPersist should return true as cassandra doesn't have any
View Full Code Here

    @Test
    public void testShouldPersistHappyCase() throws Exception {
        int testMetric = 123;
        long collectionTimeInSecs = 56789;
        Metric newMetric = new Metric(locator, testMetric, collectionTimeInSecs,
                new TimeValue(2, TimeUnit.DAYS), "unknown");

        boolean shouldPersist = metricsOptimizer.shouldPersist(newMetric);

        // shouldPersist should be true as for non-string metrics we don't
        // care
        Assert.assertEquals(true, shouldPersist);

        testMetric = 789;
        collectionTimeInSecs++;
        final Metric newerMetric = new Metric(locator, testMetric, collectionTimeInSecs,
                new TimeValue(2, TimeUnit.DAYS), "unknown");

        shouldPersist = metricsOptimizer.shouldPersist(newerMetric);

        // shouldPersist should now be true as we do not have the same metric
View Full Code Here

    // in the database
    public void testShouldPersistForFirstInsertOfLocator() throws Exception {
        final Locator dummyLocator = Locator.createLocatorFromDbKey("acct.ent.check.dim.metric");
        final long collectionTimeInSecs = 45678;
        final String testMetric = "HTTP GET failed";
        final Metric newMetric = new Metric(dummyLocator, testMetric, collectionTimeInSecs,
                new TimeValue(2, TimeUnit.DAYS), "unknown");

        boolean shouldPersist = metricsOptimizer.shouldPersist(newMetric);

        // shouldPersist should return true as cassandra doesn't have any
View Full Code Here

    @Test
    public void testShouldPersistHappyCase() throws Exception {
        String testMetric = "HTTP GET failed";
        long collectionTimeInSecs = 56789;
        Metric newMetric = new Metric(locator, testMetric, collectionTimeInSecs,
                new TimeValue(2, TimeUnit.DAYS), "unknown");

        boolean shouldPersist = metricsOptimizer.shouldPersist(newMetric);

        // shouldPersist should be false as we have the same metric as the one
        // in the database
        Assert.assertEquals(false, shouldPersist);

        testMetric = "HTTP GET succeeded";
        collectionTimeInSecs++;
        newMetric = new Metric(locator, testMetric, collectionTimeInSecs,
                new TimeValue(2, TimeUnit.DAYS), "unknown");

        shouldPersist = metricsOptimizer.shouldPersist(newMetric);

        // shouldPersist should now be true as we do not have the same metric
View Full Code Here

    @Test
    public void testShouldPersistForBooleanMetrics() throws Exception {
        boolean testMetric = false;
        long collectionTimeInSecs = 56789;
        Metric newMetric = new Metric(otherLocator, testMetric, collectionTimeInSecs,
                new TimeValue(2, TimeUnit.DAYS), "unknown");

        Assert.assertTrue(newMetric.isBoolean());

        boolean shouldPersist = metricsOptimizer.shouldPersist(newMetric);

        // shouldPersist should be false as we have the same metric as the one
        // in the database
        Assert.assertEquals(false, shouldPersist);

        testMetric = true;
        collectionTimeInSecs++;
        newMetric = new Metric(otherLocator, testMetric, collectionTimeInSecs,
                new TimeValue(2, TimeUnit.DAYS), "unknown");

        shouldPersist = metricsOptimizer.shouldPersist(newMetric);

        // shouldPersist should now be true as we do not have the same metric
View Full Code Here

            try {
                String existingType = cache.get(m.getLocator(), DATA_TYPE_CACHE_KEY);
                String existingUnit = cache.get(m.getLocator(), UNIT_CACHE_KEY);
               
                if (m instanceof Metric) {
                    Metric mm = (Metric)m;
                    cache.put(m.getLocator(), DATA_TYPE_CACHE_KEY, mm.getDataType().toString());
                   
                    if (mm.getUnit() != null) {
                        cache.put(m.getLocator(), UNIT_CACHE_KEY, mm.getUnit());
                    }
                   
                    // log mismatches.
                    if (existingType != null && !existingType.equals(mm.getDataType().toString())) {
                        log.warn("Types changed for {}. From {} to {}", new Object[] {m.getLocator().toString(), existingType, mm.getDataType().toString()});
                    }
                    if (existingUnit != null && !existingUnit.equals(mm.getUnit())) {
                        log.warn("Units changed for {}. From {} to {}", new Object[] {m.getLocator().toString(), existingUnit, mm.getUnit()});
                    }
                }
           
                cache.put(m.getLocator(), ROLLUP_TYPE_CACHE_KEY, m.getRollupType().toString());
            } catch (Throwable th) {
View Full Code Here

TOP

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

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.