Examples of MeasurementAggregate


Examples of org.rhq.core.domain.measurement.MeasurementAggregate

        report.addData(new MeasurementDataNumeric(buckets.get(59) + 30, request, 6.6));

        dataManager.mergeMeasurementReport(report);
        waitForRawInserts();

        MeasurementAggregate actual = dataManager.getMeasurementAggregate(getOverlord(), dynamicSchedule.getId(),
            beginTime.getMillis(), endTime.getMillis());

        MeasurementAggregate expected = new MeasurementAggregate(1.1, divide((1.1 + 2.2 + 3.3 + 4.4 + 5.5 + 6.6), 6),
            6.6);

        AssertUtils.assertPropertiesMatch("Aggregate does not match", expected, actual, 0.0001D);
    }
View Full Code Here

Examples of org.rhq.core.domain.measurement.MeasurementAggregate

            String condition = "         AND d.schedule_id = ? \n";

            ps = getFullQuery("getAggregateByScheduleId", connection, beginTime, endTime, 1, condition, scheduleId);
            rs = ps.executeQuery();
            if (rs.next()) {
                MeasurementAggregate measurementAggregate = fillAggregateFromResultSet(rs);
                return measurementAggregate;
            }

            throw new MeasurementNotFoundException("Data not found");
        } catch (SQLException e) {
View Full Code Here

Examples of org.rhq.core.domain.measurement.MeasurementAggregate

            connection = datasource.getConnection();
            ps = getFullQuery("getAggregateByContext", connection, beginTime, endTime, 1, conditions, bindParams);
            rs = ps.executeQuery();
            if (rs.next()) {
                MeasurementAggregate measurementAggregate = fillAggregateFromResultSet(rs);
                return measurementAggregate;
            }

            throw new MeasurementNotFoundException("Data not found");
        } catch (SQLException e) {
View Full Code Here

Examples of org.rhq.core.domain.measurement.MeasurementAggregate

    private MeasurementAggregate fillAggregateFromResultSet(ResultSet rs) throws SQLException {
        Double avg = getDoubleOrNanFromResultSet(rs, 2);
        Double max = getDoubleOrNanFromResultSet(rs, 3);
        Double min = getDoubleOrNanFromResultSet(rs, 4);

        MeasurementAggregate measurementAggregate = new MeasurementAggregate(min, avg, max);
        return measurementAggregate;
    }
View Full Code Here

Examples of org.rhq.core.domain.measurement.MeasurementAggregate

                Integer scheduleId = (Integer) tupple[2];
                scheduleIdsMap.put(definitionName, scheduleId);
            }

            StorageNodeLoadComposite result = new StorageNodeLoadComposite(node, beginTime, endTime);
            MeasurementAggregate totalDiskUsedAggregate = new MeasurementAggregate(0d, 0d, 0d);
            Integer scheduleId = null;

            // find the aggregates and enrich the result instance
            if (!scheduleIdsMap.isEmpty()) {
                try {
                    if ((scheduleId = scheduleIdsMap.get(METRIC_TOKENS)) != null) {
                        MeasurementAggregate tokensAggregate = measurementManager.getMeasurementAggregate(subject,
                            scheduleId, beginTime, endTime);
                        result.setTokens(tokensAggregate);
                    }
                    if ((scheduleId = scheduleIdsMap.get(METRIC_OWNERSHIP)) != null) {
                        StorageNodeLoadComposite.MeasurementAggregateWithUnits ownershipAggregateWithUnits = getMeasurementAggregateWithUnits(
                            subject, scheduleId, MeasurementUnits.PERCENTAGE, beginTime, endTime);
                        result.setActuallyOwns(ownershipAggregateWithUnits);
                    }

                    //calculated disk space related metrics
                    if ((scheduleId = scheduleIdsMap.get(METRIC_DATA_DISK_USED_PERCENTAGE)) != null) {
                        StorageNodeLoadComposite.MeasurementAggregateWithUnits dataDiskUsedPercentageAggregateWithUnits = getMeasurementAggregateWithUnits(
                            subject, scheduleId, MeasurementUnits.PERCENTAGE, beginTime, endTime);
                        result.setDataDiskUsedPercentage(dataDiskUsedPercentageAggregateWithUnits);
                    }
                    if ((scheduleId = scheduleIdsMap.get(METRIC_TOTAL_DISK_USED_PERCENTAGE)) != null) {
                        StorageNodeLoadComposite.MeasurementAggregateWithUnits totalDiskUsedPercentageAggregateWithUnits = getMeasurementAggregateWithUnits(
                            subject, scheduleId, MeasurementUnits.PERCENTAGE, beginTime, endTime);
                        result.setTotalDiskUsedPercentage(totalDiskUsedPercentageAggregateWithUnits);
                    }
                    if ((scheduleId = scheduleIdsMap.get(METRIC_FREE_DISK_TO_DATA_RATIO)) != null) {
                        MeasurementAggregate freeDiskToDataRatioAggregate = measurementManager.getMeasurementAggregate(
                            subject, scheduleId, beginTime, endTime);
                        result.setFreeDiskToDataSizeRatio(freeDiskToDataRatioAggregate);
                    }

                    if ((scheduleId = scheduleIdsMap.get(METRIC_LOAD)) != null) {
View Full Code Here

Examples of org.rhq.core.domain.measurement.MeasurementAggregate

                Integer scheduleId = (Integer) tupple[2];
                scheduleIdsMap.put(definitionName, scheduleId);
            }

            List<ListenableFuture<StorageNodeLoadComposite>> compositeFutures = new ArrayList<ListenableFuture<StorageNodeLoadComposite>>();
            final MeasurementAggregate totalDiskUsedAggregate = new MeasurementAggregate(0d, 0d, 0d);
            Integer scheduleId = null;

            // find the aggregates and enrich the result instance
            if (scheduleIdsMap.isEmpty()) {
                // no sheduled metrics yet
                return Futures.successfulAsList(Lists.newArrayList(Futures.immediateFuture(result)));
            }

            if ((scheduleId = scheduleIdsMap.get(METRIC_FREE_DISK_TO_DATA_RATIO)) != null) {
                ListenableFuture<AggregateNumericMetric> dataFuture = metricsServer.getSummaryAggregateAsync(
                    scheduleId, beginTime, endTime);
                ListenableFuture<StorageNodeLoadComposite> compositeFuture = Futures.transform(dataFuture,
                    new Function<AggregateNumericMetric, StorageNodeLoadComposite>() {
                        @Override
                        public StorageNodeLoadComposite apply(AggregateNumericMetric metric) {
                            result.setFreeDiskToDataSizeRatio(new MeasurementAggregate(metric.getMin(),
                                metric.getAvg(), metric.getMax()));
                            return result;
                        }
                    });
                compositeFutures.add(wrapFuture(compositeFuture, result, "Failed to retrieve metric ["
View Full Code Here

Examples of org.rhq.core.domain.measurement.MeasurementAggregate

    private StorageNodeLoadComposite.MeasurementAggregateWithUnits getMeasurementAggregateWithUnits(Subject subject,
        int schedId, MeasurementUnits units, long beginTime, long endTime) {
        MetricsServer metricsServer = storageClientManager.getMetricsServer();
        AggregateNumericMetric metric = metricsServer.getSummaryAggregate(schedId, beginTime, endTime);
        MeasurementAggregate measurementAggregate = new MeasurementAggregate(metric.getMin(), metric.getAvg(),
            metric.getMax());
        StorageNodeLoadComposite.MeasurementAggregateWithUnits measurementAggregateWithUnits = new StorageNodeLoadComposite.MeasurementAggregateWithUnits(
            measurementAggregate, units);
        measurementAggregateWithUnits.setFormattedValue(getSummaryString(measurementAggregate, units));
        return measurementAggregateWithUnits;
View Full Code Here

Examples of org.rhq.core.domain.measurement.MeasurementAggregate

            beginTime, endTime);
        return Futures.transform(dataFuture,
            new Function<AggregateNumericMetric, StorageNodeLoadComposite.MeasurementAggregateWithUnits>() {
                @Override
                public StorageNodeLoadComposite.MeasurementAggregateWithUnits apply(AggregateNumericMetric metric) {
                    MeasurementAggregate measurementAggregate = new MeasurementAggregate(metric.getMin(), metric
                        .getAvg(), metric.getMax());
                    StorageNodeLoadComposite.MeasurementAggregateWithUnits measurementAggregateWithUnits = new StorageNodeLoadComposite.MeasurementAggregateWithUnits(
                        measurementAggregate, units);
                    return measurementAggregateWithUnits;
                }
View Full Code Here

Examples of org.rhq.core.domain.measurement.MeasurementAggregate

            }

            summary.setCollectionType(collectionType);

            if (!narrowed) {
                MeasurementAggregate compositeHighLow = dataManager.getMeasurementAggregate(subject, schedule.getId(),
                    begin, end);
                if (compositeHighLow.isEmpty()) {
                    summary.setValuesPresent(false);
                }

                Map<String, MetricDisplayValue> metricValues = new HashMap<String, MetricDisplayValue>();
                metricValues.put(MetricDisplayConstants.MIN_KEY, new MetricDisplayValue(compositeHighLow.getMin()));
                metricValues.put(MetricDisplayConstants.AVERAGE_KEY, new MetricDisplayValue(compositeHighLow.getAvg()));
                metricValues.put(MetricDisplayConstants.MAX_KEY, new MetricDisplayValue(compositeHighLow.getMax()));
                MeasurementDataNumeric currentNumeric = dataManager.getCurrentNumericForSchedule(schedule.getId());
                Double lastValue = (currentNumeric != null) ? currentNumeric.getValue() : Double.NaN;
                metricValues.put(MetricDisplayConstants.LAST_KEY, new MetricDisplayValue(lastValue));
                summary.setMetrics(metricValues);
            }
View Full Code Here

Examples of org.rhq.core.domain.measurement.MeasurementAggregate

            /*
             * Get the aggregate data from the backend and check if it is empty or not. If it is empty (for all members
             * of the group), skip over this metric.
             */
            MeasurementAggregate aggregate;
            if (totalScheduleCount == 0) {
                aggregate = new MeasurementAggregate(null, null, null);
                log.warn("No metric schedules found for def=[" + definition + "] and " + context
                    + ", using empty aggregate");
            } else {
                if (context.type == EntityContext.Type.ResourceGroup
                    && definition.getDataType() == DataType.MEASUREMENT) {
                    aggregate = dataManager.getAggregate(subject, context.getGroupId(), definitionId, begin, end);
                } else {
                    aggregate = dataUtil.getAggregateByDefinitionAndContext(begin, end, definitionId, context);
                }
            }
            if (aggregate.isEmpty()) {
                if (log.isTraceEnabled()) {
                    log.warn("No metric data found for def=[" + definition + "] and " + context + " in the timeframe ["
                        + new Date(begin) + ", " + new Date(end) + "]");
                }

                summary.setValuesPresent(false);
            }

            Map<String, MetricDisplayValue> metricValues = new HashMap<String, MetricDisplayValue>();
            metricValues.put(MetricDisplayConstants.MIN_KEY, new MetricDisplayValue(aggregate.getMin()));
            metricValues.put(MetricDisplayConstants.AVERAGE_KEY, new MetricDisplayValue(aggregate.getAvg()));
            metricValues.put(MetricDisplayConstants.MAX_KEY, new MetricDisplayValue(aggregate.getMax()));

            // TODO put the sum back on - JBNADM-2626
            //metricValues.put(MetricDisplayConstants.SUMMARY_KEY, new MetricDisplayValue(aggregate.getSum()));
            summary.setMetrics(metricValues);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.