コード例 #1
0
  static {
    Map<String, String> context = new HashMap<>();
    context.put("resourceType", "URL");
    context.put("resourceName", "http://www.jboss.org");

    String triggerId = "jboss-url-response-time-trigger";
    String triggerDescription = "Response Time for http://www.jboss.org";
    String dataId = "jboss-url-response-time-data-id";

    trigger = new Trigger(TEST_TENANT, triggerId, triggerDescription, context);

    firingCondition =
        new ThresholdCondition(
            trigger.getId(), Mode.FIRING, dataId, ThresholdCondition.Operator.GT, 1000d);
    firingCondition.setTenantId(TEST_TENANT);
    firingCondition.getContext().put("description", "Response Time");
    firingCondition.getContext().put("unit", "ms");

    autoResolveCondition =
        new ThresholdCondition(
            trigger.getId(), Mode.AUTORESOLVE, dataId, ThresholdCondition.Operator.LTE, 1000d);
    autoResolveCondition.setTenantId(TEST_TENANT);
    autoResolveCondition.getContext().put("description", "Response Time");
    autoResolveCondition.getContext().put("unit", "ms");

    firingDampening = Dampening.forStrictTimeout(trigger.getId(), Mode.FIRING, 10000);
    firingDampening.setTenantId(TEST_TENANT);
  }
コード例 #2
0
  public static Alert getOpenAlert() {

    List<Set<ConditionEval>> satisfyingEvals = new ArrayList<>();

    Data rtBadData1 =
        Data.forNumeric(firingCondition.getDataId(), System.currentTimeMillis(), 1900d);
    ThresholdConditionEval eval1 = new ThresholdConditionEval(firingCondition, rtBadData1);

    Set<ConditionEval> evalSet1 = new HashSet<>();
    evalSet1.add(eval1);
    satisfyingEvals.add(evalSet1);

    // 5 seconds later
    Data rtBadData2 =
        Data.forNumeric(firingCondition.getDataId(), System.currentTimeMillis() + 5000, 1800d);
    ThresholdConditionEval eval2 = new ThresholdConditionEval(firingCondition, rtBadData2);

    Set<ConditionEval> evalSet2 = new HashSet<>();
    evalSet2.add(eval2);
    satisfyingEvals.add(evalSet2);

    Alert openAlert = new Alert(trigger.getTenantId(), trigger, firingDampening, satisfyingEvals);

    return openAlert;
  }
コード例 #3
0
  public static Alert resolveAlert(Alert unresolvedAlert) {
    List<Set<ConditionEval>> resolvedEvals = new ArrayList<>();

    Data rtGoodData =
        Data.forNumeric(autoResolveCondition.getDataId(), System.currentTimeMillis() + 20000, 900d);
    ThresholdConditionEval eval1 = new ThresholdConditionEval(autoResolveCondition, rtGoodData);
    Set<ConditionEval> evalSet1 = new HashSet<>();
    evalSet1.add(eval1);
    resolvedEvals.add(evalSet1);

    unresolvedAlert.setResolvedEvalSets(resolvedEvals);
    unresolvedAlert.setStatus(Alert.Status.RESOLVED);
    unresolvedAlert.setResolvedBy(RESOLVED_BY);
    unresolvedAlert.addNote(RESOLVED_BY, RESOLVED_NOTES);
    unresolvedAlert.setResolvedTime(System.currentTimeMillis());

    return unresolvedAlert;
  }