Package org.rhq.enterprise.server.measurement.util

Examples of org.rhq.enterprise.server.measurement.util.MeasurementDataManagerUtility


                    + "] does not have permission to view metric display summaries for autoGroup[parentResourceId="
                    + context.parentResourceId + ", resourceTypeId=" + context.resourceTypeId + "]");
            }
        }

        MeasurementDataManagerUtility dataUtil = MeasurementDataManagerUtility.getInstance(rhqDs);

        // Loop over the definitions, find matching schedules and create a MetricDisplaySummary for each definition
        for (int definitionId : measurementDefinitionIds) {

            MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
            if (context.type == EntityContext.Type.Resource) {
                criteria.addFilterResourceId(context.resourceId);
            } else if (context.type == EntityContext.Type.ResourceGroup) {
                criteria.addFilterResourceGroupId(context.groupId);
            } else if (context.type == EntityContext.Type.AutoGroup) {
                criteria.addFilterAutoGroupParentResourceId(context.parentResourceId);
                criteria.addFilterAutoGroupResourceTypeId(context.resourceTypeId);
            }
            criteria.addFilterDefinitionIds(definitionId);
            criteria.clearPaging();//disable paging as the code assumes all the results will be returned.

            PageList<MeasurementSchedule> theSchedules = scheduleManager.findSchedulesByCriteria(subject, criteria);
            int totalScheduleCount = theSchedules.getTotalSize();

            criteria.addFilterEnabled(true);
            criteria.setPageControl(PageControl.getSingleRowInstance()); // get single row only, we want totalSize
            theSchedules = scheduleManager.findSchedulesByCriteria(subject, criteria);
            int collecting = theSchedules.getTotalSize();

            /*
             * If no metric is collecting, stop here as we have nothing to contribute
             */
            if ((collecting == 0) && enabledOnly) {
                if (log.isTraceEnabled()) {
                    log.trace("There were no schedules enabled for definition id " + definitionId);
                }

                continue;
            }

            MetricDisplaySummary summary = new MetricDisplaySummary();

            // See MetricsDisplay.jsp for wrt the next two lines.
            summary.setNumberCollecting(collecting);
            summary.setShowNumberCollecting(true);

            summary.setDefinitionId(definitionId);
            summary.setBeginTimeFrame(begin);
            summary.setAlertCount(getAlertCountForContext(definitionId, context, begin, end));
            summary.setEndTimeFrame(end);

            MeasurementDefinition definition = entityManager.find(MeasurementDefinition.class, definitionId);
            summary.setDefinitionId(definition.getId());
            summary.setUnits(definition.getUnits().getName());
            summary.setDescription(definition.getDescription());
            summary.setMetricName(definition.getName());
            summary.setLabel(definition.getDisplayName());
            summary.setDescription(definition.getDescription());
            summary.setMetricSource(definition.getResourceType().getName());

            /*
             * 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 ["
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.measurement.util.MeasurementDataManagerUtility

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.