Examples of MeasurementSchedule


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

        int[] measurementScheduleIds, long beginTime, long endTime) throws MeasurementException {
        List<MetricDisplaySummary> allMeasurementData = new ArrayList<MetricDisplaySummary>(
            measurementScheduleIds.length);
        List<Integer> scheduleIds = new ArrayList<Integer>(measurementScheduleIds.length);
        for (int measurementScheduleId : measurementScheduleIds) {
            MeasurementSchedule schedule = null;
            try {
                schedule = scheduleManager.getScheduleById(subject, measurementScheduleId);
                scheduleIds.add(schedule.getId());
            } catch (MeasurementNotFoundException mnfe) {
                throw new MeasurementException(mnfe);
            }

            MetricDisplaySummary summary = getMetricDisplaySummary(subject, schedule, beginTime, endTime, false);
            if (summary != null) {
                summary.setUnits(schedule.getDefinition().getUnits().name());
                // TODO: jmarques - should we add summary.setResourceId(resourceId) here?
                allMeasurementData.add(summary);
            }
        }
View Full Code Here

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

     * @param  scheduleId the id of the desired schedule
     *
     * @return The MeasurementSchedule or null if not found
     */
    public MeasurementSchedule getScheduleById(int scheduleId) {
        MeasurementSchedule ms;
        try {
            ms = entityManager.find(MeasurementSchedule.class, scheduleId);
        } catch (NoResultException n) {
            ms = null;
        }
View Full Code Here

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

     * @param  scheduleId The primary key of the Schedule
     *
     * @return a MeasurementSchedule or null, if there is
     */
    public MeasurementSchedule getScheduleById(Subject subject, int scheduleId) {
        MeasurementSchedule schedule = entityManager.find(MeasurementSchedule.class, scheduleId);
        if (schedule == null) {
            return null;
        }

        // the auth check eagerly loads the resource
        if (authorizationManager.canViewResource(subject, schedule.getResource().getId()) == false) {
            throw new PermissionException("User[" + subject.getName()
                + "] does not have permission to view measurementSchedule[id=" + scheduleId + "]");
        }

        // and this eagerly loads the definition
        schedule.getDefinition().getId();
        return schedule;
    }
View Full Code Here

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

            if (results.size() != 1) {
                throw new MeasurementException("Could not find measurementSchedule[resourceId=" + resourceId
                    + ", definitionId=" + definitionId + "]");
            }

            MeasurementSchedule schedule = results.get(0);
            if (attachBaseline && (schedule.getBaseline() != null)) {
                schedule.getBaseline().getId(); // eagerly load the baseline
            }

            return schedule;
        } catch (NoResultException nre) {
            throw new MeasurementNotFoundException(nre);
View Full Code Here

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

    public void createSchedulesForExistingResources(ResourceType type, MeasurementDefinition newDefinition) {
        List<Resource> resources = type.getResources();
        if (resources != null) {
            for (Resource res : resources) {
                res.setAgentSynchronizationNeeded();
                MeasurementSchedule sched = new MeasurementSchedule(newDefinition, res);
                sched.setInterval(newDefinition.getDefaultInterval());
                entityManager.persist(sched);
            }
        }
        return;
    }
View Full Code Here

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

     * @param  subject  A subject that must be valid
     * @param  schedule A MeasurementSchedule to persist.
     */
    public void updateSchedule(Subject subject, MeasurementSchedule schedule) {
        // attach it so we can navigate to its resource object for authz check
        MeasurementSchedule attached = entityManager.find(MeasurementSchedule.class, schedule.getId());
        if (authorizationManager.hasResourcePermission(subject, Permission.MANAGE_MEASUREMENTS, attached.getResource()
            .getId()) == false) {
            throw new PermissionException("User[" + subject.getName()
                + "] does not have permission to view measurementSchedule[id=" + schedule.getId() + "]");
        }

View Full Code Here

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

    public void removeMeasurementDefinition(MeasurementDefinition def) {
        // First remove the schedules and associated OOBs.
        List<MeasurementSchedule> schedules = def.getSchedules();
        Iterator<MeasurementSchedule> schedIter = schedules.iterator();
        while (schedIter.hasNext()) {
            MeasurementSchedule sched = schedIter.next();
            if (sched.getBaseline() != null) {
                entityManager.remove(sched.getBaseline());
                sched.setBaseline(null);
            }
            oobManager.removeOOBsForSchedule(subjectManager.getOverlord(), sched);
            sched.getResource().setAgentSynchronizationNeeded();
            entityManager.remove(sched);
            schedIter.remove();
        }

        // Now remove the definition itself.
View Full Code Here

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

    @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();

            // only check permissions if the user is attempting to save a new baseline
            if (save
                && !authorizationManager.hasResourcePermission(subject, Permission.MANAGE_MEASUREMENTS,
                    resource.getId())) {
View Full Code Here

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

        PageList<MeasurementSchedule> schedules = measurementScheduleManager.findSchedulesByCriteria(
            subjectManager.getOverlord(), criteria);
        if (schedules.isEmpty()) {
            throw new MeasurementException("Could not fine MeasurementSchedule with the id[" + scheduleId + "]");
        }
        MeasurementSchedule schedule = schedules.get(0);

        if (authorizationManager.canViewResource(subject, schedule.getResource().getId()) == false) {
            throw new PermissionException("User[" + subject.getName()
                + "] does not have permission to view schedule[id=" + scheduleId + "]");
        }

        if (schedule.getDefinition().getDataType() != DataType.MEASUREMENT) {
            throw new IllegalArgumentException(schedule + " is not about numerical values. Can't compute aggregates");
        }

        if (startTime > endTime) {
            throw new IllegalArgumentException("Start date " + startTime + " is not before " + endTime);
View Full Code Here

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

            PageList<MeasurementSchedule> schedules = measurementScheduleManager.findSchedulesByCriteria(
                subjectManager.getOverlord(), criteria);
            if (schedules.isEmpty()) {
                throw new MeasurementException("Could not fine MeasurementSchedule with the id[" + scheduleId + "]");
            }
            MeasurementSchedule schedule = schedules.get(0);

            if (authorizationManager.canViewResource(subject, schedule.getResource().getId()) == false) {
                throw new PermissionException("User[" + subject.getName()
                    + "] does not have permission to view schedule[id=" + scheduleId + "]");
            }

            if (schedule.getDefinition().getDataType() != DataType.MEASUREMENT) {
                throw new IllegalArgumentException(schedule + " is not about numerical values. Can't compute aggregates");
            }

            if (startTime > endTime) {
                throw new IllegalArgumentException("Start date " + startTime + " is not before " + endTime);
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.