Examples of MeasurementUnits


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

            break;
        }
        case THRESHOLD: {
            double value = condition.getThreshold();
            MeasurementUnits units = condition.getMeasurementDefinition().getUnits();
            String formatted = MeasurementConverterClient.format(value, units, true);

            if (condition.getOption() == null) {
                str.append(MSG.view_alert_common_tab_conditions_type_metric_threshold());
                str.append(" [");
                str.append(condition.getName());
                str.append(" ");
                str.append(condition.getComparator());
                str.append(" ");
                str.append(formatted);
                str.append("]");
            } else {
                // this is a calltime threshold condition
                str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_threshold());
                str.append(" [");
                if (condition.getMeasurementDefinition() != null) {
                    str.append(condition.getMeasurementDefinition().getDisplayName());
                    str.append(" ");
                }
                str.append(condition.getOption()); // MIN, MAX, AVG (never null)
                str.append(" ");
                str.append(condition.getComparator()); // <, >, =
                str.append(" ");
                str.append(formatted);
                str.append("]");
                if (condition.getName() != null && condition.getName().length() > 0) {
                    str.append(" ");
                    str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_destination());
                    str.append(" '");
                    str.append(condition.getName());
                    str.append("'");
                }
            }
            break;
        }
        case BASELINE: {
            str.append(MSG.view_alert_common_tab_conditions_type_metric_baseline());
            str.append(" [");
            str.append(condition.getName());
            str.append(" ");
            str.append(condition.getComparator());
            str.append(" ");

            double value = condition.getThreshold();
            MeasurementUnits units = MeasurementUnits.PERCENTAGE;
            String formatted = MeasurementConverterClient.format(value, units, true);
            str.append(formatted);

            str.append(" ").append(MSG.view_alert_common_tab_conditions_type_metric_baseline_verb()).append(" ");
            str.append(condition.getOption());
            str.append("]");
            break;
        }
        case CHANGE: {
            if (condition.getOption() == null) {
                str.append(MSG.view_alert_common_tab_conditions_type_metric_change());
                str.append(" [");
                str.append(condition.getName());
                str.append("]");
            } else {
                // this is a calltime change condition
                str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_change());
                str.append(" [");
                if (condition.getMeasurementDefinition() != null) {
                    str.append(condition.getMeasurementDefinition().getDisplayName());
                    str.append(" ");
                }
                str.append(condition.getOption()); // MIN, MAX, AVG (never null)
                str.append(" ");
                str.append(getCalltimeChangeComparator(condition.getComparator())); // LO, HI, CH
                str.append(" ");
                str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_change_verb());
                str.append(" ");

                double value = condition.getThreshold();
                MeasurementUnits units = MeasurementUnits.PERCENTAGE;
                String formatted = MeasurementConverterClient.format(value, units, true);
                str.append(formatted);

                str.append("]");
                if (condition.getName() != null && condition.getName().length() > 0) {
                    str.append(" ");
                    str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_destination());
                    str.append(" '");
                    str.append(condition.getName());
                    str.append("'");
                }
            }
            break;
        }
        case TRAIT: {
            str.append(MSG.view_alert_common_tab_conditions_type_metric_trait_change());
            str.append(" [");
            str.append(condition.getName());
            str.append("]");
            if (condition.getOption() != null && condition.getOption().length() > 0) {
                str.append(" ");
                str.append(MSG.view_alert_common_tab_conditions_type_metric_trait_matching());
                str.append(" '");
                str.append(condition.getOption());
                str.append("'");
            }

            break;
        }
        case CONTROL: {
            str.append(MSG.view_alert_common_tab_conditions_type_operation());
            str.append(" [");
            str.append(condition.getName());
            str.append("] ");
            str.append(MSG.view_alert_common_tab_conditions_type_operation_status());
            str.append(" [");
            str.append(condition.getOption());
            str.append("]");
            break;
        }
        case RESOURCE_CONFIG: {
            str.append(MSG.view_alert_common_tab_conditions_type_resource_configuration());
            break;
        }
        case EVENT: {
            str.append(MSG.view_alert_common_tab_conditions_type_event());
            str.append(" [");
            str.append(condition.getName());
            str.append("]");
            if (condition.getOption() != null && condition.getOption().length() > 0) {
                String eventDetailsRegexValue = "", eventSourcePathRegexValue = "";
                if (condition.getOption().contains(AlertCondition.ADHOC_SEPARATOR)) {
                    String[] regexes = condition.getOption().split(AlertCondition.ADHOC_SEPARATOR);
                    if (regexes.length > 0) {
                        eventDetailsRegexValue = regexes[0];
                        if (regexes.length > 1) {
                            eventSourcePathRegexValue = regexes[1];
                        }
                    }
                } else {
                    eventDetailsRegexValue = condition.getOption(); // old approach -> probably working with db before rhq 4.13
                }
                if (!eventSourcePathRegexValue.isEmpty()) {
                    str.append(" ");
                    str.append(MSG.view_alert_common_tab_conditions_type_event_matching());
                    str.append(" '");
                    str.append(eventSourcePathRegexValue);
                    str.append("'");
                }
                if (!eventDetailsRegexValue.isEmpty()) {
                    str.append(" ");
                    str.append(MSG.view_alert_common_tab_conditions_type_event_details_matching());
                    str.append(" '");
                    str.append(eventDetailsRegexValue);
                    str.append("'");
                }
            }
            break;
        }
        case DRIFT: {
            String configNameRegex = condition.getName();
            String pathNameRegex = condition.getOption();
            if (configNameRegex == null || configNameRegex.length() == 0) {
                if (pathNameRegex == null || pathNameRegex.length() == 0) {
                    // neither a config name regex nor path regex was specified
                    str.append(MSG.view_alert_common_tab_conditions_type_drift());
                } else {
                    // a path name regex was specified, but not a config name regex
                    str.append(MSG.view_alert_common_tab_conditions_type_drift_onlypaths(pathNameRegex));
                }
            } else {
                if (pathNameRegex == null || pathNameRegex.length() == 0) {
                    // a config name regex was specified, but not a path name regex
                    str.append(MSG.view_alert_common_tab_conditions_type_drift_onlyconfig(configNameRegex));
                } else {
                    // both a config name regex and a path regex was specified
                    str.append(MSG.view_alert_common_tab_conditions_type_drift_configpaths(pathNameRegex,
                        configNameRegex));
                }
            }
            break;
        }
        case RANGE: {
            String metricName = condition.getName();
            MeasurementUnits units = condition.getMeasurementDefinition().getUnits();
            double loValue = condition.getThreshold();
            String formattedLoValue = MeasurementConverterClient.format(loValue, units, true);
            String formattedHiValue = condition.getOption();
            try {
                double hiValue = Double.parseDouble(formattedHiValue);
View Full Code Here

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

        }

        String magnitude = matcher.group(1);
        String units = matcher.group(2);

        MeasurementUnits fromUnits;
        if (units.equals("")) {
            /*
             * no units is valid, and we assume the passed targetUnits; however, we will
             * still need to check that the number is well-formed, so continue processing.
             */
            fromUnits = targetUnits;
        } else {
            fromUnits = MeasurementUnits.getUsingDisplayUnits(units, targetUnits.getFamily());

            if ((fromUnits == null) || (!fromUnits.isComparableTo(targetUnits))) {
                throw new MeasurementConversionException("The units in '" + input + "' were not valid, " + "expected '"
                    + targetUnits.getFamily() + "' units, received '" + units + "' units");
            }
        }

View Full Code Here

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

    }

    public static MeasurementNumericValueAndUnits parse(String input, MeasurementSchedule targetSchedule)
        throws MeasurementConversionException {
        MeasurementUnits targetUnits = targetSchedule.getDefinition().getUnits();

        return parse(input, targetUnits);
    }
View Full Code Here

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

       return nf;
   }

    public static Double scale(MeasurementNumericValueAndUnits origin, MeasurementUnits targetUnits)
       throws MeasurementConversionException {
       MeasurementUnits originUnits = origin.getUnits();
       Double originValue = origin.getValue();

       return originValue * MeasurementUnits.calculateOffset(originUnits, targetUnits);
   }
View Full Code Here

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

       if (origin < 0) {
           wasNegative = true;
           origin = -origin;
       }

       MeasurementUnits baseUnit = targetUnits.getBaseUnits();
       MeasurementNumericValueAndUnits valueAndUnits = new MeasurementNumericValueAndUnits(origin, baseUnit);

       Double results = scale(valueAndUnits, targetUnits);
       if (wasNegative) {
           results = -results;
View Full Code Here

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

   public static String[] formatToSignificantPrecision(double[] values, MeasurementUnits targetUnits, boolean bestFit) {
       if ((null == values) || (values.length == 0)) {
           return null;
       }

       MeasurementUnits originalUnits = targetUnits;

       /*
        * in the overwhelming majority of cases, you're going to want to apply a bestFit
        * to the passed data, but it's not required; it's perfectly possible to allow a
        * list of doubles to be formatted without being fit, in which case the targetUnits
        * will be part of the formatted display for each result element
        */
       if (bestFit) {
           // find bestFit units by taking the average
           Double average = 0.0;

           for (int i = 0, sz = values.length; i < sz; i++) {
               /*
                * adding fractional amount iterative leads to greater
                * error, but prevents overflow on large data sets
                */
               average += (values[i] / sz);
           }

           MeasurementNumericValueAndUnits fittedAverage = fit(average, targetUnits);
           //noinspection UnnecessaryLocalVariable
           MeasurementUnits fittedUnits = fittedAverage.getUnits();

           /*
            * and change the local reference to targetUnits, so that the same logic
            * can be used both for the bestFit and non-bestFit computations
            */
 
View Full Code Here

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

       return format(formatted, targetUnits);
   }

   public static String scaleAndFormat(Double origin, MeasurementSchedule targetSchedule, boolean bestFit)
       throws MeasurementConversionException {
       MeasurementUnits targetUnits = targetSchedule.getDefinition().getUnits();

       return scaleAndFormat(origin, targetUnits, bestFit, null, null);
   }
View Full Code Here

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

   }

   public static String scaleAndFormat(Double origin, MeasurementUnits targetUnits, boolean bestFit,
       Integer minimumFractionDigits, Integer maximumFractionDigits) throws MeasurementConversionException {

       MeasurementUnits baseUnits = targetUnits.getBaseUnits();
       MeasurementNumericValueAndUnits valueAndUnits = new MeasurementNumericValueAndUnits(origin, baseUnits);
       Double scaledMagnitude = scale(valueAndUnits, targetUnits);

       return format(scaledMagnitude, targetUnits, bestFit);
   }
View Full Code Here

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

           if (nextOrdinal == maxOrdinal) {
               // we could theoretically get bigger, but we don't have any units to represent that
               break;
           }

           MeasurementUnits biggerUnits = MeasurementUnits.values()[nextOrdinal];
           if (biggerUnits.getFamily() != currentValueAndUnits.getUnits().getFamily()) {
               // we're as big as we can get, break out of the loop so we can return
               break;
           }

           Double smallerValue = scale(currentValueAndUnits, biggerUnits);

           nextValueAndUnits = new MeasurementNumericValueAndUnits(smallerValue, biggerUnits);
       } while (nextValueAndUnits.getValue() > 1.0);

       // next, make the value bigger if it's too small
       int minOrdinal = (lowUnits != null) ? (lowUnits.ordinal() - 1) : -1;

       while (currentValueAndUnits.getValue() < 1.0) {
           int nextOrdinal = currentValueAndUnits.getUnits().ordinal() - 1;
           if (nextOrdinal == minOrdinal) {
               // we could theoretically get smaller, but we don't have any units to represent that
               break;
           }

           MeasurementUnits smallerUnits = MeasurementUnits.values()[nextOrdinal];
           if (smallerUnits.getFamily() != currentValueAndUnits.getUnits().getFamily()) {
               // we're as small as we can get, break out of the loop so we can return
               break;
           }

           Double biggerValue = scale(currentValueAndUnits, smallerUnits);
View Full Code Here

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

            break;
        }

        case THRESHOLD: {
            double value = condition.getThreshold();
            MeasurementUnits units = condition.getMeasurementDefinition().getUnits();
            String formatted = MeasurementConverter.format(value, units, true);

            if (condition.getOption() == null) {
                String metricName = condition.getName();
                String comparator = condition.getComparator();
                str.append(metricName).append(' ').append(comparator).append(' ').append(formatted);
            } else {
                // this is a calltime threshold condition
                String metricName = "";
                if (condition.getMeasurementDefinition() != null) {
                    metricName = condition.getMeasurementDefinition().getDisplayName();
                }

                String limit = condition.getOption(); // MIN, MAX, AVG (never null)
                String comparator = condition.getComparator(); // <, >, =

                if (condition.getName() != null && condition.getName().length() > 0) {
                    String regex = condition.getName();
                    if (isShort) {
                        str.append(AlertI18NFactory.getMessage(
                            AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_THRESHOLD_WITH_EXPR_SHORT, metricName, limit,
                            comparator, formatted, regex));
                    } else {
                        str.append(AlertI18NFactory.getMessage(
                            AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_THRESHOLD_WITH_EXPR, metricName, limit,
                            comparator, formatted, regex));
                    }
                } else {
                    if (isShort) {
                        str.append(AlertI18NFactory.getMessage(
                            AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_THRESHOLD_SHORT, metricName, limit, comparator,
                            formatted));
                    } else {
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_THRESHOLD,
                            metricName, limit, comparator, formatted));
                    }
                }
            }
            break;
        }
        case BASELINE: {
            String metricName = condition.getName();
            String comparator = condition.getComparator();
            double value = condition.getThreshold();
            MeasurementUnits units = MeasurementUnits.PERCENTAGE;
            String percentage = MeasurementConverter.format(value, units, true);
            String baselineThreshold = condition.getOption(); // mean, min, max

            if (isShort) {
                if (baselineThreshold.equalsIgnoreCase("min")) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_BASELINE_MIN_SHORT, metricName,
                        comparator, percentage));
                } else if (baselineThreshold.equalsIgnoreCase("max")) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_BASELINE_MAX_SHORT, metricName,
                        comparator, percentage));
                } else { // mean
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_BASELINE_MEAN_SHORT, metricName,
                        comparator, percentage));
                }
            } else {
                if (baselineThreshold.equalsIgnoreCase("min")) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_BASELINE_MIN, metricName,
                        comparator, percentage));
                } else if (baselineThreshold.equalsIgnoreCase("max")) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_BASELINE_MAX, metricName,
                        comparator, percentage));
                } else { // mean
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_BASELINE_MEAN, metricName,
                        comparator, percentage));
                }
            }
            break;
        }
        case CHANGE: {
            if (condition.getOption() == null) {
                String metricName = condition.getName();
                if (isShort) {
                    str.append(AlertI18NFactory
                        .getMessage(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_SHORT, metricName));
                } else {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CHANGED, metricName));
                }
            } else {
                // this is a calltime change condition
                double value = condition.getThreshold();
                MeasurementUnits units = MeasurementUnits.PERCENTAGE;
                String formatted = MeasurementConverter.format(value, units, true);

                String comparator;
                if ("HI".equalsIgnoreCase(condition.getComparator())) {
                    comparator = AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_GROWS);
                } else if ("LO".equalsIgnoreCase(condition.getComparator())) {
                    comparator = AlertI18NFactory
                        .getMessage(AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_SHRINKS);
                } else { // CH
                    comparator = AlertI18NFactory
                        .getMessage(AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_CHANGES);
                }

                String metricName = "";
                if (condition.getMeasurementDefinition() != null) {
                    metricName = condition.getMeasurementDefinition().getDisplayName();
                }

                String limit = condition.getOption(); // MIN, MAX, AVG (never null)

                if (condition.getName() != null && condition.getName().length() > 0) {
                    String regex = condition.getName();
                    if (isShort) {
                        str.append(AlertI18NFactory.getMessage(
                            AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_WITH_EXPR_SHORT, metricName, limit,
                            comparator, formatted, regex));
                    } else {
                        str.append(AlertI18NFactory.getMessage(
                            AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_WITH_EXPR, metricName, limit,
                            comparator, formatted, regex));
                    }
                } else {
                    if (isShort) {
                        str.append(AlertI18NFactory.getMessage(
                            AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_SHORT, metricName, limit, comparator,
                            formatted));
                    } else {
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE,
                            metricName, limit, comparator, formatted));
                    }
                }
            }
            break;
        }
        case TRAIT: {
            String metricName = condition.getName();
            String expression = condition.getOption();

            if (expression != null && !expression.isEmpty()) {
                if (isShort) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_WITH_EXPR_SHORT,
                        metricName, expression));
                } else {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_WITH_EXPR,
                        metricName, expression));
                }
            } else {
                if (isShort) {
                    str.append(AlertI18NFactory
                        .getMessage(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_SHORT, metricName));
                } else {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CHANGED, metricName));
                }
            }
            break;
        }
        case CONTROL: {
            String opName;
            try {
                Integer resourceTypeId = condition.getAlertDefinition().getResource().getResourceType().getId();
                String operationName = condition.getName();

                OperationDefinition definition = operationManager.getOperationDefinitionByResourceTypeAndName(
                    resourceTypeId, operationName, false);
                opName = definition.getDisplayName();
            } catch (Exception e) {
                opName = condition.getName(); // can't look up the op display name (are we in a test?), just use the op name
            }

            String status = condition.getOption();
            if (isShort) {
                str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_OPERATION_SHORT, opName, status));
            } else {
                str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_OPERATION, opName, status));
            }

            break;
        }
        case RESOURCE_CONFIG: {
            if (isShort) {
                str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_RESOURCECONFIGCHANGE_SHORT));
            } else {
                str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_RESOURCECONFIGCHANGE));
            }
            break;
        }
        case EVENT: {
            String severity = condition.getName();
            if (condition.getOption() != null && condition.getOption().length() > 0) {
                String expression = condition.getOption();
                String regexEventDetails = "", regexSourceLocation = "";
                if (expression.contains(AlertCondition.ADHOC_SEPARATOR)) {
                    String[] regexes = expression.split(AlertCondition.ADHOC_SEPARATOR);
                    if (regexes.length > 0) {
                        regexEventDetails = regexes[0];
                        if (regexes.length > 1) {
                            regexSourceLocation = regexes[1];
                        }
                    }
                } else {
                    regexEventDetails = expression; // old approach -> probably working with db before rhq 4.13
                }

                if (isShort) {
                    if (!regexEventDetails.isEmpty()) {
                        if (!regexSourceLocation.isEmpty()) {
                            str.append(AlertI18NFactory.getMessage(
                                AlertI18NResourceKeys.ALERT_EVENT_WITH_EXPR_WITH_SOURCE_SHORT, severity,
                                regexEventDetails, regexSourceLocation));
                        } else {
                            str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT_WITH_EXPR_SHORT,
                                severity, regexEventDetails));
                        }
                    } else if (!regexSourceLocation.isEmpty()) {
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT_WITH_SOURCE_SHORT,
                            severity, regexSourceLocation));
                    } else {
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT_SHORT, severity));
                    }
                } else {
                    if (!regexEventDetails.isEmpty()) {
                        if (!regexSourceLocation.isEmpty()) {
                            str.append(AlertI18NFactory.getMessage(
                                AlertI18NResourceKeys.ALERT_EVENT_WITH_EXPR_WITH_SOURCE, severity, regexEventDetails,
                                regexSourceLocation));
                        } else {
                            str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT_WITH_EXPR,
                                severity, regexEventDetails));
                        }
                    } else if (!regexSourceLocation.isEmpty()) {
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT_WITH_SOURCE, severity,
                            regexSourceLocation));
                    } else {
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT, severity));
                    }
                }
            } else {
                if (isShort) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT_SHORT, severity));
                } else {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT, severity));
                }
            }
            break;
        }
        case DRIFT: {
            String configNameRegex = condition.getName();
            String pathNameRegex = condition.getOption();
            if (isShort) {
                if (configNameRegex == null || configNameRegex.length() == 0) {
                    if (pathNameRegex == null || pathNameRegex.length() == 0) {
                        // neither a config name regex nor path regex was specified
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_SHORT));
                    } else {
                        // a path name regex was specified, but not a config name regex
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_ONLYPATHS_SHORT,
                            pathNameRegex));
                    }
                } else {
                    if (pathNameRegex == null || pathNameRegex.length() == 0) {
                        // a config name regex was specified, but not a path name regex
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_ONLYCONFIG_SHORT,
                            configNameRegex));
                    } else {
                        // both a config name regex and a path regex was specified
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_CONFIGPATHS_SHORT,
                            pathNameRegex, configNameRegex));
                    }
                }
            } else {
                if (configNameRegex == null || configNameRegex.length() == 0) {
                    if (pathNameRegex == null || pathNameRegex.length() == 0) {
                        // neither a config name regex nor path regex was specified
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT));
                    } else {
                        // a path name regex was specified, but not a config name regex
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_ONLYPATHS,
                            pathNameRegex));
                    }
                } else {
                    if (pathNameRegex == null || pathNameRegex.length() == 0) {
                        // a config name regex was specified, but not a path name regex
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_ONLYCONFIG,
                            configNameRegex));
                    } else {
                        // both a config name regex and a path regex was specified
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_CONFIGPATHS,
                            pathNameRegex, configNameRegex));
                    }
                }
            }
            break;
        }
        case RANGE: {
            String metricName = condition.getName();
            Double loValue = condition.getThreshold();
            String hiValueStr = condition.getOption();

            String loValueFormatted;
            String hiValueFormatted;
            MeasurementUnits units = condition.getMeasurementDefinition().getUnits();
            if (units == null) {
                loValueFormatted = "" + loValue;
                hiValueFormatted = hiValueStr;
            } else {
                loValueFormatted = MeasurementConverter.format(loValue, units, true);
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.