Package com.rackspacecloud.blueflood.types

Examples of com.rackspacecloud.blueflood.types.Range


    }
   
    @Test
    public void testRangeIteratorFullAnd5m() throws Exception {
        Set<Range> expectedRanges = new HashSet<Range>();
        expectedRanges.add(new Range(0, 299999));
        expectedRanges.add(new Range(300000, 599999));
        expectedRanges.add(new Range(600000, 899999));
        expectedRanges.add(new Range(900000, 1199999));
       
        // FULL and 5m have the same rollup semantics.
        for (Granularity g : new Granularity[] { Granularity.FULL, Granularity.MIN_5}) {
            Set<Range> actualRanges = new HashSet<Range>();
            for (Range time : Range.getRangesToRollup(g, 200000, 1000000)) {
View Full Code Here


    public void testRangeMapper60m() throws Exception {
        int baseMillis = 6500000;
        int hrs = 10;
        int endMillis = baseMillis + 3600000 * hrs;
        //Map of every 60m(coarser gran) in this time range, mapped to iterable of 20m sub-ranges that get rolled up
        Map<Range, Iterable<Range>> retMap = Range.mapFinerRanges(Granularity.MIN_60, new Range(baseMillis, endMillis));
        Assert.assertEquals(retMap.entrySet().size(), 11);
        for(Map.Entry<Range,Iterable<Range>> entry : retMap.entrySet()) {
            Range coarserSubRange = entry.getKey();
            int iterValCount = 0;
            Iterable<Range> subranges = entry.getValue();
            for (Range subrange : subranges) {
                if(iterValCount == 0) {
                    //Start point of coarser range is equal to start point of 1st 20m sub-range
                    Assert.assertEquals(coarserSubRange.getStart(), subrange.getStart());
                }
                iterValCount++;
                if(iterValCount == 3) {
                    Assert.assertEquals(coarserSubRange.getStop() - 1, subrange.getStop());
                }
            }
            //Every 60m range gets divided into 3 20m sub-ranges
            Assert.assertEquals(iterValCount, 3);
        }
View Full Code Here

    private static Set<Range> makeRanges(Granularity g, long startMillis, int count) {
        Set<Range> set = new HashSet<Range>();
        long millis = startMillis;
        for (int i = 0; i < count; i++) {
            long end = millis + g.milliseconds();
            set.add(new Range(millis, end - 1));
            millis = end;
        }
        return set;
    }
View Full Code Here

    public void testRangeDerivation() {
        for (Granularity gran : Granularity.granularities()) {
            long now = 1334582854000L;
            int nowSlot = gran.slot(now);
            now = gran.snapMillis(now);
            Range nowRange = new Range(now, now + gran.milliseconds() - 1);
            Assert.assertEquals(nowRange, gran.deriveRange(nowSlot, now));
           
            Range prevRange = gran.deriveRange(nowSlot - 1, now);
            Assert.assertEquals(gran.milliseconds(), nowRange.start - prevRange.start);
           
            // incrementing nowSlot forces us to test slot wrapping.
            Range wayBeforeRange = gran.deriveRange(nowSlot + 1, now);
            Assert.assertEquals(gran.numSlots() - 1, (nowRange.start - wayBeforeRange.start) / gran.milliseconds());
        }
    }
View Full Code Here

public class RangeTest {

    @Test
    public void testGetStartAndStop() {
        Range myRange = new Range(1, 2);

        Assert.assertEquals(1, myRange.getStart());
        Assert.assertEquals(2, myRange.getStop());
    }
View Full Code Here

        Assert.assertEquals(2, myRange.getStop());
    }

    @Test
    public void testEquals() {
        Range myRange = new Range(1, 2);
        Range myRange2 = new Range(1, 2);
        Range myRange3 = new Range(2, 3);
        Average avg = new Average(1, 2.0);

        Assert.assertFalse(myRange.equals(avg));
        Assert.assertFalse(myRange.equals(myRange3));
        Assert.assertTrue(myRange.equals(myRange2));
View Full Code Here

        Assert.assertTrue(myRange.equals(myRange2));
    }

    @Test
    public void testToString() {
        Range myRange = new Range(1, 3);

        Assert.assertEquals("1:3 (2)", myRange.toString());
    }
View Full Code Here

        // slot. This implies that the range we wish to return is before slot(reference).  allow for slot wrapping.
        referenceMillis = snapMillis(referenceMillis);
        int refSlot = slot(referenceMillis);
        int slotDiff = slot > refSlot ? (numSlots() - slot + refSlot) : (refSlot - slot);
        long rangeStart = referenceMillis - slotDiff * milliseconds();
        return new Range(rangeStart, rangeStart + milliseconds() - 1);
    }
View Full Code Here

       
        log.debug("Saw {} new files since {}", pages.size() == batchSize ? "many" : Integer.toString(pages.size()), lastMarker);
        boolean emptiness = getBlobsWithinRange(pages).isEmpty();

        if(emptiness) {
            log.warn("No file found within range {}", new Range(START_TIME, STOP_TIME));
        } else {
            log.debug("New files found within range {}", new Range(START_TIME, STOP_TIME));
        }

        return !emptiness;
    }
View Full Code Here

    private RollupsQueryParams(long from, long to, Set<BasicRollupsOutputSerializer.MetricStat> stats) {
        if (from >= to) {
            throw new IllegalArgumentException("'from' timestamp has to be strictly less than 'to'.");
        }
        this.stats = stats;
        this.range = new Range(from, to);
        this.points = 0;
        this.resolution = Resolution.FULL;
    }
View Full Code Here

TOP

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

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.