Package org.rhq.core.domain.alert

Examples of org.rhq.core.domain.alert.AlertDefinition


        HttpServletResponse response) throws Exception {
        PageControl pc = WebUtility.getPageControl(request);

        log.debug("Viewing notifications for an alert definition ...");

        AlertDefinition alertDefinition = AlertDefUtil.getAlertDefinition(request);
        Subject subject = RequestUtils.getSubject(request);
        PageList<T> notifyList = getPageList(subject, alertDefinition, pc);

        request.setAttribute("notifyList", notifyList);
        request.setAttribute(Constants.LIST_SIZE_ATTR, notifyList.getTotalSize());
View Full Code Here


        portal.setName(titleName);

        // if there's an alert definition available, set our second
        // title parameter to its name
        try {
            AlertDefinition alertDef = AlertDefUtil.getAlertDefinition(request);
            request.setAttribute(Constants.TITLE_PARAM2_ATTR, alertDef.getName());
        } catch (ParameterNotFoundException e) {
            // it's okay
            log.trace("couldn't find alert definition: " + e.getMessage());
        }
    }
View Full Code Here

    @Override
    public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
        log.debug("in edit definition properties form prepare ...");

        AlertDefinition alertDef = AlertDefUtil.getAlertDefinition(request);

        DefinitionForm defForm = (DefinitionForm) form;
        defForm.importProperties(alertDef);

        defForm.setId(RequestUtils.getResourceId(request));
View Full Code Here

    @Override
    protected void setupConditions(HttpServletRequest request, DefinitionForm defForm) throws Exception {
        Integer alertDefId = new Integer(request.getParameter("ad"));
        log.trace("alertDefId=" + alertDefId);

        AlertDefinition alertDef = AlertDefUtil.getAlertDefinition(request);

        // Get the alert names
        Collection alertdefs = defForm.getAlertnames();
        for (Iterator it = alertdefs.iterator(); it.hasNext();) {
            Map.Entry entry = (Map.Entry) it.next();

            //  Don't include this alert definition
            if (entry.getValue().equals(alertDef.getId())) {
                it.remove();
                break;
            }
        }
View Full Code Here

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
        Subject subject = RequestUtils.getSubject(request);

        // properties, also sets Request or RequestType request attribute
        AlertDefinition alertDef = AlertDefUtil.getAlertDefinition(request);

        // conditions
        Set<AlertCondition> conds = alertDef.getConditions();

        List<AlertConditionBean> alertDefConditions = AlertDefUtil.getAlertConditionBeanList(subject, request, conds);
        request.setAttribute("conditionExpression", alertDef.getConditionExpression().name());
        request.setAttribute("alertDefConditions", alertDefConditions);

        request.setAttribute("controlEnabled", true); // TODO: disable if this resource doesn't have any operations facet

        int recoveryAlertDefId = alertDef.getRecoveryId();
        if (recoveryAlertDefId != 0) {
            String recoveryAlertName = getRecoveryAlertName(recoveryAlertDefId, subject);
            request.setAttribute("recoveryAlertName", recoveryAlertName);
        }
View Full Code Here

        return null;
    }

    private String getRecoveryAlertName(int alertDefinitionId, Subject user) {
        try {
            AlertDefinition alertDefinition = LookupUtil.getAlertDefinitionManager().getAlertDefinitionById(user,
                alertDefinitionId);
            return alertDefinition.getName();
        } catch (Exception ex) {
            return null;
        }
    }
View Full Code Here

            return forward;
        }

        Subject subject = RequestUtils.getSubject(request);

        AlertDefinition alertDef = AlertDefUtil.getAlertDefinition(request);

        try {
            defForm.exportConditionsEnablement(alertDef, request, subject);
        } catch (Exception e) {
            log.debug("alert definition update failed:", e);
            RequestUtils.setError(request, "alert.config.edit.definition.error", e.getMessage(), "global");
            return returnFailure(request, mapping, null);
        }

        try {
            if (context == FormContext.Type) {
                AlertTemplateManagerLocal alertTemplateManager = LookupUtil.getAlertTemplateManager();
                alertTemplateManager.updateAlertTemplate(subject, alertDef, true);
            } else if (context == FormContext.Resource) {
                AlertDefinitionManagerLocal alertDefinitionManager = LookupUtil.getAlertDefinitionManager();
                alertDefinitionManager.updateAlertDefinition(subject, alertDef.getId(), alertDef, true);
            } else if (context == FormContext.Group) {
                GroupAlertDefinitionManagerLocal groupAlertDefinitionManager = LookupUtil
                    .getGroupAlertDefinitionManager();
                groupAlertDefinitionManager.updateGroupAlertDefinitions(subject, alertDef, true);
            } else {
View Full Code Here

        measSched2.setEnabled(true);
        platform2.addSchedule(measSched2);
        measDef.addSchedule(measSched2);
        em.persist(measSched2);

        alertDef = new AlertDefinition();
        alertDef.setName("PRAlertDef1");
        alertDef.setResource(platform);
        alertDef.setPriority(AlertPriority.MEDIUM);
        alertDef.setAlertDampening(new AlertDampening(Category.NONE));
        alertDef.setConditionExpression(BooleanExpression.ALL);
        alertDef.setRecoveryId(0);
        em.persist(alertDef);

        alertDef2 = new AlertDefinition();
        alertDef2.setName("PRAlertDef2");
        alertDef2.setResource(platform2);
        alertDef2.setPriority(AlertPriority.MEDIUM);
        alertDef2.setAlertDampening(new AlertDampening(Category.NONE));
        alertDef2.setConditionExpression(BooleanExpression.ALL);
View Full Code Here

    public Resource getTargetResource(Alert alert) {
        if (mode == null) {
            return null;
        } else if (mode == ResourceSelectionMode.SELF) {
            AlertDefinition definition = alert.getAlertDefinition();
            Resource contextResource = definition.getResource();
            return contextResource;
        } else if (mode == ResourceSelectionMode.SPECIFIC) {
            return LookupUtil.getResourceManager().getResourceById(getOverlord(), resourceId);
        } else if (mode == ResourceSelectionMode.RELATIVE) {
            AlertDefinition definition = alert.getAlertDefinition();
            Resource contextResource = definition.getResource();

            Resource searchFrom = contextResource;
            if (ancestorTypeId != null) {
                List<Resource> contextLineage = LookupUtil.getResourceManager().getResourceLineage(
                    contextResource.getId());
View Full Code Here

    @Test(enabled = ENABLED)
    public void testBZ736685_DeleteConditionLogButNoAlert() throws Exception {
        // create our resource with alert definition
        MeasurementDefinition metricDef = createResourceWithMetricSchedule();
        AlertDefinition alertDef = createAlertDefinitionWithTwoConditionsALL(metricDef, resource.getId());

        // re-load the resource so we get the measurement schedule
        Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
        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);

        PageList<Alert> alerts = getAlerts(resourceWithSchedules.getId());
        assert alerts.size() == 0 : "no alerts should have fired: " + alerts;

        // ...but make sure a condition was true (the condition we know is true is "< 60")
        int condId = 0;
        for (AlertCondition cond : alertDef.getConditions()) {
            if (cond.getComparator().equals("<")) {
                condId = cond.getId();
                break;
            }
        }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.alert.AlertDefinition

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.