コード例 #1
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;
  }
コード例 #2
0
 public RateConditionEval(RateCondition condition, Data data, Data previousData) {
   super(
       Type.RATE,
       condition.match(
           data.getTimestamp(),
           Double.valueOf(data.getValue()),
           previousData.getTimestamp(),
           Double.valueOf(previousData.getValue())),
       data.getTimestamp(),
       data.getContext());
   this.condition = condition;
   this.time = data.getTimestamp();
   this.value = Double.valueOf(data.getValue());
   this.previousTime = previousData.getTimestamp();
   this.previousValue = Double.valueOf(previousData.getValue());
   this.rate = condition.getRate(this.time, this.value, this.previousTime, this.previousValue);
 }
コード例 #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;
  }