Examples of MeasurementReport


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

    }

    @Nullable
    protected Double collectNumericMetric(Resource resource, String metricName) throws Exception {
        System.out.println("=== Collecting numeric metric [" + metricName + "] for " + resource + "...");
        MeasurementReport report = collectMetric(resource, metricName);

        Double value;
        if (report.getNumericData().isEmpty()) {
            assertEquals(
                report.getTraitData().size(),
                0,
                "Metric [" + metricName + "] for Resource type " + resource.getResourceType()
                    + " is defined as a numeric metric, but the plugin returned one or more traits!: "
                    + report.getTraitData());
            assertEquals(report.getCallTimeData().size(), 0,
                "Metric [" + metricName + "] for Resource type " + resource.getResourceType()
                    + " is defined as a numeric metric, but the plugin returned one or more call-time metrics!: "
                    + report.getCallTimeData());
            value = null;
        } else {
            assertEquals(report.getNumericData().size(), 1,
                "Requested a single metric, but plugin returned more than one datum: " + report.getNumericData());
            MeasurementDataNumeric datum = report.getNumericData().iterator().next();
            assertEquals(datum.getName(), metricName, "Numeric metric [" + metricName + "] for Resource type "
                + resource.getResourceType() + " was requested, but the plugin returned a numeric metric with name ["
                + datum.getName() + "] and value [" + datum.getValue() + "]!");
            // Normalize NaN or infinite to null, as the PC does.
            value = (datum.getValue().isNaN() || datum.getValue().isInfinite()) ? null : datum.getValue();
View Full Code Here

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

            ensureSerializable(obj);
        }
    }

    public void testMeasurementReport() {
        MeasurementReport report = new MeasurementReport();
        report.setCollectionTime(1111);

        CallTimeData callTimeData = new CallTimeData(new MeasurementScheduleRequest(1, "1", 1, true, DataType.CALLTIME));
        callTimeData.addCallData("dest1", new Date(1111), 1);
        callTimeData.addCallData("dest1", new Date(1112), 2);

        report.addData(callTimeData);

        report.addData(new MeasurementDataNumeric(2, new MeasurementScheduleRequest(2, "2", 2, true,
            DataType.MEASUREMENT), new Double(2.2)));

        report.addData(new MeasurementDataTrait(3, new MeasurementScheduleRequest(3, "3", 3, true, DataType.TRAIT),
            "trait3"));

        MeasurementReport copy = ensureSerializable(report);
        assert copy.getDataCount() == 3 : "-->" + copy.getDataCount();
        assert copy.getCallTimeData().size() == 1 : "-->" + copy.getCallTimeData();
        assert copy.getNumericData().size() == 1 : "-->" + copy.getNumericData();
        assert copy.getTraitData().size() == 1 : "-->" + copy.getTraitData();
    }
View Full Code Here

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

        Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
        MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();

        // simulate a measurement report coming from the agent - two values, but neither fit in our range, so no alerts are fired
        MeasurementScheduleRequest request = new MeasurementScheduleRequest(schedule);
        MeasurementReport report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(60), request, 20.0)); // 20 < 60 but !(20 > 40)
        report.addData(new MeasurementDataNumeric(getTimestamp(30), request, 70.0)); // !(70 < 60) but 70 > 40
        MeasurementDataManagerLocal dataManager = LookupUtil.getMeasurementDataManager();
        dataManager.mergeMeasurementReport(report);

        // wait for our JMS messages to process and see if we get any alerts
        Thread.sleep(5000);

        // make sure no alert was triggered
        PageList<Alert> alerts = getAlerts(resourceWithSchedules.getId());
        assert alerts.size() == 0 : "no alerts should have fired: " + alerts;

        // simulate another measurement report coming from the agent - one values that fits in our range, so 1 alert is fired
        request = new MeasurementScheduleRequest(schedule);
        report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(15), request, 50.0)); // 50 < 60 AND 50 > 40
        dataManager.mergeMeasurementReport(report);

        // wait for our JMS messages to process and see if we get any alerts
        Thread.sleep(5000);
View Full Code Here

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

        Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
        MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();

        // simulate a measurement report coming from the agent - one value that is inside our range, so no alerts are fired
        MeasurementScheduleRequest request = new MeasurementScheduleRequest(schedule);
        MeasurementReport report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(60), request, 50.0)); // 50 is inside the range 40...60
        MeasurementDataManagerLocal dataManager = LookupUtil.getMeasurementDataManager();
        dataManager.mergeMeasurementReport(report);

        // wait for our JMS messages to process and see if we get any alerts
        Thread.sleep(5000);

        // make sure no alert was triggered
        PageList<Alert> alerts = getAlerts(resourceWithSchedules.getId());
        assert alerts.size() == 0 : "no alerts should have fired: " + alerts;

        // simulate another measurement report coming from the agent - one value that is outside the range, so 1 alert is fired
        request = new MeasurementScheduleRequest(schedule);
        report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(15), request, 20.0)); // 20 is outside 40...60
        dataManager.mergeMeasurementReport(report);

        // wait for our JMS messages to process and see if we get any alerts
        Thread.sleep(5000);
View Full Code Here

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

        MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();

        // simulate a measurement report coming from the agent
        // with a single metric that makes a condition trigger but does not fire an alert
        MeasurementScheduleRequest request = new MeasurementScheduleRequest(schedule);
        MeasurementReport report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(60), request, 20.0)); // 20 < 60 but !(20 > 40)
        MeasurementDataManagerLocal dataManager = LookupUtil.getMeasurementDataManager();
        dataManager.mergeMeasurementReport(report);

        // wait for our JMS messages to process and see if we get any alerts
        Thread.sleep(5000);
View Full Code Here

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

        Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
        MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();

        // simulate a measurement report coming from the agent - one values that fits in our range, so 1 alert is fired
        MeasurementScheduleRequest request = new MeasurementScheduleRequest(schedule);
        MeasurementReport report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(15), request, 50.0)); // 50 < 60 AND 50 > 40
        MeasurementDataManagerLocal dataManager = LookupUtil.getMeasurementDataManager();
        dataManager.mergeMeasurementReport(report);

        // wait for our JMS messages to process and see if we get any alerts
        Thread.sleep(5000);
View Full Code Here

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

        final Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
        MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();

        // simulate a measurement report coming from the agent - one values that changes value, so 1 alert is fired
        MeasurementScheduleRequest request = new MeasurementScheduleRequest(schedule);
        MeasurementReport report = new MeasurementReport();
        report.addData(new MeasurementDataTrait(getTimestamp(15), request, "Foo"));
        MeasurementDataManagerLocal dataManager = LookupUtil.getMeasurementDataManager();
        dataManager.mergeMeasurementReport(report);

        final Alert[] alertHolder = new Alert[1];
View Full Code Here

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

        //we want to test that the agent cache reload doesn't confuse the counting

        //first, send 2 matches
        MeasurementDataManagerLocal measurementDataManager = LookupUtil.getMeasurementDataManager();
        MeasurementScheduleRequest request = new MeasurementScheduleRequest(schedule);
        MeasurementReport report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(25), request, 0d));
        measurementDataManager.mergeMeasurementReport(report);

        Thread.sleep(3000);

        request = new MeasurementScheduleRequest(schedule);
        report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(20), request, 0d));
        measurementDataManager.mergeMeasurementReport(report);

        Thread.sleep(3000);

        //now reload the caches
        reloadAllAlertConditionCaches();

        //ok, so before BZ 1025491, after the cache reload, a non-match wouldn't cancel the counting.
        //so we need to test that if we send a non-match followed by a match we DON'T get an alert.

        //send a non-match, followed by a match
        request = new MeasurementScheduleRequest(schedule);
        report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(15), request, 1d));
        measurementDataManager.mergeMeasurementReport(report);

        Thread.sleep(3000);

        request = new MeasurementScheduleRequest(schedule);
        report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(10), request, 0d));
        measurementDataManager.mergeMeasurementReport(report);

        Thread.sleep(3000);

        //now, we should get NO alert
        List<Alert> alerts = getAlerts(resourceWithSchedules.getId());
        assert alerts.size() == 0 : "No alert should have fired: " + alerts;

        //let's send in 2 more matches - we should be getting an alert
        request = new MeasurementScheduleRequest(schedule);
        report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(5), request, 0d));
        measurementDataManager.mergeMeasurementReport(report);

        Thread.sleep(3000);

        //throw in a cache reload to check that it doesn't mess up the counting of the positives in sequence
        reloadAllAlertConditionCaches();

        request = new MeasurementScheduleRequest(schedule);
        report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(0), request, 0d));
        measurementDataManager.mergeMeasurementReport(report);

        //wait
        Thread.sleep(5000);
View Full Code Here

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

        String metricName = request.getName();

        if (CALCULATED_METRIC_HEAP_USAGE_PERCENTAGE.equals(request.getName())) {
            result = true;

            MeasurementReport calculationPropsReport = new MeasurementReport();
            Set<MeasurementScheduleRequest> calculationPropsSchedules = new HashSet(2);

            MeasurementScheduleRequest heapUsedRequest = new MeasurementScheduleRequest(0, "{HeapMemoryUsage.used}",
                0L, true, DataType.MEASUREMENT);
            MeasurementScheduleRequest heapComittedRequest = new MeasurementScheduleRequest(0,
                "{HeapMemoryUsage.committed}", 0L, true, DataType.MEASUREMENT);
            calculationPropsSchedules.add(heapUsedRequest);
            calculationPropsSchedules.add(heapComittedRequest);

            getBeanProperties(calculationPropsReport, bean, calculationPropsSchedules);
            Set<MeasurementDataNumeric> values = calculationPropsReport.getNumericData();
            Double heapUsed = Double.NaN;
            Double heapCommitted = Double.NaN;
            if (null != values && values.size() == 2) {
                for (MeasurementDataNumeric v : values) {
                    if (v.getName().equals("{HeapMemoryUsage.used}")) {
View Full Code Here

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

    private SampleComponent sampleComponent;

    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        report = new MeasurementReport();
        requests = new HashSet<MeasurementScheduleRequest>();
        address = new Address("path");
        sampleComponent = new SampleComponent();
    }
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.