private <M extends Metric> M writeMetricIfNotExists(Metric metric, Class<M> metricClass) { final Metric existing = metrics.putIfAbsent(metric.getId(), metric); if (existing != null) { if (metricClass.isInstance(existing)) { return (M) existing; } else { throw new IllegalArgumentException(metric.getId() + " is already used for a different type of metric: " + metricClass.getSimpleName()); } } return (M) metric; }
private <M extends Metric> M register(Metric registerMetric, Class<M> metricClass) { Metric metric = readMetric(registerMetric.getId(), metricClass); if (metric == null) { return writeMetricIfNotExists(registerMetric, metricClass); } else { return (M) metric; } }
int metricIndex = 0; for (Metric metric : metrics) { MetricId metricId = metric.getId(); BValue metricValue = null; String metricType = null;
MetricId metricId = metric.getId(); if (metric instanceof Counter) { StructureTypeInfo counterStructInfo = observePackage.getStructInfo(COUNTER);