public Collection detect()

in src/main/java/com/microsoft/dhalion/detectors/ResourceAvailabilityDetector.java [57:86]


  public Collection<Symptom> detect(Collection<Measurement> measurements) {
    Instant now = context.checkpoint();
    Instant previous = context.previousCheckpoint();

    MeasurementsTable filteredMeasurements = context.measurements().between(previous, now);
    if (filteredMeasurements.size() == 0) {
      LOG.fine("Did not find any measurements to evaluate resource availability");
      return Collections.emptyList();
    }

    Collection<String> assignments = new ArrayList<>();
    Collection<String> instances = filteredMeasurements.uniqueInstances();
    for (String instance : instances) {
      double totalFree = aggregate(filteredMeasurements.instance(instance).type(freeMetric));
      double totalDemand = aggregate(filteredMeasurements.instance(instance).type(demandMetric));
      if (evaluate(instance, totalFree, totalDemand)) {
        assignments.add(instance);
      }
    }

    if (assignments.isEmpty()) {
      return Collections.emptyList();
    }

    Symptom symptom = new Symptom(symptomType, now, assignments);
    if (LOG.isLoggable(Level.FINE)) {
      LOG.fine(String.format("Symptom (%s) created for %s", symptom, toString()));
    }
    return Collections.singletonList(symptom);
  }