Package org.rhq.core.domain.alert

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


        MeasurementDefinition metricDef = createResourceWithMetricSchedule("type-with-trait.xml", "TypeWithTrait");

        AlertDefinition alertDef = createAlertDefinitionWithChangeFromNull(metricDef, resource.getId());

        assert alertDef.getConditions().size() == 1 : "1 alertDef condition should exist";
        AlertCondition condition = alertDef.getConditions().iterator().next();
        int conditionId = condition.getId();

        // re-load the resource so we get the measurement schedule
        final Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
        MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();
View Full Code Here


    private AlertCondition getAlertConditionWithLogs(final int conditionId) {
        return executeInTransaction(false, new TransactionCallbackReturnable<AlertCondition>() {
            @Override
            public AlertCondition execute() throws Exception {
                AlertCondition cond = em.find(AlertCondition.class, conditionId);
                cond.getConditionLogs().size(); // force the load
                return cond;
            }
        });
    }
View Full Code Here

    }

    private AlertDefinition createAlertDefinitionWithTwoConditionsALL(MeasurementDefinition metricDef, int resourceId) {
        // create alert definition with the conditions "metric value > 40 AND metric value < 60"
        HashSet<AlertCondition> conditions = new HashSet<AlertCondition>(2);
        AlertCondition cond1 = new AlertCondition();
        cond1.setCategory(AlertConditionCategory.THRESHOLD);
        cond1.setName(metricDef.getDisplayName());
        cond1.setComparator(">");
        cond1.setThreshold(40.0); // value > 40 threshold
        cond1.setOption(null);
        cond1.setMeasurementDefinition(metricDef);
        conditions.add(cond1);

        AlertCondition cond2 = new AlertCondition();
        cond2.setCategory(AlertConditionCategory.THRESHOLD);
        cond2.setName(metricDef.getDisplayName());
        cond2.setComparator("<");
        cond2.setThreshold(60.0); // value < 60 threshold
        cond2.setOption(null);
        cond2.setMeasurementDefinition(metricDef);
        conditions.add(cond2);

        AlertDefinition alertDefinition = new AlertDefinition();
        alertDefinition.setName("two condition ALL alert");
        alertDefinition.setEnabled(true);
View Full Code Here

        return alertDefinition;
    }

    private AlertDefinition createAlertDefinitionWithDampening(MeasurementDefinition metricDef, int resourceId) {
        AlertCondition cond = new AlertCondition();
        cond.setCategory(AlertConditionCategory.THRESHOLD);
        cond.setName(metricDef.getDisplayName());
        cond.setComparator("=");
        cond.setThreshold(0d); // value = 0 threshold
        cond.setOption(null);
        cond.setMeasurementDefinition(metricDef);

        AlertDampening dampening = new AlertDampening(Category.CONSECUTIVE_COUNT);
        dampening.setValue(3);

        AlertDefinition alertDefinition = new AlertDefinition();
View Full Code Here

    private AlertDefinition createAlertDefinitionWithOneInsideRangeCondition(MeasurementDefinition metricDef,
        int resourceId) {
        // create alert definition with the range condition "metric value between 40...60"
        HashSet<AlertCondition> conditions = new HashSet<AlertCondition>(1);
        AlertCondition cond1 = new AlertCondition();
        cond1.setCategory(AlertConditionCategory.RANGE);
        cond1.setName(metricDef.getDisplayName());
        cond1.setThreshold(40.0); // threshold is always the low value of the range
        cond1.setOption(Double.valueOf(60.0).toString()); // option is a stringified double that is always the high value of the range
        cond1.setComparator("<"); // the value must be inside the range
        cond1.setMeasurementDefinition(metricDef);
        conditions.add(cond1);

        AlertDefinition alertDefinition = new AlertDefinition();
        alertDefinition.setName("one inside-range condition alert");
        alertDefinition.setEnabled(true);
View Full Code Here

        return alertDefinition;
    }

    private AlertDefinition createAlertDefinitionWithChangeFromNull(MeasurementDefinition metricDef, int resourceId) {
        HashSet<AlertCondition> conditions = new HashSet<AlertCondition>(1);
        AlertCondition cond1 = new AlertCondition();
        cond1.setCategory(AlertConditionCategory.TRAIT);
        cond1.setName(metricDef.getDisplayName());
        cond1.setMeasurementDefinition(metricDef);
        conditions.add(cond1);

        AlertDefinition alertDefinition = new AlertDefinition();
        alertDefinition.setName("one trait change from null alert");
        alertDefinition.setEnabled(true);
View Full Code Here

    }

    private AlertDefinition createAlertDefinitionWithAvailChangeCondition(int resourceId,
        AlertConditionOperator condition) {
        HashSet<AlertCondition> conditions = new HashSet<AlertCondition>(1);
        AlertCondition cond1 = new AlertCondition();
        cond1.setCategory(AlertConditionCategory.AVAILABILITY);
        cond1.setName(condition.name());
        cond1.setThreshold(null);
        cond1.setOption(null);
        cond1.setComparator(null);
        cond1.setMeasurementDefinition(null);
        conditions.add(cond1);

        AlertDefinition alertDefinition = new AlertDefinition();
        alertDefinition.setName("avail change: " + condition.name());
        alertDefinition.setEnabled(true);
View Full Code Here

    }

    private AlertDefinition createAlertDefinitionWithAvailDurationCondition(int resourceId, String alertDefName,
        AlertConditionOperator condition, int duration) {
        HashSet<AlertCondition> conditions = new HashSet<AlertCondition>(1);
        AlertCondition cond1 = new AlertCondition();
        cond1.setCategory(AlertConditionCategory.AVAIL_DURATION);
        cond1.setName(condition.name());
        cond1.setThreshold(null);
        cond1.setOption(String.valueOf(duration));
        cond1.setComparator(null);
        cond1.setMeasurementDefinition(null);
        conditions.add(cond1);

        AlertDefinition alertDefinition = new AlertDefinition();
        alertDefinition.setName(alertDefName);
        alertDefinition.setEnabled(true);
View Full Code Here

    private AlertDefinition createAlertDefinitionWithOneOutsideRangeCondition(MeasurementDefinition metricDef,
        int resourceId) {
        // create alert definition with the range condition "metric value outside 40...60"
        HashSet<AlertCondition> conditions = new HashSet<AlertCondition>(1);
        AlertCondition cond1 = new AlertCondition();
        cond1.setCategory(AlertConditionCategory.RANGE);
        cond1.setName(metricDef.getDisplayName());
        cond1.setThreshold(40.0); // threshold is always the low value of the range
        cond1.setOption(Double.valueOf(60.0).toString()); // option is a stringified double that is always the high value of the range
        cond1.setComparator(">"); // the value must be outside the range
        cond1.setMeasurementDefinition(metricDef);
        conditions.add(cond1);

        AlertDefinition alertDefinition = new AlertDefinition();
        alertDefinition.setName("one outside-range condition alert");
        alertDefinition.setEnabled(true);
View Full Code Here

        alertDefinition.setRecoveryId(0);
        alertDefinition.setGroup(testData.getResourceGroup());
        alertDefinition.setEnabled(true);

        // We need a threshold alert condition to recreate the issue in bug 949048
        AlertCondition ac = new AlertCondition();
        ac.setCategory(AlertConditionCategory.THRESHOLD);
        ac.setMeasurementDefinition(testData.getMeasurementDef());
        ac.setComparator("<");
        ac.setThreshold(0.5);
        alertDefinition.addCondition(ac);

        AlertDefinition newAlertDefinition = alertDefinitionManager.createAlertDefinitionInNewTransaction(
            testData.getSubject(), alertDefinition, null, true);
        testData.getAlertDefinitionIds().add(newAlertDefinition.getId());
View Full Code Here

TOP

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

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.