/** * Merges the configuration and update states using parameter entity as a reference. * * @param entity a {@link org.opennms.netmgt.threshd.ThresholdEntity} object. */ public void merge(ThresholdEntity entity) { if (getThresholdConfig().equals(entity.getThresholdConfig()) == false) { sendRearmForTriggeredStates(); getThresholdConfig().merge(entity.getThresholdConfig()); } }
/** * Returns the names of the dataousrces required to evaluate this threshold entity * * @return Collection of the names of datasources */ public Collection<String> getRequiredDatasources() { if (hasThresholds()) { final Set<String> dataSources = new HashSet<String>(); dataSources.addAll(getThresholdConfig().getRequiredDatasources()); dataSources.addAll(getThresholdConfig().getFilterDatasources()); return dataSources; } else { throw new IllegalStateException("No thresholds have been added."); } } /**
/** * Get datasource name * * @return a {@link java.lang.String} object. */ public String getDataSourceExpression() { if (hasThresholds()) { return getThresholdConfig().getDatasourceExpression(); } else { throw new IllegalStateException("No thresholds have been added."); } }
/** * Get datasource Label * * @return a {@link java.lang.String} object. */ public String getDatasourceLabel() { if (hasThresholds()) { return getThresholdConfig().getDsLabel().orElse(null); } else { return null; } }
/** * Get datasource type * * @return a {@link java.lang.String} object. */ public String getDatasourceType() { if (hasThresholds()) { return getThresholdConfig().getDsType(); } else { throw new IllegalStateException("No thresholds have been added."); } }
if (passedThresholdFilters(resourceWrapper, thresholdEntity)) { LOG.info("applyThresholds: Processing threshold {} : {} on resource {}", key, thresholdEntity, resourceWrapper); Collection<String> requiredDatasources = thresholdEntity.getThresholdConfig().getRequiredDatasources(); final Map<String, Double> values = new HashMap<String,Double>(); boolean valueMissing = false; boolean relaxed = thresholdEntity.getThresholdConfig().getBasethresholddef().getRelaxed(); for(final String ds : requiredDatasources) { final Double dsValue = resourceWrapper.getAttributeValue(ds);
/** * 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(); }
dsValue=getThresholdConfig().evaluate(values); } else { throw new IllegalStateException("No thresholds have been added.");
boolean updated = false; for (ThresholdEntity e : thresholdEntitySet) { if (thresholdEntity.getThresholdConfig().equals(e.getThresholdConfig())) { e.merge(thresholdEntity); updated = true; LOG.warn("fillThresholdStateMap: Could not parse threshold expression", e); if (newConfig != null && newConfig.equals(entity.getThresholdConfig())) { found = true; continue;
final List<ResourceFilter> filters = thresholdEntity.getThresholdConfig().getBasethresholddef().getResourceFilters(); if (filters.size() == 0) return true; final FilterOperator operator = thresholdEntity.getThresholdConfig().getBasethresholddef().getFilterOperator(); boolean andResult = true; for (ResourceFilter f : filters) {