private synchronized void updateMetrics(int numMissingTopics, int numMismatchedTopics, int numMismatchedTopicPartitions, Map<String, Integer> misMatchedPartitionNumberTopics) { _numMissingTopics.inc(numMissingTopics - _numMissingTopics.getCount()); _numMismatchedTopics.inc(numMismatchedTopics - _numMismatchedTopics.getCount()); _numMismatchedTopicPartitions .inc(numMismatchedTopicPartitions - _numMismatchedTopicPartitions.getCount()); for (String topic : misMatchedPartitionNumberTopics.keySet()) { if (!_mismatchedTopicPartitionsCounter.containsKey(topic)) { Counter topicPartitionCounter = new Counter(); try { HelixKafkaMirrorMakerMetricsReporter.get().getRegistry().register( getMismatchedTopicMetricName(topic), topicPartitionCounter); } catch (Exception e) { LOGGER.error("Error registering metrics!", e); } _mismatchedTopicPartitionsCounter.put(topic, topicPartitionCounter); } } for (String topic : _mismatchedTopicPartitionsCounter.keySet()) { Counter counter = _mismatchedTopicPartitionsCounter.get(topic); if (!misMatchedPartitionNumberTopics.containsKey(topic)) { counter.dec(counter.getCount()); } else { counter.inc(misMatchedPartitionNumberTopics.get(topic) - counter.getCount()); } } }
private synchronized void updateMetrics(int numMissingTopics, int numMismatchedTopics, int numMismatchedTopicPartitions, Map<String, Integer> misMatchedPartitionNumberTopics) { _numMissingTopics.inc(numMissingTopics - _numMissingTopics.getCount()); _numMismatchedTopics.inc(numMismatchedTopics - _numMismatchedTopics.getCount()); _numMismatchedTopicPartitions .inc(numMismatchedTopicPartitions - _numMismatchedTopicPartitions.getCount()); for (String topic : misMatchedPartitionNumberTopics.keySet()) { if (!_mismatchedTopicPartitionsCounter.containsKey(topic)) { Counter topicPartitionCounter = new Counter(); try { HelixKafkaMirrorMakerMetricsReporter.get().getRegistry().register( getMismatchedTopicMetricName(topic), topicPartitionCounter); } catch (Exception e) { LOGGER.error("Error registering metrics!", e); } _mismatchedTopicPartitionsCounter.put(topic, topicPartitionCounter); } } for (String topic : _mismatchedTopicPartitionsCounter.keySet()) { Counter counter = _mismatchedTopicPartitionsCounter.get(topic); if (!misMatchedPartitionNumberTopics.containsKey(topic)) { counter.dec(counter.getCount()); } else { counter.inc(misMatchedPartitionNumberTopics.get(topic) - counter.getCount()); } } }