Package com.rackspacecloud.blueflood.types

Examples of com.rackspacecloud.blueflood.types.Locator


        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


        // meh
    }

    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");
View Full Code Here

        final String tenantId = "ac" + randString(8);
        List<Metric> metrics = new ArrayList<Metric>();
        final long now = System.currentTimeMillis();

        for (int i = 0; i < count; i++) {
            final Locator locator = Locator.createLocatorFromPathComponents(tenantId, "met" + randString(8));
            metrics.add(getRandomIntMetric(locator, now - 10000000));
        }

        return metrics;
    }
View Full Code Here

    @Test
    // Testing an edge case when there are no metrics available for a locator
    // 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");
View Full Code Here

    @Test
    // Testing an edge case when there are no metrics available for a locator
    // 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");
View Full Code Here

    // tenantId can be null!
    public static Collection<Metric> remarshal(Collection<BasicMetric> basicMetrics, String tenantId) {
        List<Metric> metrics = new ArrayList<Metric>(basicMetrics.size());
        for (BasicMetric bm : basicMetrics) {
            String appliedTenantId = tenantId == null ? bm.getTenant() : tenantId;
            Locator locator = Locator.createLocatorFromPathComponents(appliedTenantId, splitForLocator(bm.getMetricName()));
            Metric m = new Metric(locator, bm.getMetricValue(), bm.getCollectionTime(), new TimeValue(bm.getTtlInSeconds(), TimeUnit.SECONDS), bm.getUnit());
            metrics.add(m);
        }
        return metrics;
    }
View Full Code Here

    // tenantId can be null!
    private static Collection<PreaggregatedMetric> remarshalCounters(Bundle bundle, String tenantId) {
        final Collection<Counter> counters = bundle.getCounters();
        final List<PreaggregatedMetric> metrics = new ArrayList<PreaggregatedMetric>(counters.size());
        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())
View Full Code Here

    // tenantId can be null!
    private static Collection<PreaggregatedMetric> remarshalGauges(Bundle bundle, String tenantId) throws IOException {
        final Collection<Gauge> gauges = bundle.getGauges();
        final List<PreaggregatedMetric> metrics = new ArrayList<PreaggregatedMetric>(gauges.size());
        for (Gauge g : gauges) {
            Locator locator = Locator.createLocatorFromPathComponents(tenantId == null ? g.getTenant() : tenantId, splitForLocator(g.getName()));
            Points<SimpleNumber> points = new Points<SimpleNumber>();
            points.add(new Points.Point<SimpleNumber>(bundle.getCollectionTime(), new SimpleNumber(g.getValue())));
            Rollup rollup = GaugeRollup.buildFromRawSamples(points);
            PreaggregatedMetric metric = new PreaggregatedMetric(bundle.getCollectionTime(), locator, DEFAULT_PREAG_TTL, rollup);
            metrics.add(metric);
View Full Code Here

    // tenantId can be null!
    private static Collection<PreaggregatedMetric> remarshalSets(Bundle bundle, String tenantId) {
        final Collection<Set> sets = bundle.getSets();
        final List<PreaggregatedMetric> metrics = new ArrayList<PreaggregatedMetric>(sets.size());
        for (Set s : sets) {
            Locator locator = Locator.createLocatorFromPathComponents(tenantId == null ? s.getTenant() : tenantId, splitForLocator(s.getName()));
            SetRollup rollup = new SetRollup();
            for (String value : s.getValues()) {
                rollup = rollup.withObject(value);
            }
            PreaggregatedMetric metric = new PreaggregatedMetric(bundle.getCollectionTime(), locator, DEFAULT_PREAG_TTL, rollup);
View Full Code Here

    // tenantId can be null!
    private static Collection<PreaggregatedMetric> remarshalTimers(Bundle bundle, String tenantId) {
        final Collection<Timer> timers = bundle.getTimers();
        final List<PreaggregatedMetric> metrics = new ArrayList<PreaggregatedMetric>(timers.size());
        for (Timer t : timers) {
            Locator locator = Locator.createLocatorFromPathComponents(tenantId == null ? t.getTenant() : tenantId, splitForLocator(t.getName()));
            TimerRollup rollup = new TimerRollup()
                    .withCount(t.getCount().longValue())
                    .withSampleCount(1)
                    .withAverage(t.getAvg())
                    .withMaxValue(t.getMax())
View Full Code Here

TOP

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

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.