Beispiel #1
0
 public Object getValue() {
   try {
     Set<MeasurementData> d =
         remoteClient
             .getMeasurementDataManager()
             .findLiveData(
                 remoteClient.getSubject(), resourceId, new int[] {definition.getId()});
     MeasurementData data = d.iterator().next();
     return data.getValue();
   } catch (Exception e) {
     return "?";
   }
 }
  public AlertConditionCacheStats checkConditions(MeasurementData... measurementData) {
    if ((measurementData == null) || (measurementData.length == 0)) {
      return new AlertConditionCacheStats();
    }

    AlertConditionCacheStats stats = new AlertConditionCacheStats();
    try {
      for (MeasurementData datum : measurementData) {
        int scheduleId = datum.getScheduleId();

        if (datum instanceof MeasurementDataNumeric) {
          List<? extends NumericDoubleCacheElement> conditionCacheElements =
              lookupMeasurementDataCacheElements(scheduleId);

          Double providedValue = ((MeasurementDataNumeric) datum).getValue();

          processCacheElements(conditionCacheElements, providedValue, datum.getTimestamp(), stats);
        } else if (datum instanceof MeasurementDataTrait) {
          List<MeasurementTraitCacheElement> cacheElements =
              lookupMeasurementTraitCacheElements(scheduleId);

          processCacheElements(
              cacheElements,
              ((MeasurementDataTrait) datum).getValue(),
              datum.getTimestamp(),
              stats);
        } else {
          log.error(
              getClass().getSimpleName()
                  + " does not support "
                  + "checking conditions against "
                  + datum.getClass().getSimpleName()
                  + " types");
        }
      }

      AlertConditionCacheMonitor.getMBean().incrementMeasurementCacheElementMatches(stats.matched);
      AlertConditionCacheMonitor.getMBean().incrementMeasurementProcessingTime(stats.getAge());
      if (log.isDebugEnabled())
        log.debug("Check Measurements[size=" + measurementData.length + "] - " + stats);
    } catch (Throwable t) {
      // don't let any exceptions bubble up to the calling SLSB layer
      log.error("Error during measurement data cache processing for agent[id=" + agentId + "]", t);
    }
    return stats;
  }