Package org.rhq.enterprise.server.measurement

Examples of org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal


        request.setAttribute("dampenInverseCount", AlertDampening.Category.INVERSE_COUNT.ordinal());
        request.setAttribute("dampenDurationCount", AlertDampening.Category.DURATION_COUNT.ordinal());

        request.setAttribute("noneDeleted", Constants.ALERT_CONDITION_NONE_DELETED);

        MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();
        MeasurementDefinitionManagerLocal definitionManager = LookupUtil.getMeasurementDefinitionManager();
        ConfigurationManagerLocal configurationManager = LookupUtil.getConfigurationManager();

        Subject subject = RequestUtils.getSubject(request);
        Resource resource = RequestUtils.getResource(request);
        ResourceGroup group = RequestUtils.getResourceGroupIfExists(request);

        ResourceType type = null;
        if (resource != null) {
            // resource alert definition
            type = resource.getResourceType();
        } else if (group != null) {
            // group alert definition
            type = group.getResourceType();
        } else {
            // template alert definition
            type = RequestUtils.getResourceType(request);
        }

        defForm.setResourceType(type.getId());

        List<MeasurementDefinition> dataDefinitions = definitionManager.findMeasurementDefinitionsByResourceType(
            subject, type.getId(), DataType.MEASUREMENT, null);

        List<MeasurementDefinition> calltimeDefinitions = definitionManager.findMeasurementDefinitionsByResourceType(
            subject, type.getId(), DataType.CALLTIME, null);

        List<MeasurementDefinition> traitDefinitions = definitionManager.findMeasurementDefinitionsByResourceType(
            subject, type.getId(), DataType.TRAIT, null);

        List<RelatedOptionBean> baselines = new ArrayList<RelatedOptionBean>();

        if (resource != null) {
            for (MeasurementDefinition definition : dataDefinitions) {
                MeasurementSchedule schedule = scheduleManager.getSchedule(subject, resource.getId(), definition
                    .getId(), false);

                RelatedOptionBean rob = new RelatedOptionBean(definition.getName(), String.valueOf(definition.getId()),
                    getBaselineList(schedule));
                baselines.add(rob);

                setDisabledName(schedule, definition);
            }

            for (MeasurementDefinition definition : traitDefinitions) {
                MeasurementSchedule schedule = scheduleManager.getSchedule(subject, resource.getId(), definition
                    .getId(), false);
                setDisabledName(schedule, definition);
            }
        } else {
            List<LabelValueBean> defaultBaselineLabels = getBaselineList(null);
View Full Code Here


        if (scheduleId == null) {
            scheduleId = RequestUtils.getMetricId(request);
        }

        MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();

        MeasurementBaseline metricValue = new MeasurementBaseline();
        MeasurementSchedule schedule = scheduleManager.getScheduleById(subject, scheduleId);

        if ((schedule != null) && (schedule.getBaseline() != null)) {
            metricValue = schedule.getBaseline();
        } else {
            log.info(" the measurement object does not have a baseline set");
View Full Code Here

            range.setEnd(rangePreferences.end);
        }

        Subject subject = WebUtility.getSubject(request);
        Resource resource = (Resource) request.getAttribute(AttrConstants.RESOURCE_ATTR);
        MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();
        List<MeasurementSchedule> callTimeSchedules = scheduleManager.findSchedulesForResourceAndType(
            subject, resource.getId(), DataType.CALLTIME, null, false);

        PerformanceForm perfForm = (PerformanceForm) form;
        prepareForm(request, perfForm, callTimeSchedules);
View Full Code Here

    public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
        log.trace("Executing ConfigMetricsFormPrepareAction...");

        Subject subject = WebUtility.getSubject(request);
        MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();
        MeasurementDefinitionManagerLocal definitionManager = LookupUtil.getMeasurementDefinitionManager();
        ResourceTypeManagerLocal rtManager = LookupUtil.getResourceTypeManager();

        // NOTE: This action will be passed either a resourceTypeId OR a resourceId or a groupID or type+parent
        boolean configuringDefaultSchedules = false;
        int type = WebUtility.getOptionalIntRequestParameter(request, "type", -1);
        int parent = WebUtility.getOptionalIntRequestParameter(request, "parent", -1);

        // If only a type is present, we want the defaults
        if ((type > 0) && (parent == -1)) {
            configuringDefaultSchedules = true;
        }

        PageList<MeasurementScheduleComposite> measurementSchedules = null;
        PageControl pageControl = WebUtility.getPageControl(request);
        int groupId = WebUtility.getOptionalIntRequestParameter(request, "groupId", -1);
        if (configuringDefaultSchedules || (groupId > 0) || ((type > 0) && (parent > 0))) {
            pageControl.initDefaultOrderingField("md.name"); // underlying query runs over the MeasurementDefinition
        } else {
            pageControl.initDefaultOrderingField("ms.definition.name");
        }

        // We never want pagination for the schedules table, so don't allow user to change ps to anything other than -1.
        pageControl.setPageSize(PageControl.SIZE_UNLIMITED);

        if (configuringDefaultSchedules) {
            int resourceTypeId = type;
            log.debug("Obtaining default metric schedules for resource type " + resourceTypeId + "...");
            List<MeasurementDefinition> definitions = definitionManager.findMeasurementDefinitionsByResourceType(
                subject, resourceTypeId, null, null);
            List<MeasurementScheduleComposite> composites = new ArrayList<MeasurementScheduleComposite>();
            for (MeasurementDefinition definition : definitions) {
                composites.add(new MeasurementScheduleComposite(definition, definition.isDefaultOn(), definition
                    .getDefaultInterval()));
            }
            measurementSchedules = new PageList<MeasurementScheduleComposite>(composites, definitions.size(),
                pageControl);
            //request.setAttribute(AttrConstants.MONITOR_ENABLED_ATTR, Boolean.FALSE);
            ResourceType rType = rtManager.getResourceTypeById(subject, resourceTypeId);

            request.setAttribute(AttrConstants.RESOURCE_TYPE_ATTR, rType);
            //request.setAttribute("section", resourceCategoryName);
        } else {
            int resourceId = WebUtility.getOptionalIntRequestParameter(request, "id", -1);
            if ((parent > 0) && (type > 0)) {
                //request.setAttribute(AttrConstants.MONITOR_ENABLED_ATTR, true);
                measurementSchedules = scheduleManager.getMeasurementScheduleCompositesByContext(subject, EntityContext
                    .forAutoGroup(parent, type), pageControl);

                request.setAttribute("type", type);
                request.setAttribute("parent", parent);
                ResourceManagerLocal resMgr = LookupUtil.getResourceManager();
                Resource parentRes = resMgr.getResourceById(subject, parent);
                request.setAttribute("parentName", parentRes.getName());
            } else if (resourceId > 0) {
                boolean monitoringConfigured = isMonitoringConfigured(resourceId);
                //request.setAttribute(AttrConstants.MONITOR_ENABLED_ATTR, monitoringConfigured);
                if (monitoringConfigured) {
                    log.debug("Obtaining metric schedules for resource " + resourceId + "...");
                    measurementSchedules = scheduleManager.getMeasurementScheduleCompositesByContext(subject,
                        EntityContext.forResource(resourceId), pageControl);
                }
            } else if (groupId > 0) {
                boolean monitoringConfigured = true; // isMonitoringConfiguredForGroup(groupId); // TODO implement the method, see below
                //request.setAttribute(AttrConstants.MONITOR_ENABLED_ATTR, true); // TODO change true -> monitoringConfigured
                if (monitoringConfigured) {
                    log.debug("Obtaining metric schedules for comp group " + groupId + "...");
                    measurementSchedules = scheduleManager.getMeasurementScheduleCompositesByContext(subject,
                        EntityContext.forGroup(groupId), pageControl);
                    request.setAttribute(AttrConstants.GROUP_ID, groupId);
                }

                //adding the groupName into the request to display on config page.
View Full Code Here

        if (log.isTraceEnabled())
            log.trace("modify-metric-schedules action");

        Subject subject = WebUtility.getSubject(request);
        MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();

        Map<String, Integer> returnRequestParams = new HashMap<String, Integer>(2);

        // NOTE: This action will be passed either a resourceTypeId OR a resourceId OR a groupId or ...
        int resourceId = WebUtility.getOptionalIntRequestParameter(request, ParamConstants.RESOURCE_ID_PARAM, -1);
        int groupId = WebUtility.getOptionalIntRequestParameter(request, ParamConstants.GROUP_ID_PARAM, -1);
        int resourceTypeId = WebUtility.getOptionalIntRequestParameter(request, ParamConstants.RESOURCE_TYPE_ID_PARAM,
            -1);

        int parent = WebUtility.getOptionalIntRequestParameter(request, "parent", -1);

        // Find out what we want to configure
        MetricsDisplayMode mode = WebUtility.getMetricsDisplayMode(request);

        // put the return params in the request
        switch (mode) {
        case RESOURCE_DEFAULT: {
            returnRequestParams.put(ParamConstants.RESOURCE_TYPE_ID_PARAM, resourceTypeId);
            break;
        }

        case RESOURCE: {
            returnRequestParams.put(ParamConstants.RESOURCE_ID_PARAM, resourceId);
            break;
        }

        case COMPGROUP: {
            returnRequestParams.put(ParamConstants.GROUP_ID_PARAM, groupId);

            break;
        }

        case AUTOGROUP: {
            returnRequestParams.put(ParamConstants.RESOURCE_TYPE_ID_PARAM, resourceTypeId);
            returnRequestParams.put("parent", parent);
            break;
        }

        case UNSET:
            // Do nothing, as we have invalid input
            break;
        }

        forward = checkSubmit(request, mapping, form, returnRequestParams);
        MonitoringConfigForm monitoringConfigForm = (MonitoringConfigForm) form;
        int[] measurementDefinitionIdsToUpdate = monitoringConfigForm.getMids();

        // Don't make any back-end call if user has not selected any metrics.
        if (measurementDefinitionIdsToUpdate.length == 0) {
            return (forward != null) ? forward : returnSuccess(request, mapping, returnRequestParams);
        }

        /*
         * Do the real show. First see if we need to disable the collection. If not, change the collection interval
         * further down
         */
        if (forward != null) {
            if (monitoringConfigForm.isRemoveClicked()) {
                switch (mode) {
                case RESOURCE_DEFAULT: {
                    scheduleManager.disableDefaultCollectionForMeasurementDefinitions(subject,
                        measurementDefinitionIdsToUpdate, monitoringConfigForm.getSchedulesShouldChange());
                    break;
                }

                case RESOURCE: {
                    scheduleManager.disableSchedulesForResource(subject, resourceId, measurementDefinitionIdsToUpdate);
                    break;
                }

                case COMPGROUP: {
                    scheduleManager.disableSchedulesForCompatibleGroup(subject, groupId,
                        measurementDefinitionIdsToUpdate);
                    break;
                }

                case AUTOGROUP: {
                    scheduleManager.disableSchedulesForAutoGroup(subject, parent, resourceTypeId,
                        measurementDefinitionIdsToUpdate);
                    break;
                }
                }

                RequestUtils.setConfirmation(request,
                    "resource.common.monitor.visibility.config.RemoveMetrics.Confirmation");
            }

            return forward;
        }

        // If we've fallen through to here, it's a request to update the collection interval...
        long newCollectionInterval = monitoringConfigForm.getIntervalTime();
        switch (mode) {
        case RESOURCE_DEFAULT: {
            scheduleManager.updateDefaultCollectionIntervalForMeasurementDefinitions(subject,
                measurementDefinitionIdsToUpdate, newCollectionInterval, monitoringConfigForm
                    .getSchedulesShouldChange());
            break;
        }

        case RESOURCE: {
            scheduleManager.updateSchedulesForResource(subject, resourceId, measurementDefinitionIdsToUpdate,
                newCollectionInterval);
            break;
        }

        case COMPGROUP: {
            scheduleManager.updateSchedulesForCompatibleGroup(subject, groupId, measurementDefinitionIdsToUpdate,
                newCollectionInterval);
            break;
        }

        case AUTOGROUP: {
            scheduleManager.updateSchedulesForAutoGroup(subject, parent, resourceTypeId,
                measurementDefinitionIdsToUpdate, newCollectionInterval);
            break;
        }
        }

View Full Code Here

        int newTemplateId = alertTemplateManager.createAlertTemplate(subjectManager.getOverlord(), newTemplate,
            resourceType.getId());

        // additionally, we want to ensure that the metric is enabled and collecting at a more frequent interval than
        // is set by default.
        MeasurementScheduleManagerLocal measurementManager = LookupUtil.getMeasurementScheduleManager();
        measurementManager.updateDefaultCollectionIntervalAndEnablementForMeasurementDefinitions(
            subjectManager.getOverlord(), ArrayUtils.toPrimitive(measurementDefinitionIds.toArray(new Integer[2])),
            60000L, true, true);

        return newTemplateId;
    }
View Full Code Here

        int newTemplateId = alertTemplateManager.createAlertTemplate(subjectManager.getOverlord(), newTemplate,
            resourceType.getId());

        // additionally, we want to ensure that the metric is enabled and collecting at a more frequent interval than
        // is set by default.
        MeasurementScheduleManagerLocal measurementManager = LookupUtil.getMeasurementScheduleManager();
        measurementManager.updateDefaultCollectionIntervalAndEnablementForMeasurementDefinitions(
            subjectManager.getOverlord(),
            ArrayUtils.toPrimitive(measurementDefinitionIds.toArray(new Integer[measurementDefinitionIds.size()])),
            60000L, true, true);

        return newTemplateId;
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal

Copyright © 2018 www.massapicom. 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.