Examples of MeasurementReport


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

    public MeasurementSenderRunner(MeasurementManager measurementManager) {
        this.measurementManager = measurementManager;
    }

    public MeasurementReport call() throws Exception {
        MeasurementReport report = this.measurementManager.swapReport();
        if (report == null) {
            LOG.error("Measurement report is null - nothing to do.");
            return null;
        }

        filterUnchangedTraits(report);
        cleanseInvalidNumericValues(report);
        this.measurementManager.perMinuteItizeData(report);

        if (report.getDataCount() > 0) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Measurement collection for [" + report.getDataCount() + "] metrics took "
                        + report.getCollectionTime() + "ms - sending report to Server...");
            }
            this.measurementManager.sendMeasurementReport(report);
        } else {
            LOG.debug("Measurement report contains no data - not sending to Server.");
        }
View Full Code Here

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

        } catch (Exception e) {
            LOG.warn("Cannot get measurement facet for Resource [" + resourceId + "]. Cause: " + e);
            return Collections.emptySet();
        }

        MeasurementReport report = new MeasurementReport();
        for (MeasurementScheduleRequest request : requests) {
            request.setEnabled(true);
        }

        try {
            measurementFacet.getValues(report, Collections.unmodifiableSet(requests));
        } catch (Throwable t) {
            LOG.error("Could not get measurement values", t);
            return Collections.emptySet();
        }

        Iterator<MeasurementDataNumeric> iterator = report.getNumericData().iterator();
        while (iterator.hasNext()) {
            MeasurementDataNumeric numeric = iterator.next();
            if (numeric.isPerMinuteCollection()) {
                CachedValue currentValue = perMinuteCache.get(numeric.getScheduleId());
                if (currentValue == null) {
                    iterator.remove();
                } else {
                    numeric.setValue(calculatePerMinuteValue(numeric, currentValue));
                }
            }
        }

        Set<MeasurementData> values = new HashSet<MeasurementData>();
        values.addAll(report.getNumericData());
        values.addAll(report.getTraitData());
        return values;
    }
View Full Code Here

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

    }

    public MeasurementReport swapReport() {
        try {
            this.measurementLock.writeLock().lock();
            MeasurementReport previousReport = this.activeReport;

            this.activeReport = new MeasurementReport();

            return previousReport;
        } finally {
            this.measurementLock.writeLock().unlock();
        }
View Full Code Here

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

    public MeasurementCollectorRunner(MeasurementManager measurementManager) {
        this.measurementManager = measurementManager;
    }

    public MeasurementReport call() {
        MeasurementReport report = null;
        try {
            this.measurementManager.getLock().readLock().lock();

            report = this.measurementManager.getActiveReport();
            long start = System.currentTimeMillis();

            InventoryManager im = this.measurementManager.getInventoryManager();

            Set<ScheduledMeasurementInfo> requests = this.measurementManager.getNextScheduledSet();

            if (requests != null) {
                ScheduledMeasurementInfo next = requests.iterator().next();

                if ((System.currentTimeMillis() - 30000L) > next.getNextCollection()) {
                    this.measurementManager.incrementLateCollections(requests.size());
                    if (log.isDebugEnabled()) {
                        log.debug("Measurement collection is falling behind... Missed requested time by ["
                            + (System.currentTimeMillis() - requests.iterator().next().getNextCollection()) + "ms]");

                        if (!scheduleHistory.isEmpty()) {
                            log.debug("The most recent measurement requests prior to this detected delay: "
                                + scheduleHistory);
                        }
                    }

                    // BZ 834019 - reschedule these requests for the future, and away from the set of requests on this schedule
                    this.measurementManager.rescheduleLateCollections(requests);
                    return report;
                }

                Integer resourceId = next.getResourceId();
                ResourceContainer container = im.getResourceContainer(resourceId);
                if (container.getResourceComponentState() != ResourceContainer.ResourceComponentState.STARTED
                    || container.getAvailability() == null
                    || container.getAvailability().getAvailabilityType() == AvailabilityType.DOWN) {
                    // Don't collect metrics for resources that are down
                    if (log.isDebugEnabled()) {
                        log.debug("Measurements not collected for inactive resource component: "
                            + container.getResource());
                    }
                } else {
                    MeasurementFacet measurementComponent = ComponentUtil
                        .getComponent(resourceId, MeasurementFacet.class, FacetLockType.READ,
                            MeasurementManager.FACET_METHOD_TIMEOUT, true, true, true);

                    if (log.isDebugEnabled()) {
                        scheduleHistory.addRequests(requests);
                    }

                    getValues(measurementComponent, report, requests, container.getResource());
                }

                this.measurementManager.reschedule(requests);

                report.incrementCollectionTime(System.currentTimeMillis() - start);
            }
        } catch (Throwable t) {
            log.error("Failed to run measurement collection", t);
        } finally {
            this.measurementManager.getLock().readLock().unlock();
View Full Code Here

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

        if (resourceComponent instanceof MeasurementFacet) {
            for (MeasurementDefinition def : resource.getResourceType().getMetricDefinitions()) {
                Set<MeasurementScheduleRequest> metricList = new HashSet<MeasurementScheduleRequest>();
                metricList.add(new MeasurementScheduleRequest(1, def.getName(), 1000, true, def.getDataType(), null));
                MeasurementReport report = new MeasurementReport();
                ((MeasurementFacet) resourceComponent).getValues(report, metricList);

                MeasurementData data = report.getTraitData().iterator().next();
                assert data != null : "Unable to collect trait [" + def.getName() + "] on " + resource;
                log.info("Measurement: " + def.getName() + "=" + data.getValue());
            }
        }
    }
View Full Code Here

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

            resource);
        if (resourceComponent instanceof MeasurementFacet) {
            for (MeasurementDefinition def : resource.getResourceType().getMetricDefinitions()) {
                Set<MeasurementScheduleRequest> metricList = new HashSet<MeasurementScheduleRequest>();
                metricList.add(new MeasurementScheduleRequest(1, def.getName(), 1000, true, def.getDataType()));
                MeasurementReport report = new MeasurementReport();
                ((MeasurementFacet) resourceComponent).getValues(report, metricList);

                assert report.getNumericData().size() > 0 : "Measurement " + def.getName() + " not collected from "
                    + resource;
                MeasurementData data = report.getNumericData().iterator().next();
                assert data != null : "Unable to collect metric [" + def.getName() + "] on " + resource;
                System.out.println("Measurement: " + def.getName() + "=" + data.getValue());
            }
        }
    }
View Full Code Here

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

                ResourceComponent serviceComponent = PluginContainer.getInstance().getInventoryManager()
                    .getResourceComponent(service);
                if (serviceComponent instanceof MeasurementFacet) {
                    Set<MeasurementScheduleRequest> metricList = new HashSet<MeasurementScheduleRequest>();
                    metricList.add(new MeasurementScheduleRequest(1, "numbackends", 1000, true, DataType.MEASUREMENT));
                    MeasurementReport report = new MeasurementReport();
                    ((MeasurementFacet) serviceComponent).getValues(report, metricList);
                    for (MeasurementData value : report.getNumericData()) {
                        System.out.println(value.getValue() + ":" + service.getName());
                    }
                }
            }
        }
View Full Code Here

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

        Configuration configuration = getConfiguration(rt);
        return manuallyAdd(rt, configuration, component);
    }

    private void checkAllMetrics(String resourceType, ResourceComponent component) throws Exception {
        MeasurementReport report = getMeasurementReport(component);
        assertAll(report, getResourceDescriptor(resourceType));
    }
View Full Code Here

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

        if (resourceComponent instanceof MeasurementFacet) {
            for (MeasurementDefinition def : resource.getResourceType().getMetricDefinitions()) {
                Set<MeasurementScheduleRequest> metricList = new HashSet<MeasurementScheduleRequest>();
                metricList.add(new MeasurementScheduleRequest(1, def.getName(), 1000, true, def.getDataType(), null));
                MeasurementReport report = new MeasurementReport();
                ((MeasurementFacet) resourceComponent).getValues(report, metricList);

                if (def.getDataType().equals(DataType.TRAIT)) {
                    Assert.assertTrue(report.getTraitData().iterator().hasNext(),
                        "Unable to collect trait [" + def.getName()
                        + "] on " + resource);
                    MeasurementData data = report.getTraitData().iterator().next();
                    Assert.assertNotNull(data, "Unable to collect trait [" + def.getName() + "] on " + resource);
                    log.info("Measurement: " + def.getName() + "=" + data.getValue());
                } else if (def.getDataType().equals(DataType.MEASUREMENT)) {
                    Assert.assertTrue(report.getNumericData().iterator().hasNext(),
                        "Unable to collect measurement [" + def.getName() + "] on " + resource);
                    MeasurementData data = report.getNumericData().iterator().next();
                    Assert.assertNotNull(data, "Unable to collect measurement [" + def.getName() + "] on " + resource);
                    log.info("Measurement: " + def.getName() + "=" + data.getValue());
                }
            }
        }
View Full Code Here

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

     * Returns a measurement report.
     */
    public MeasurementReport getMeasurementReport(ResourceComponent component) throws Exception {
        Resource resource = this.components.get(component);
        ResourceType type = resource.getResourceType();
        MeasurementReport report = new MeasurementReport();
        Set<MeasurementScheduleRequest> s = new HashSet<MeasurementScheduleRequest>();
        for (MeasurementDefinition md : type.getMetricDefinitions())
            s.add(new MeasurementScheduleRequest(new MeasurementSchedule(md, resource)));
        ((MeasurementFacet)component).getValues(report, s);
        return report;
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.