Package org.rhq.server.metrics.domain

Examples of org.rhq.server.metrics.domain.IndexEntry


    @Override
    public IndexEntry next() {
        Row row = rowIterator.next();
        lastScheduleId = row.getInt(0);
        IndexEntry indexEntry = new IndexEntry(bucket, partition, time.getMillis(), lastScheduleId);
        if (!rowIterator.hasNext()) {
            loadPage();
        }
        return indexEntry;
    }
View Full Code Here


        Stopwatch stopwatch = Stopwatch.createStarted();
        try {
            IndexIterator iterator = new IndexIterator(start, end, bucket, dao, configuration);
            Batch batch = new Batch();
            while (iterator.hasNext()) {
                IndexEntry indexEntry = iterator.next();
                if (batch.getStartTime() == null) {
                    batch.setStartTime(indexEntry.getTimestamp());
                    batch.setEndTime(new DateTime(indexEntry.getTimestamp()).plus(timeSliceDuration));
                }
                if (batch.getStartTime().getMillis() == indexEntry.getTimestamp()) {
                    batch.add(indexEntry);
                    if (batch.size() == batchSize) {
                        submitAggregationTask(batch);
                        batch = new Batch();
                    }
                } else {
                    submitAggregationTask(batch);
                    batch = new Batch()
                        .setStartTime(indexEntry.getTimestamp())
                        .setEndTime(new DateTime(indexEntry.getTimestamp()).plus(timeSliceDuration))
                        .add(indexEntry);
                }
            }
            if (batch.size() > 0) {
                submitAggregationTask(batch);
View Full Code Here

        assertEquals(actual, expected, "The index entries do not match");
    }

    private IndexEntry newIndexEntry(IndexBucket bucket, DateTime time, int scheduleId) {
        return new IndexEntry(bucket, (scheduleId % numPartitions), time, scheduleId);
    }
View Full Code Here

    private void assertIndexEquals(IndexBucket bucket, DateTime startTime, DateTime endTime,
        List<Integer> scheduleIds) {
        List<IndexEntry> expected = new ArrayList<IndexEntry>();
        for (Integer scheduleId : scheduleIds) {
            expected.add(new IndexEntry(bucket, (scheduleId % configuration.getIndexPartitions()), startTime,
                scheduleId));
        }

        List<IndexEntry> actual = new ArrayList<IndexEntry>();
        IndexIterator iterator = new IndexIterator(startTime, endTime, bucket, dao, configuration);
View Full Code Here

    @Test(enabled = ENABLED)
    public void insertAndFindIndexEntries() {
        dao = new MetricsDAO(storageSession, new MetricsConfiguration().setIndexPageSize(2).setIndexPartitions(1));

        IndexEntry entry1 = new IndexEntry(IndexBucket.RAW, 0, hour(2).getMillis(), 100);
        IndexEntry entry2 = new IndexEntry(IndexBucket.RAW, 0, hour(2).getMillis(), 101);
        IndexEntry entry5 = new IndexEntry(IndexBucket.RAW, 0, hour(2).getMillis(), 103);
        IndexEntry entry6 = new IndexEntry(IndexBucket.RAW, 0, hour(2).getMillis(), 104);

        dao.updateIndex(IndexBucket.RAW, hour(2).getMillis(), 100).get();
        dao.updateIndex(IndexBucket.RAW, hour(2).getMillis(), 101).get();
        dao.updateIndex(IndexBucket.RAW, hour(2).getMillis(), 102).get();
        dao.updateIndex(IndexBucket.RAW, hour(3).getMillis(), 101).get();
        dao.updateIndex(IndexBucket.RAW, hour(2).getMillis(), 103).get();
        dao.updateIndex(IndexBucket.RAW, hour(2).getMillis(), 104).get();
        dao.updateIndex(IndexBucket.RAW, hour(2).getMillis(), 105).get();

        List<IndexEntry> expected = asList(entry1, entry2);
        List<IndexEntry> actual = new ArrayList<IndexEntry>();

        ResultSet resultSet = dao.findIndexEntries(IndexBucket.RAW, 0, hour(2).getMillis()).get();
        for (Row row : resultSet) {
            actual.add(new IndexEntry(IndexBucket.RAW, 0, hour(2).getMillis(), row.getInt(0)));
        }
        assertEquals(actual, expected, "The first page of index entries is wrong");
        actual.clear();

        resultSet = dao.findIndexEntries(IndexBucket.RAW, 0, hour(2).getMillis(), 102).get();
        expected = asList(entry5, entry6);
        for (Row row : resultSet) {
            actual.add(new IndexEntry(IndexBucket.RAW, 0, hour(2).getMillis(), row.getInt(0)));
        }
        assertEquals(actual, expected, "The next page of index entries is wrong");

    }
View Full Code Here

TOP

Related Classes of org.rhq.server.metrics.domain.IndexEntry

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.