Examples of AlertConditionLog


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

        String conditionValue;
        if (conditionLogs.size() > 1) {
            conditionText = MSG.view_alerts_field_condition_text_many();
            conditionValue = "--";
        } else if (conditionLogs.size() == 1) {
            AlertConditionLog conditionLog = conditionLogs.iterator().next();
            AlertCondition condition = conditionLog.getCondition();
            conditionText = AlertFormatUtility.formatAlertConditionForDisplay(condition);
            conditionValue = conditionLog.getValue();
            if (condition.getMeasurementDefinition() != null) {
                try {
                    conditionValue = MeasurementConverterClient.format(Double.valueOf(conditionLog.getValue()),
                        condition.getMeasurementDefinition().getUnits(), true);
                } catch (Exception e) {
                    // the condition log value was probably not a number (most likely a trait). Ignore this exception.
                    // even if any other errors occur trying to format the value, ignore this and just use the raw value string
                }
View Full Code Here

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

         * this method is marked as REQUIRES_NEW because I want this log work to complete before I resume the
         * outer-scoping transaction, which will operate on the results.
         */
        try {
            try {
                AlertConditionLog alertConditionLog = this.getUnmatchedLogByAlertConditionId(alertConditionId);

                /*
                 * No exceptions.
                 *
                 * This means that there was exactly one existing, unmatched, active alert condition.  This is another
                 * positive event associated against the same alertCondition, so we're going to use its data to update the
                 * "ctime" and "value" properties.
                 */
                alertConditionLog.setCtime(ctime);
                value = DatabaseTypeFactory.getDefaultDatabaseType().getString(value, AlertConditionLog.MAX_LOG_LENGTH);
                alertConditionLog.setValue(value);
                if (log.isDebugEnabled()) {
                    log.debug("Updating unmatched alert condition log: " + alertConditionLog);
                }

                entityManager.merge(alertConditionLog); // update values, for
                entityManager.flush();
            } catch (NoResultException nre) { // this is the expected case 90% of the time
                // lookup the condition entity
                AlertCondition condition = entityManager.find(AlertCondition.class, alertConditionId);

                // persist the log entry
                AlertConditionLog conditionLog = new AlertConditionLog(condition, ctime);
                conditionLog.setValue(value);

                if (log.isDebugEnabled()) {
                    log.debug("Inserting unmatched alert condition log: " + conditionLog);
                }

View Full Code Here

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

    }

    @Override
    public void removeUnmatchedLogByAlertConditionId(int alertConditionId) {
        try {
            AlertConditionLog alertConditionLog = this.getUnmatchedLogByAlertConditionId(alertConditionId);

            if (log.isDebugEnabled()) {
                log.debug("Removing unmatched alert condition log: " + alertConditionLog);
            }
View Full Code Here

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

                Set<AlertConditionLog> acls = history.getAlert().getConditionLogs();
                if (acls.size() > 1) {
                    history.setConditionText("Multiple Conditions");
                    history.setConditionValue("--");
                } else if (acls.size() == 1) {
                    AlertConditionLog log = acls.iterator().next();
                    AlertCondition condition = log.getCondition();
                    String displayText = AlertDefUtil.formatAlertConditionForDisplay(condition, request);

                    String firedValue = log.getValue();
                    if (condition.getMeasurementDefinition() != null) {
                        DataType type = condition.getMeasurementDefinition().getDataType();
                        if (type == DataType.CALLTIME || type == DataType.TRAIT)
                            firedValue = log.getValue();
                        else
                            firedValue = MeasurementConverter.format(Double.valueOf(log.getValue()), condition
                                .getMeasurementDefinition().getUnits(), true);
                    }

                    history.setConditionText(displayText);
                    history.setConditionValue(firedValue);
View Full Code Here

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

        return md;
    }

    private Alert createAlert(AlertCondition condition) {
        Alert alert = new Alert();
        AlertConditionLog conditionLog = new AlertConditionLog(condition, System.currentTimeMillis());
        alert.addConditionLog(conditionLog);
        return alert;
    }
View Full Code Here

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

                String conditionValue;

                if (conditionLogs.size() > 1) {
                    conditionText = "Multiple Conditions";
                } else if (conditionLogs.size() == 1) {
                    AlertConditionLog conditionLog = conditionLogs.iterator().next();
                    AlertCondition condition = conditionLog.getCondition();
                    conditionText = formatCondition(condition);
                    conditionValue = conditionLog.getValue();
                    if (condition.getMeasurementDefinition() != null) {
                        try {
                            conditionValue = MeasurementConverter.format(conditionLog.getValue(),
                                condition.getMeasurementDefinition().getUnits());
                        } catch (Exception e) {
                            // the condition log value was probably not a number (most likely a trait). Ignore this exception.
                            // even if any other errors occur trying to format the value, ignore this and just use the raw value string
                        }
View Full Code Here

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

        Iterator<AlertCondition> condsIterator = conds.iterator();
        Iterator<AlertConditionLog> condLogsIterator = condLogs.iterator();

        for (AlertConditionBean alertCondBean : alertCondBeans) {
            AlertCondition cond = condsIterator.next();
            AlertConditionLog condLog = condLogsIterator.next();
            AlertConditionCategory category = cond.getCategory();

            if (category == AlertConditionCategory.CONTROL) {
                alertCondBean.setActualValue(RequestUtils.message(request, "alert.current.list.ControlActualValue"));
            } else if ((category == AlertConditionCategory.THRESHOLD) || (category == AlertConditionCategory.BASELINE)
                || (category == AlertConditionCategory.CHANGE)) {

                // Format threshold and value.
                MeasurementDefinition definition = condLog.getCondition().getMeasurementDefinition();
                String firedValue;

                try {
                    firedValue = MeasurementConverter.format(Double.valueOf(condLog.getValue()), definition.getUnits(),
                        true);
                } catch (Exception e) {
                    // check if this is Calltime data
                    if (definition.getDataType() == DataType.CALLTIME)
                        firedValue = condLog.getValue();
                    else
                        firedValue = "??";
                }

                alertCondBean.setActualValue(firedValue);
            } else if ((category == AlertConditionCategory.RESOURCE_CONFIG)
                || (category == AlertConditionCategory.EVENT)) {
                // TODO: jmarques - add validation to make sure condition is a valid regex Pattern
                alertCondBean.setActualValue(condLog.getValue());
            } else if (category == AlertConditionCategory.TRAIT) {
                alertCondBean.setActualValue(condLog.getValue());
            } else {
                alertCondBean.setActualValue("??");
            }
        }
View Full Code Here

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

                String recoveryInfo = AlertDefUtil.getAlertRecoveryInfo(alert, resource.getId());

                if (alert.getConditionLogs().size() > 1) {
                    results.add(new AlertWithLatestConditionLog(alert, "Multiple Conditions", "--", recoveryInfo));
                } else if (alert.getConditionLogs().size() == 1) {
                    AlertConditionLog log = alert.getConditionLogs().iterator().next();
                    AlertCondition condition = log.getCondition();
                    String displayText = AlertDefUtil.formatAlertConditionForDisplay(condition, request);

                    String firedValue = log.getValue();
                    if (isPureNumeric(condition)) {
                        firedValue = MeasurementConverter.format(Double.valueOf(log.getValue()), condition
                            .getMeasurementDefinition().getUnits(), true);
                    }

                    results.add(new AlertWithLatestConditionLog(alert, displayText, firedValue, recoveryInfo));
                } else {
View Full Code Here

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

                String recoveryInfo = AlertDefUtil.getAlertRecoveryInfo(alert, res.getId());

                if (alert.getConditionLogs().size() > 1) {
                    results.add(new AlertWithLatestConditionLog(alert, "Multiple Conditions", "--", recoveryInfo));
                } else if (alert.getConditionLogs().size() == 1) {
                    AlertConditionLog log = alert.getConditionLogs().iterator().next();
                    AlertCondition condition = log.getCondition();
                    String displayText = AlertDefUtil.formatAlertConditionForDisplay(condition, request);

                    String firedValue = log.getValue();
                    if (condition.getMeasurementDefinition() != null) {
                        firedValue = MeasurementConverter.format(Double.valueOf(log.getValue()), condition
                            .getMeasurementDefinition().getUnits(), true);
                    }

                    results.add(new AlertWithLatestConditionLog(alert, displayText, firedValue, recoveryInfo));
                } else {
View Full Code Here

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

        AlertNotificationLog anl = new AlertNotificationLog(a, "dummy", ResultState.SUCCESS, "message");
        em.persist(anl);

        AlertCondition ac = ad.getConditions().iterator().next();
        AlertConditionLog acl = new AlertConditionLog(ac, timestamp);
        acl.setAlert(a);
        acl.setValue("dummy value");
        em.persist(acl);

        return a;
    }
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.