public void setThresholdConfig(BaseThresholdDefConfigWrapper thresholdConfig) { Assert.notNull(thresholdConfig.getType(), "threshold must have a 'type' value set"); Assert.notNull(thresholdConfig.getDatasourceExpression(), "threshold must have a 'ds-name' value set"); Assert.notNull(thresholdConfig.getDsType(), "threshold must have a 'ds-type' value set"); Assert.isTrue(thresholdConfig.hasValue(), "threshold must have a 'value' value set"); Assert.isTrue(thresholdConfig.hasRearm(), "threshold must have a 'rearm' value set"); Assert.isTrue(thresholdConfig.hasTrigger(), "threshold must have a 'trigger' value set"); Assert.isTrue(TYPE.equals(thresholdConfig.getType()), "threshold for ds-name '" + thresholdConfig.getDatasourceExpression() + "' has type of '" + thresholdConfig.getType() + "', but this evaluator only supports thresholds with a 'type' value of '" + TYPE + "'"); Assert.isTrue(!Double.isNaN(thresholdConfig.getValue()), "threshold must have a 'value' value that is a number"); Assert.isTrue(thresholdConfig.getValue() != Double.POSITIVE_INFINITY && thresholdConfig.getValue() != Double.NEGATIVE_INFINITY, "threshold must have a 'value' value that is not positive or negative infinity"); Assert.isTrue(thresholdConfig.getValue() != 1.0, "threshold must not be unity (1.0)"); m_thresholdConfig = thresholdConfig; setMultiplier(thresholdConfig.getValue()); }
private boolean wasTriggered(double dsValue) { // Test Code // if(Double.valueOf(getPreviousTriggeringSample()).isNaN()) { // log().debug(TYPE + " threshold evaluate trigger, sample value="+dsValue); // return true; // } if(Double.valueOf(dsValue).isNaN()) return false; if(Double.valueOf(getLastSample()).isNaN()) return false; double threshold = Math.abs(getLastSample() - dsValue); // Test Code // log().debug(TYPE + " threshold evaluate trigger, sample value="+dsValue+",prev value="+getLastSample()+",thresh="+threshold+",trigger="+getThresholdConfig().getValue()); return threshold >= getThresholdConfig().getValue(); }
public void setThresholdConfig(BaseThresholdDefConfigWrapper thresholdConfig) { Assert.notNull(thresholdConfig.getType(), "threshold must have a 'type' value set"); Assert.notNull(thresholdConfig.getDatasourceExpression(), "threshold must have a 'ds-name' value set"); Assert.notNull(thresholdConfig.getDsType(), "threshold must have a 'ds-type' value set"); Assert.isTrue(thresholdConfig.hasValue(), "threshold must have a 'value' value set"); Assert.isTrue(thresholdConfig.hasRearm(), "threshold must have a 'rearm' value set"); Assert.isTrue(thresholdConfig.hasTrigger(), "threshold must have a 'trigger' value set"); Assert.isTrue(TYPE.equals(thresholdConfig.getType()), "threshold for ds-name '" + thresholdConfig.getDatasourceExpression() + "' has type of '" + thresholdConfig.getType() + "', but this evaluator only supports thresholds with a 'type' value of '" + TYPE + "'"); Assert.isTrue(!Double.isNaN(thresholdConfig.getValue()), "threshold must have a 'value' value that is a number"); Assert.isTrue(thresholdConfig.getValue() != Double.POSITIVE_INFINITY && thresholdConfig.getValue() != Double.NEGATIVE_INFINITY, "threshold must have a 'value' value that is not positive or negative infinity"); Assert.isTrue(thresholdConfig.getValue() != 0.0, "threshold must not be 0 for absolute change"); m_thresholdConfig = thresholdConfig; setChange(thresholdConfig.getValue()); }
public void setThresholdConfig(BaseThresholdDefConfigWrapper thresholdConfig) { Assert.notNull(thresholdConfig.getType(), "threshold must have a 'type' value set"); Assert.notNull(thresholdConfig.getDatasourceExpression(), "threshold must have a 'ds-name' value set"); Assert.notNull(thresholdConfig.getDsType(), "threshold must have a 'ds-type' value set"); Assert.isTrue(thresholdConfig.hasValue(), "threshold must have a 'value' value set"); Assert.isTrue(thresholdConfig.hasRearm(), "threshold must have a 'rearm' value set"); Assert.isTrue(thresholdConfig.hasTrigger(), "threshold must have a 'trigger' value set"); Assert.isTrue(TYPE.equals(thresholdConfig.getType()), "threshold for ds-name '" + thresholdConfig.getDatasourceExpression() + "' has type of '" + thresholdConfig.getType() + "', but this evaluator only supports thresholds with a 'type' value of '" + TYPE + "'"); Assert.isTrue(!Double.isNaN(thresholdConfig.getValue()), "threshold must have a 'value' value that is a number"); Assert.isTrue(thresholdConfig.getValue() != Double.POSITIVE_INFINITY && thresholdConfig.getValue() != Double.NEGATIVE_INFINITY, "threshold must have a 'value' value that is not positive or negative infinity"); m_thresholdConfig = thresholdConfig; }
private Event createBasicEvent(String uei, Date date, double dsValue, CollectionResourceWrapper resource) { Map<String,String> params = new HashMap<String,String>(); params.put("previousValue", formatValue(getPreviousTriggeringSample())); params.put("multiplier", Double.toString(getThresholdConfig().getValue())); // params.put("trigger", Integer.toString(getThresholdConfig().getTrigger())); // params.put("rearm", Double.toString(getThresholdConfig().getRearm())); return createBasicEvent(uei, date, dsValue, resource, params); }
private Event createBasicEvent(String uei, Date date, double dsValue, CollectionResourceWrapper resource) { Map<String,String> params = new HashMap<String,String>(); params.put("threshold", Double.toString(getThresholdConfig().getValue())); params.put("trigger", Integer.toString(getThresholdConfig().getTrigger())); params.put("rearm", Double.toString(getThresholdConfig().getRearm())); return createBasicEvent(uei, date, dsValue, resource, params); }
private Event createBasicEvent(String uei, Date date, double dsValue, CollectionResourceWrapper resource) { Map<String,String> params = new HashMap<String,String>(); params.put("previousValue", formatValue(getPreviousTriggeringSample())); params.put("changeThreshold", Double.toString(getThresholdConfig().getValue())); params.put("trigger", Integer.toString(getThresholdConfig().getTrigger())); return createBasicEvent(uei, date, dsValue, resource, params); }
private Event createBasicEvent(String uei, Date date, double dsValue, CollectionResourceWrapper resource) { Map<String,String> params = new HashMap<String,String>(); params.put("previousValue", formatValue(getPreviousTriggeringSample())); params.put("threshold", Double.toString(getThresholdConfig().getValue())); params.put("trigger", Integer.toString(getThresholdConfig().getTrigger())); // params.put("rearm", Double.toString(getThresholdConfig().getRearm())); return createBasicEvent(uei, date, dsValue, resource, params); }
protected boolean isThresholdExceeded(double dsValue) { if (ThresholdType.HIGH.equals(getThresholdConfig().getType())) { return dsValue >= getThresholdConfig().getValue(); } else if (ThresholdType.LOW.equals(getThresholdConfig().getType())) { return dsValue <= getThresholdConfig().getValue(); } else { throw new IllegalStateException("This thresholding strategy can only be used for thresholding types of 'high' and 'low'."); } }
/** * This method is responsible for returning a String object which represents * the content of this ThresholdEntity. Primarily used for debugging * purposes. * * @return String which represents the content of this ThresholdEntity */ @Override public String toString() { if (!hasThresholds()) { return ""; } final StringBuilder buffer = new StringBuilder("{"); buffer.append("evaluator=").append(this.getThresholdConfig().getType()); buffer.append(", dsName=").append(this.getDataSourceExpression()); buffer.append(", dsType=").append(this.getDatasourceType()); buffer.append(", evaluators=["); for (ThresholdEvaluatorState item : getThresholdEvaluatorStates(null)) { buffer.append("{ds=").append(item.getThresholdConfig().getDatasourceExpression()); buffer.append(", value=").append(item.getThresholdConfig().getValue()); buffer.append(", rearm=").append(item.getThresholdConfig().getRearm()); buffer.append(", trigger=").append(item.getThresholdConfig().getTrigger()); buffer.append("}"); } buffer.append("]}"); return buffer.toString(); }
/** {@inheritDoc} */ @Override public boolean equals(final Object obj) { if ( this == obj ) { return true; } if (obj instanceof BaseThresholdDefConfigWrapper) { final BaseThresholdDefConfigWrapper that = (BaseThresholdDefConfigWrapper)obj; return Objects.equals(this.getType(), that.getType()) && Objects.equals(this.getDsType(), that.getDsType()) && Objects.equals(this.getDatasourceExpression(), that.getDatasourceExpression()) && Objects.equals(this.getDsLabel(), that.getDsLabel()) && Objects.equals(this.getTriggeredUEI(), that.getTriggeredUEI()) && Objects.equals(this.getRearmedUEI(), that.getRearmedUEI()) && Objects.equals(this.getValue(), that.getValue()) && Objects.equals(this.getRearm(), that.getRearm()) && Objects.equals(this.getTrigger(), that.getTrigger()) && Objects.equals(this.getBasethresholddef().getFilterOperator(), that.getBasethresholddef().getFilterOperator()) && Objects.equals(this.getBasethresholddef().getRelaxed(), that.getBasethresholddef().getRelaxed()) && Objects.equals(this.getBasethresholddef().getResourceFilters(), that.getBasethresholddef().getResourceFilters()); } return false; }