public static MetricType getByIdentifier(String identifier) { for (int i = 0; i < MetricType.values().length; i++) { MetricType metricType = MetricType.values()[i]; if (metricType.getIdentifier().equals(identifier)) { return metricType; } } return null; }
/** * Computes totals for each of the {@link MetricType}s. * * @return aggregates for each global metric type. * @throws StorageException if there was a problem fetching tasks from storage. */ public List<GlobalMetric> computeConsumptionTotals() throws StorageException { List<GlobalMetric> counts = FluentIterable.from(Arrays.asList(MetricType.values())) .transform(TO_GLOBAL_METRIC) .toList(); for (ITaskConfig task : getTasks(Query.unscoped().active())) { for (GlobalMetric count : counts) { count.accumulate(task); } } return counts; }
private void processMetricItem(int minute, ProductLine productLine, String metricKey) { for (MetricType type : MetricType.values()) { String productlineName = productLine.getId(); AlertResultEntity alertResult = computeAlertInfo(minute, productlineName, metricKey, type); if (alertResult != null && alertResult.isTriggered()) { String metricTitle = buildMetricTitle(metricKey); String mailTitle = getAlertConfig().buildMailTitle(productLine.getTitle(), metricTitle); m_alertInfo.addAlertInfo(metricKey, new Date().getTime()); storeAlert(productlineName, metricTitle, mailTitle, alertResult); sendAlertInfo(productLine, mailTitle, alertResult.getContent(), alertResult.getAlertType()); } } }