Examples of MeasurementBaseline


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

            }
        });
    }

    private MeasurementBaseline baseline(MeasurementSchedule schedule, double avg, double min, double max) {
        MeasurementBaseline baseline = new MeasurementBaseline();
        baseline.setSchedule(schedule);
        baseline.setMean(avg);
        baseline.setMax(max);
        baseline.setMin(min);

        return baseline;
    }
View Full Code Here

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

    @Test(enabled = ENABLED)
    public void testRenameServer() throws Exception {

        Resource testResource = null;
        MeasurementSchedule sched = null;
        MeasurementBaseline baseline = null;
        EventDefinition eDef = null;

        // Note, plugins are registered in new transactions. for tests, this means
        // you can't do everything in a trans and roll back at the end. You must clean up
        // manually.  Still, some work can be performed transactionally, as done below.
        try {
            registerPlugin("update6-1.xml");
            ResourceType server = getResourceType("testServer1");

            getTransactionManager().begin();

            getPluginId();

            Set<MeasurementDefinition> definitions1 = server.getMetricDefinitions();
            // for metric counts, add one for the built in AvailabilityType metric
            assert definitions1.size() == 2;

            /*
             * Create a Fake Resource and a MeasurementSchedule
             */
            testResource = new Resource("-test-", "-test resource-", server);
            testResource.setUuid("" + new Random().nextInt());
            em.persist(testResource);

            sched = new MeasurementSchedule(definitions1.iterator().next(), testResource);
            em.persist(sched);

            em.flush();

            baseline = new MeasurementBaseline();
            baseline.setSchedule(sched);
            baseline.setUserEntered(true);
            em.persist(baseline);

            eDef = new EventDefinition(server, "-test event definition-");
            em.persist(eDef);

View Full Code Here

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

            // pass now for olderThanTime to ensure all existing baselines are deleted
            // pass 30000 for amountOfData to only include the youngest in the baseline calculation
            long computeTime = baselineManager.calculateAutoBaselines(3000, System.currentTimeMillis());
            assert computeTime > 0;

            MeasurementBaseline bl1;
            MeasurementBaseline bl2;
            int bl1Id;
            int bl2Id;
            Date bl1ComputeTime;
            Date bl2ComputeTime;

            begin();

            bl1 = em.find(MeasurementSchedule.class, measSched.getId()).getBaseline();
            assert bl1 != null : "Baseline for measSched should have been inserted";
            assert bl1.getSchedule().getId() == measSched.getId();
            assert !bl1.isUserEntered();
            assertEquals(30.0, bl1.getMin());
            assertEquals(50.0, bl1.getMax());
            assertEquals(40.0, bl1.getMean());

            bl2 = em.find(MeasurementSchedule.class, measSched2.getId()).getBaseline();
            assert bl2 != null : "Baseline for measSched2 should have been inserted";
            assert bl2.getSchedule().getId() == measSched2.getId();
            assert !bl2.isUserEntered();
            assertEquals(500.0, bl2.getMin());
            assertEquals(2500.0, bl2.getMax());
            assertEquals(1500.0, bl2.getMean());

            // remember these, the next time we calculate, they will be deleted and new ones created
            bl1Id = bl1.getId();
            bl2Id = bl2.getId();
            bl1ComputeTime = bl1.getComputeTime();
            bl2ComputeTime = bl2.getComputeTime();

            commit();

            // calculate them again, the values will be the same, but the delete query will be triggered
            // wait a bit so our compute time will be assured to be different
            Thread.sleep(1000L);
            computeTime = baselineManager.calculateAutoBaselines(30000, System.currentTimeMillis());
            assert computeTime > 0;

            begin();

            bl1 = em.find(MeasurementSchedule.class, measSched.getId()).getBaseline();
            assert bl1 != null : "Baseline for measSched should have been inserted";
            assert bl1.getSchedule().getId() == measSched.getId();
            assert !bl1.isUserEntered();
            assertEquals(30.0, bl1.getMin());
            assertEquals(50.0, bl1.getMax());
            assertEquals(40.0, bl1.getMean());

            bl2 = em.find(MeasurementSchedule.class, measSched2.getId()).getBaseline();
            assert bl2 != null : "Baseline for measSched2 should have been inserted";
            assert bl2.getSchedule().getId() == measSched2.getId();
            assert !bl2.isUserEntered();
            assertEquals(500.0, bl2.getMin());
            assertEquals(2500.0, bl2.getMax());
            assertEquals(1500.0, bl2.getMean());

            // check the new IDs with the old ones - they should be different due to the delete query
            assert bl1.getId() != bl1Id : "bl1.getId() was " + bl1.getId() + ", bl1Id was " + bl1Id;
            assert bl2.getId() != bl2Id : "bl2.getId() was " + bl2.getId() + ", bl2Id was " + bl2Id;
            assert bl1.getComputeTime().after(bl1ComputeTime);
            assert bl2.getComputeTime().after(bl2ComputeTime);

            commit();

            // calculate them again using wider ranges to include more (all available) 1H data in the calculation
            Thread.sleep(1000L);
            computeTime = baselineManager.calculateAutoBaselines(240000, System.currentTimeMillis());
            assert computeTime > 0;

            begin();

            bl1 = em.find(MeasurementSchedule.class, measSched.getId()).getBaseline();
            assert bl1 != null : "Baseline for measSched should have been inserted";
            assert bl1.getSchedule().getId() == measSched.getId();
            assert !bl1.isUserEntered();
            assertEquals(2.0, bl1.getMin());
            assertEquals(50.00, bl1.getMax());
            assertEquals(20.25, bl1.getMean());

            bl2 = em.find(MeasurementSchedule.class, measSched2.getId()).getBaseline();
            assert bl2 != null : "Baseline for measSched2 should have been inserted";
            assert bl2.getSchedule().getId() == measSched2.getId();
            assert !bl2.isUserEntered();
            assertEquals(500.0, bl2.getMin());
            assertEquals(7000.0, bl2.getMax());
            assertEquals(3375.0, bl2.getMean());

            // check the new IDs with the old ones - they should be different due to the delete query
            assert bl1.getId() != bl1Id;
            assert bl2.getId() != bl2Id;
            assert bl1.getComputeTime().after(bl1ComputeTime);
            assert bl2.getComputeTime().after(bl2ComputeTime);

            commit();
        } catch (Throwable t) {
            System.out.println("TEST FAILURE STACK TRACE FOLLOWS:");
            t.printStackTrace();
View Full Code Here

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

            if (null == scheduleWithBaseline || null == scheduleWithBaseline.getBaseline()) {
                throw new IllegalStateException(
                    "A baseline has not yet been generated for this metric. It must exist before a manual override can be set.  An initial baseline is typically generated within a few hours after metric data begins for the metric.");
            }

            MeasurementBaseline measurementBaseline = scheduleWithBaseline.getBaseline();
            if (maxBaseline < measurementBaseline.getMin()) {
                throw new IllegalArgumentException("Invalid baselineMax value, must not be less than baselineMin.");
            }

            MeasurementBaseline newMeasurementBaseline = scheduleWithBaseline.getBaseline();
            newMeasurementBaseline.setSchedule(scheduleWithBaseline);
            newMeasurementBaseline.setUserEntered(true);
            newMeasurementBaseline.setMax(maxBaseline);
            scheduleManager.updateSchedule(getSessionSubject(), scheduleWithBaseline);

        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
View Full Code Here

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

            if (null == scheduleWithBaseline || null == scheduleWithBaseline.getBaseline()) {
                throw new IllegalStateException(
                    "A baseline has not yet been generated for this metric. It must exist before a manual override can be set.  An initial baseline is typically generated within a few hours after metric data begins for the metric.");
            }

            MeasurementBaseline measurementBaseline = scheduleWithBaseline.getBaseline();
            if (minBaseline > measurementBaseline.getMax()) {
                throw new IllegalArgumentException("Invalid baseline value, must not be greater than baselineMax.");
            }

            MeasurementBaseline newMeasurementBaseline = scheduleWithBaseline.getBaseline();
            newMeasurementBaseline.setSchedule(scheduleWithBaseline);
            newMeasurementBaseline.setUserEntered(true);
            newMeasurementBaseline.setMin(minBaseline);
            scheduleManager.updateSchedule(getSessionSubject(), scheduleWithBaseline);

        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
View Full Code Here

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

            if (null == scheduleWithBaseline || null == scheduleWithBaseline.getBaseline()) {
                throw new IllegalStateException(
                    "A baseline has not yet been generated for this metric. It must exist before a manual override can be set.  An initial baseline is typically generated within a few hours after metric data begins for the metric.");
            }

            MeasurementBaseline measurementBaseline = scheduleWithBaseline.getBaseline();
            if (meanBaseline < measurementBaseline.getMin() || meanBaseline > measurementBaseline.getMax()) {
                throw new IllegalArgumentException(
                    "Invalid baseline value, must not be less than baselineMin or greater than baselineMax.");
            }

            MeasurementBaseline newMeasurementBaseline = scheduleWithBaseline.getBaseline();
            newMeasurementBaseline.setSchedule(scheduleWithBaseline);
            newMeasurementBaseline.setUserEntered(true);
            newMeasurementBaseline.setMean(meanBaseline);
            scheduleManager.updateSchedule(getSessionSubject(), scheduleWithBaseline);

        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
View Full Code Here

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

        /*
         * this is informational debugging only - do NOT change the status bits here
         */
        if (log.isDebugEnabled()) {
            MeasurementBaseline baseline = entityManager.find(MeasurementBaseline.class, baselineId);
            Agent agent = baseline.getSchedule().getResource().getAgent();
            log.debug("Marking status, agent[id=" + agent.getId() + ", status=" + agent.getStatus()
                + "] for measurementBaseline[id=" + baselineId + "]");
        }
    }
View Full Code Here

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

    private static final String MEASUREMENT_BASELINE_MEAN_TEXT = "Baseline Value";
    private static final String MEASUREMENT_BASELINE_MAX_TEXT = "Max Value";

    public static String getBaselineText(String baselineOption, MeasurementSchedule schedule) {
        if ((null != schedule) && (null != schedule.getBaseline())) {
            MeasurementBaseline baseline = schedule.getBaseline();

            String lookupText = null;
            Double value = null;

            if (baselineOption.equals(MeasurementConstants.BASELINE_OPT_MIN)) {
                lookupText = MEASUREMENT_BASELINE_MIN_TEXT;
                value = baseline.getMin();
            } else if (baselineOption.equals(MeasurementConstants.BASELINE_OPT_MEAN)) {
                lookupText = MEASUREMENT_BASELINE_MEAN_TEXT;
                value = baseline.getMean();
            } else if (baselineOption.equals(MeasurementConstants.BASELINE_OPT_MAX)) {
                lookupText = MEASUREMENT_BASELINE_MAX_TEXT;
                value = baseline.getMax();
            }

            if (value != null) {
                try {
                    String formatted = MeasurementConverter.scaleAndFormat(value, schedule, true);
View Full Code Here

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

                for (MeasurementBaseline baseline : tmpList) {
                    baselineMap.put(baseline.getScheduleId(),baseline);
                }

                for (AggregateNumericMetric metric : metricList) {
                    MeasurementBaseline baseline = baselineMap.get(metric.getScheduleId());
                    if (baseline==null)
                        continue;

                    try {
                        count += oobManager.calculateOOB(metric,baseline);
View Full Code Here

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

        criteria.addFilterIds(scheduleIds.toArray(new Integer[scheduleIds.size()]));
        criteria.setPageControl(PageControl.getUnlimitedInstance());
        List<MeasurementSchedule> schedules = measurementScheduleManager.findSchedulesByCriteria(
            subjectManager.getOverlord(), criteria);
        for (MeasurementSchedule schedule : schedules) {
            MeasurementBaseline baseline = baselines.get(schedule.getId());
            baseline.setScheduleId(schedule.getId());
            baseline.setSchedule(schedule); // this sets the reverse, owning relationship as well
            entityManager.persist(baseline);
        }
    }
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.