Examples of MeasurementBaseline


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

            + "   AND ms.definition.id = :definitionId ");
        query.setParameter("groupId", groupId);
        query.setParameter("definitionId", definitionId);
        Object[] results = (Object[]) query.getSingleResult();

        MeasurementBaseline baseline = new MeasurementBaseline();
        if ((Long) results[6] == 0) {
            // no baselines calculated yet, return null to indicate that
            return null;
        }

        // there was at least one baseline, so one or more of min/mean/max might be non-null
        if (results[0] == null || results[1] == null) {
            baseline.setMin(null);
        } else if (Math.abs((Double) results[0] - (Double) results[1]) < 1e-9) {
            baseline.setMin((Double) results[0]); // they are close enough to being equal
        } else {
            baseline.setMin(-1.0); // use negative to represent mixed, because we currently don't support graphing negs
        }
        if (results[2] == null || results[3] == null) {
            baseline.setMean(null);
        } else if (Math.abs((Double) results[2] - (Double) results[3]) < 1e-9) {
            baseline.setMean((Double) results[2]); // they are close enough to being equal
        } else {
            baseline.setMean(-1.0); // use negative to represent mixed, because we currently don't support graphing negs
        }
        if (results[4] == null || results[5] == null) {
            baseline.setMax(null);
        } else if (Math.abs((Double) results[4] - (Double) results[5]) < 1e-9) {
            baseline.setMax((Double) results[4]); // they are close enough to being equal
        } else {
            baseline.setMax(-1.0); // use negative to represent mixed, because we currently don't support graphing negs
        }
        return baseline;
    }
View Full Code Here

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

    @TransactionAttribute(TransactionAttributeType.NEVER)
    public MeasurementBaseline calculateAutoBaseline(Subject subject, Integer measurementScheduleId, long startDate,
        long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException {

        MeasurementBaseline result = measurementBaselineManager.calculateAutoBaselineInNewTransaction(subject,
            measurementScheduleId, startDate, endDate, save);

        if (save) {
            // note, this executes in a new transaction so the baseline must already be committed to the database
            agentStatusManager.updateByMeasurementBaseline(result.getId());
        }

        return result;
    }
View Full Code Here

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

    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public MeasurementBaseline calculateAutoBaselineInNewTransaction(Subject subject, Integer measurementScheduleId,
        long startDate, long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException {

        MeasurementBaseline baseline;
        MeasurementSchedule sched = entityManager.find(MeasurementSchedule.class, measurementScheduleId);

        if (sched != null) {
            Resource resource = sched.getResource();
View Full Code Here

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

    @TransactionAttribute(TransactionAttributeType.NEVER)
    public MeasurementBaseline calculateAutoBaseline(Subject subject, int groupId, int definitionId, long startDate,
        long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException {

        MeasurementBaseline result = measurementBaselineManager.calculateAutoBaselineForGroupInNewTransaction(subject,
            groupId, definitionId, startDate, endDate, save);

        if (save) {
            // note, this executes in a new transaction so the baseline must already be committed to the database
            agentStatusManager.updateByMeasurementBaseline(result.getId());
        }

        return result;
    }
View Full Code Here

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

        if (save && !authorizationManager.hasGroupPermission(subject, Permission.MANAGE_MEASUREMENTS, groupId)) {
            throw new PermissionException("User[" + subject.getName()
                + "] does not have permission to calculate and set baselines for group[id=" + groupId + "]");
        }

        MeasurementBaseline baseline;
        try {
            baseline = calculateBaselineForGroup(groupId, definitionId, true, startDate, endDate, save);
            if (save) {
                // We have changed the baseline information for the schedule, so remove the now outdated OOB info.
                oobManager.removeOOBsForGroupAndDefinition(subject, groupId, definitionId);
View Full Code Here

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

            startDate, endDate);

        // attach the entity, so we can find the baseline
        schedule = entityManager.merge(schedule);

        MeasurementBaseline baseline = null;
        if (save && (schedule.getBaseline() != null)) {
            /*
             * If saving, make sure we're updating the existing one, if it exists
             */
            baseline = schedule.getBaseline();
        } else {
            /*
             * Otherwise, if we're not saving or if the the schedule doesn't have a current baseline, we create a new
             * baseline object
             */
            baseline = new MeasurementBaseline();

            if (save) {
                /*
                 * But, if we *are* in save mode, then set the relationship so when we merge the schedule below it
                 * persists this new baseline too
                 */
                baseline.setSchedule(schedule);
            }
        }

        baseline.setUserEntered(userEntered);
        baseline.setMean(agg.getAvg());
        baseline.setMin(agg.getMin());
        baseline.setMax(agg.getMax());

        if (save) {
            entityManager.persist(baseline);
            entityManager.merge(schedule);
        }
View Full Code Here

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

        Subject overlord = subjectManager.getOverlord();
        List<Integer> resourceIds = resourceManager.findImplicitResourceIdsByResourceGroup(groupId);
        List<MeasurementSchedule> schedules = measurementScheduleManager.findSchedulesByResourceIdsAndDefinitionId(
            overlord, ArrayUtils.unwrapCollection(resourceIds), definitionId);

        MeasurementBaseline baseline = null;
        for (MeasurementSchedule schedule : schedules) {
            // attach the entity, so we can find the baseline
            schedule = entityManager.merge(schedule);

            if (save && (schedule.getBaseline() != null)) {
                /*
                 * If saving, make sure we're updating the existing one, if it exists
                 */
                baseline = schedule.getBaseline();
            } else {
                /*
                 * Otherwise, if we're not saving or if the the schedule doesn't have a current baseline, we create a new
                 * baseline object
                 */
                baseline = new MeasurementBaseline();

                if (save) {
                    /*
                     * But, if we *are* in save mode, then set the relationship so when we merge the schedule below it
                     * persists this new baseline too
                     */
                    baseline.setSchedule(schedule);
                }
            }

            baseline.setUserEntered(userEntered);
            baseline.setMean(agg.getAvg());
            baseline.setMin(agg.getMin());
            baseline.setMax(agg.getMax());

            if (save) {
                entityManager.persist(baseline);
                entityManager.merge(schedule);
            }
View Full Code Here

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

            expectedStartTime, expectedEndTime);

        //verify the results (Assert and mock verification)
        Assert.assertEquals(result.size(), 1);

        MeasurementBaseline baselineResult = result.get(Integer.valueOf(expectedScheduleId));
        Assert.assertEquals(baselineResult.getMean(), mean.getArithmeticMean(), TEST_PRECISION);
        Assert.assertEquals(baselineResult.getMax(), expectedMax, TEST_PRECISION);
        Assert.assertEquals(baselineResult.getMin(), expectedMin, TEST_PRECISION);
        Assert.assertEquals(baselineResult.getScheduleId(), expectedScheduleId);
        if (baselineResult.getComputeTime().getTime() > System.currentTimeMillis()) {
            Assert.fail("Back compute time, the computation was forward dated.");
        }
        if (baselineResult.getComputeTime().getTime() < beforeComputeTime) {
            Assert.fail("Back compute time, the computation was backdated.");
        }

        verify(mockMetricsDAO, times(1)).findAggregateMetrics(eq(expectedScheduleId), eq(Bucket.ONE_HOUR),
            eq(expectedStartTime), eq(expectedEndTime));
View Full Code Here

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

    }

    public Map<Integer, MeasurementBaseline> calculateBaselines(Set<Integer> scheduleIds, long startTime, long endTime) {
        Map<Integer, MeasurementBaseline> calculatedBaselines = new HashMap<Integer, MeasurementBaseline>();

        MeasurementBaseline measurementBaseline;
        for (Integer scheduleId : scheduleIds) {
            measurementBaseline = this.calculateBaseline(scheduleId, startTime, endTime);
            if (measurementBaseline != null) {
                calculatedBaselines.put(scheduleId, measurementBaseline);
            }
View Full Code Here

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

            if (metric.getMin() < min) {
                min = metric.getMin();
            }
        }

        MeasurementBaseline baseline = new MeasurementBaseline();
        baseline.setMax(max);
        baseline.setMin(min);
        baseline.setMean(mean.getArithmeticMean());
        baseline.setScheduleId(schedule);

        if (log.isDebugEnabled()) {
            log.debug("Calculated baseline: " + baseline.toString());
        }

        return 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.