コード例 #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
  private Dampening getCleanDampening(Dampening dampening) throws Exception {
    switch (dampening.getType()) {
      case STRICT:
        return Dampening.forStrict(
            dampening.getTriggerId(), dampening.getTriggerMode(), dampening.getEvalTrueSetting());

      case STRICT_TIME:
        return Dampening.forStrictTime(
            dampening.getTriggerId(), dampening.getTriggerMode(), dampening.getEvalTimeSetting());

      case STRICT_TIMEOUT:
        return Dampening.forStrictTimeout(
            dampening.getTriggerId(), dampening.getTriggerMode(), dampening.getEvalTimeSetting());
      case RELAXED_COUNT:
        return Dampening.forRelaxedCount(
            dampening.getTriggerId(),
            dampening.getTriggerMode(),
            dampening.getEvalTrueSetting(),
            dampening.getEvalTotalSetting());
      case RELAXED_TIME:
        return Dampening.forRelaxedTime(
            dampening.getTriggerId(),
            dampening.getTriggerMode(),
            dampening.getEvalTrueSetting(),
            dampening.getEvalTimeSetting());

      default:
        throw new Exception("Unhandled Dampening Type: " + dampening.toString());
    }
  }