Package org.rhq.core.domain.measurement

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


        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_THRESHOLD_SHORT, "CT Prop", "MAX", ">", TWELVE_DOT_5_B);
    }

    public void testPrettyPrintBASELINE() {
        MeasurementDefinition md = createDynamicMeasurementDefinition();
        AlertCondition condition = createCondition(AlertConditionCategory.BASELINE, md.getDisplayName(), ">", 0.10d,
            "mean", md);
        pretty = getPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_BASELINE_MEAN, "Foo Prop", ">", TEN_PERCENT);
        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_BASELINE_MEAN_SHORT, "Foo Prop", ">", TEN_PERCENT);

        condition = createCondition(AlertConditionCategory.BASELINE, md.getDisplayName(), ">", 0.10d, "min", md);
        pretty = getPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_BASELINE_MIN, "Foo Prop", ">", TEN_PERCENT);
        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_BASELINE_MIN_SHORT, "Foo Prop", ">", TEN_PERCENT);

        condition = createCondition(AlertConditionCategory.BASELINE, md.getDisplayName(), ">", 0.10d, "max", md);
        pretty = getPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_BASELINE_MAX, "Foo Prop", ">", TEN_PERCENT);
        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_BASELINE_MAX_SHORT, "Foo Prop", ">", TEN_PERCENT);
    }
View Full Code Here


        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_BASELINE_MAX_SHORT, "Foo Prop", ">", TEN_PERCENT);
    }

    public void testPrettyPrintCHANGE() {
        MeasurementDefinition md = createDynamicMeasurementDefinition();
        AlertCondition condition = createCondition(AlertConditionCategory.CHANGE, md.getDisplayName(), null, null,
            null, md);
        pretty = getPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_METRIC_CHANGED, "Foo Prop");
        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_SHORT, "Foo Prop");
View Full Code Here

        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_SHORT, "Foo Prop");
    }

    public void testPrettyPrintCHANGE_Calltime() {
        MeasurementDefinition md = createCalltimeMeasurementDefinition();
        String regex = "some.*(reg)?ex$"; // this is the "name" of the condition

        AlertCondition condition = createCondition(AlertConditionCategory.CHANGE, regex, "LO", 0.10d, "MIN", md);
        pretty = getPrettyAlertConditionString(condition);
        String msg = AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_SHRINKS);
View Full Code Here

        pretty = getShortPrettyAlertConditionString(condition);
        assert String.format(refs, msg, 10.0f).equals(pretty) : pretty + " \n<=> " + String.format(refs, msg, 10.0f);
    }

    public void testPrettyPrintTRAIT() {
        MeasurementDefinition md = createTraitMeasurementDefinition();
        AlertCondition condition = createCondition(AlertConditionCategory.TRAIT, md.getDisplayName(), null, null, null,
            md);
        pretty = getPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_METRIC_CHANGED, "Blah Trait");
        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_SHORT, "Blah Trait");

        condition = createCondition(AlertConditionCategory.TRAIT, md.getDisplayName(), null, null, "RegexPattern", md);
        pretty = getPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_WITH_EXPR, "Blah Trait", "RegexPattern");
        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_WITH_EXPR_SHORT, "Blah Trait", "RegexPattern");
    }
View Full Code Here

        pretty = getShortPrettyAlertConditionString(condition);
        assert "Drift!".equals(pretty) : pretty;
    }

    public void testPrettyPrintRANGE() {
        MeasurementDefinition md = createDynamicMeasurementDefinition();
        AlertCondition condition = createCondition(AlertConditionCategory.RANGE, md.getDisplayName(), "<=", 1.0,
            "22.2", md);
        pretty = getPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_RANGE_INSIDE_INCL, "Foo Prop", String.format("%1.1fB", 1d),
            String.format("%2.1fB", 22.2d));
        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_RANGE_INSIDE_INCL_SHORT, "Foo Prop", String.format("%1.1fB", 1d),
            String.format("%2.1fB", 22.2d));

        condition = createCondition(AlertConditionCategory.RANGE, md.getDisplayName(), ">=", 1.0, "22.2", md);
        pretty = getPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_RANGE_OUTSIDE_INCL, "Foo Prop", String.format("%1.1fB", 1d),
            String.format("%2.1fB", 22.2d));
        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_RANGE_OUTSIDE_INCL_SHORT, "Foo Prop", String.format("%1.1fB", 1d),
            String.format("%2.1fB", 22.2d));

        condition = createCondition(AlertConditionCategory.RANGE, md.getDisplayName(), "<", 1.0, "22.2", md);
        pretty = getPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_RANGE_INSIDE_EXCL, "Foo Prop", String.format("%1.1fB", 1d),
            String.format("%2.1fB", 22.2d));
        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_RANGE_INSIDE_EXCL_SHORT, "Foo Prop", String.format("%1.1fB", 1d),
            String.format("%2.1fB", 22.2d));

        condition = createCondition(AlertConditionCategory.RANGE, md.getDisplayName(), ">", 1.0, "22.2", md);
        pretty = getPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_RANGE_OUTSIDE_EXCL, "Foo Prop", String.format("%1.1fB", 1d),
            String.format("%2.1fB", 22.2d));
        pretty = getShortPrettyAlertConditionString(condition);
        check(AlertI18NResourceKeys.ALERT_RANGE_OUTSIDE_EXCL_SHORT, "Foo Prop", String.format("%1.1fB", 1d),
View Full Code Here

        return s;
    }

    private MeasurementDefinition createDynamicMeasurementDefinition() {
        ResourceType resourceType = new ResourceType("testType", "testPlugin", ResourceCategory.PLATFORM, null);
        MeasurementDefinition md = new MeasurementDefinition(resourceType, "fooMetric");
        md.setDataType(DataType.MEASUREMENT);
        md.setDisplayName("Foo Prop");
        md.setMeasurementType(NumericType.DYNAMIC);
        md.setRawNumericType(NumericType.DYNAMIC);
        md.setUnits(MeasurementUnits.BYTES);
        return md;
    }
View Full Code Here

            Configuration resourceConfiguration = new Configuration();
            resourceConfiguration.put(new PropertySimple(BUNDLE_CONFIG_CONTEXT_VALUE_RC, BUNDLE_CONFIG_LOCATION_RC));
            serverRC.setResourceConfiguration(resourceConfiguration);

            MeasurementDefinition definition = new MeasurementDefinition(serverTypeMT, BUNDLE_CONFIG_CONTEXT_VALUE_MT);
            definition.setDataType(DataType.TRAIT);
            definition.setId(123);
            MeasurementSchedule schedule = new MeasurementSchedule(definition, serverMT);
            schedule.setId(123123);
            MeasurementScheduleRequest scheduleRequest = new MeasurementScheduleRequest(schedule);
            Set<MeasurementScheduleRequest> schedules = new HashSet<MeasurementScheduleRequest>(1);
            schedules.add(scheduleRequest);
View Full Code Here

        return md;
    }

    private MeasurementDefinition createCalltimeMeasurementDefinition() {
        ResourceType resourceType = new ResourceType("testType", "testPlugin", ResourceCategory.PLATFORM, null);
        MeasurementDefinition md = new MeasurementDefinition(resourceType, "ctMetric");
        md.setDataType(DataType.CALLTIME);
        md.setDisplayName("CT Prop");
        md.setMeasurementType(NumericType.DYNAMIC);
        md.setRawNumericType(NumericType.DYNAMIC);
        md.setUnits(MeasurementUnits.BYTES);
        md.setDestinationType("/wot gorilla");
        return md;
    }
View Full Code Here

        return md;
    }

    private MeasurementDefinition createTraitMeasurementDefinition() {
        ResourceType resourceType = new ResourceType("testType", "testPlugin", ResourceCategory.PLATFORM, null);
        MeasurementDefinition md = new MeasurementDefinition(resourceType, "traitMetric");
        md.setDataType(DataType.TRAIT);
        md.setDisplayName("Blah Trait");
        md.setUnits(MeasurementUnits.BYTES);
        return md;
    }
View Full Code Here

                break;
            }

            case THRESHOLD: {
                if (!calltimeCategory) {
                    MeasurementDefinition measDef = getMeasurementDefinition(form
                        .getValueAsString(THRESHOLD_METRIC_ITEMNAME));
                    newCondition.setName(measDef.getDisplayName());
                    newCondition.setThreshold(getMeasurementValue(measDef,
                        form.getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME)));
                    newCondition.setComparator(form.getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME));
                    newCondition.setOption(null);
                    newCondition.setMeasurementDefinition(measDef);
                } else {
                    MeasurementDefinition measDef = getMeasurementDefinition(form
                        .getValueAsString(CALLTIME_THRESHOLD_METRIC_ITEMNAME));
                    newCondition.setName(form.getValueAsString(CALLTIME_THRESHOLD_REGEX_ITEMNAME));
                    newCondition.setThreshold(getMeasurementValue(measDef,
                        form.getValueAsString(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME)));
                    newCondition.setComparator(form.getValueAsString(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME));
                    newCondition.setOption(form.getValueAsString(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME));
                    newCondition.setMeasurementDefinition(measDef);
                }
                break;
            }

            case BASELINE: {
                MeasurementDefinition measDef = getMeasurementDefinition(form
                    .getValueAsString(BASELINE_METRIC_ITEMNAME));
                newCondition.setName(measDef.getDisplayName());
                newCondition.setThreshold(getMeasurementValueByUnits(MeasurementUnits.PERCENTAGE,
                    form.getValueAsString(BASELINE_PERCENTAGE_ITEMNAME)));
                newCondition.setComparator(form.getValueAsString(BASELINE_COMPARATOR_ITEMNAME));
                newCondition.setOption(form.getValueAsString(BASELINE_SELECTION_ITEMNAME));
                newCondition.setMeasurementDefinition(measDef);
                break;
            }

            case CHANGE: {
                if (!calltimeCategory) {
                    MeasurementDefinition measDef = getMeasurementDefinition(form
                        .getValueAsString(CHANGE_METRIC_ITEMNAME));
                    newCondition.setName(measDef.getDisplayName());
                    newCondition.setComparator(null);
                    newCondition.setThreshold(null);
                    newCondition.setOption(null);
                    newCondition.setMeasurementDefinition(measDef);
                } else {
                    MeasurementDefinition measDef = getMeasurementDefinition(form
                        .getValueAsString(CALLTIME_CHANGE_METRIC_ITEMNAME));
                    newCondition.setName(form.getValueAsString(CALLTIME_CHANGE_REGEX_ITEMNAME));
                    newCondition.setThreshold(getMeasurementValueByUnits(MeasurementUnits.PERCENTAGE,
                        form.getValueAsString(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME)));
                    newCondition.setComparator(form.getValueAsString(CALLTIME_CHANGE_COMPARATOR_ITEMNAME));
                    newCondition.setOption(form.getValueAsString(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME));
                    newCondition.setMeasurementDefinition(measDef);
                }
                break;
            }

            case TRAIT: {
                MeasurementDefinition measDef = getMeasurementDefinition(form.getValueAsString(TRAIT_METRIC_ITEMNAME));
                newCondition.setName(measDef.getDisplayName());
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(form.getValueAsString(TRAIT_REGEX_ITEMNAME));
                newCondition.setMeasurementDefinition(measDef);
                break;
            }

            case CONTROL: {
                newCondition.setName(form.getValueAsString(OPERATION_NAME_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(form.getValueAsString(OPERATION_RESULTS_ITEMNAME));
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case EVENT: {
                newCondition.setName(form.getValueAsString(EVENT_SEVERITY_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                Object regex1 = form.getValue(EVENT_REGEX_ITEMNAME);
                Object regex2 = form.getValue(EVENT_SOURCE_PATH_REGEX_ITEMNAME);
                newCondition.setOption((regex1 == null ? "" : regex1) + AlertCondition.ADHOC_SEPARATOR
                    + (regex2 == null ? "" : regex2));
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case RESOURCE_CONFIG: {
                newCondition.setName(null);
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(null);
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case DRIFT: {
                newCondition.setName(form.getValueAsString(DRIFT_DEFNAME_REGEX_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(form.getValueAsString(DRIFT_PATHNAME_REGEX_ITEMNAME));
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case RANGE: {
                MeasurementDefinition measDef = getMeasurementDefinition(form.getValueAsString(RANGE_METRIC_ITEMNAME));
                newCondition.setName(measDef.getDisplayName());
                newCondition.setThreshold(getMeasurementValue(measDef,
                    form.getValueAsString(RANGE_LO_ABSVALUE_ITEMNAME)));
                newCondition.setComparator(form.getValueAsString(RANGE_COMPARATOR_ITEMNAME));
                newCondition.setOption(getMeasurementValue(measDef, form.getValueAsString(RANGE_HI_ABSVALUE_ITEMNAME))
                    .toString());
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.measurement.MeasurementDefinition

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.