package com.onaro.sanscreen.client.view.policy; import com.netapp.oci.serviceassurance.interfaces.data.PolicyCondition; import com.netapp.oci.serviceassurance.interfaces.data.ThresholdType; import com.netapp.sanscreen.server.product.shared.serviceassurance.interfaces.data.PerformanceViolation; import com.onaro.performance.interfaces.data.MetricType; /** * Immutable class that defines a (non-SAN Path) threshold. It can be * thought of as a version of the server's performance PolicyCondition, * with server text replaced with client-composed display text. */ public final class Threshold { private final ThresholdType thresholdType; private final MetricType metricType; private final Double value; /** * Gets a {@link Threshold} from a performance violation. * @param violation a {@link PerformanceViolation} * @return */ public static Threshold getFromViolation(PerformanceViolation violation) { PolicyCondition condition = violation.getPolicyCondition(); MetricType metricType = MetricType.valueOf(violation.getObjectType(), condition.getCounterName()); ThresholdType thresholdType = condition.getThresholdType(); Double value = condition.getThresholdValue(); return new Threshold(thresholdType, metricType, value); } /** * Creates a {@link Threshold}. * @param thresholdType {@link ThresholdType} * @param metricType {@link MetricType} * @param value */ public Threshold (ThresholdType thresholdType, MetricType metricType, Double value) { this.thresholdType = thresholdType; this.metricType = metricType; this.value = value; } /** * Gets the threshold type: MIN or MAX * @return the {@link ThresholdType} */ public ThresholdType getThresholdType() { return thresholdType; } /** * Gets the threshold metric: display name and units (if any) * @return the {@link MetricType} */ public MetricType getMetricType() { return metricType; } /** * Gets the threshold value * @return the value */ public Double getValue() { return value; } }