Package com.rackspacecloud.blueflood.utils

Examples of com.rackspacecloud.blueflood.utils.TimeValue


        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


                return System.currentTimeMillis();
            }
        });
       
        final AtomicInteger counter = new AtomicInteger(0);
        final ShardStateWorker worker = new ShardStateWorker(allShards, manager, new TimeValue(100, TimeUnit.MILLISECONDS), null) {
            @Override
            void performOperation() {
                counter.incrementAndGet();
            }
        };
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

    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
        // metrics for this locator yet
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
        // as the one in the database
View Full Code Here

    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
        // metrics for this locator yet
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
        // as the one in the database
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
        // as the one in the database
View Full Code Here

TOP

Related Classes of com.rackspacecloud.blueflood.utils.TimeValue

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.