Skip to content

Commit

Permalink
[#9176] Improved code so that connection object of pinot is reused in…
Browse files Browse the repository at this point in the history
… collector
  • Loading branch information
minwoo-jung committed Sep 22, 2022
1 parent 6904b75 commit bf45093
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,8 @@ public PinotMetricTagDao(SqlSessionTemplate sqlPinotSessionTemplate,

@Override
public void insertMetricTag(MetricTag metricTag) {
String key = generateKafkaKey(metricTag);
MetricJsonTag metricJsonTag = MetricJsonTag.covertMetricJsonTag(tagListTypeHandler, metricTag);
kafkaTagTemplate.send(topic, key, metricJsonTag);
}

private String generateKafkaKey(MetricTag metricTag) {
StringBuilder sb = new StringBuilder();
sb.append(metricTag.getHostName());
sb.append("_");
sb.append(metricTag.getMetricName());
sb.append("_");
sb.append(metricTag.getFieldName());
return sb.toString();
kafkaTagTemplate.send(topic, metricTag.getHostGroupName(), metricJsonTag);
}

private static class MetricJsonTag {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,19 @@ public void insert(String hostGroupName, String hostName, List<DoubleMetric> sys
Objects.requireNonNull(systemMetrics, "systemMetrics");

for (DoubleMetric doubleMetric : systemMetrics) {
String kafkaKey = generateKafkaKey(doubleMetric);
SystemMetricView systemMetricView = new SystemMetricView(hostGroupName, doubleMetric);
this.kafkaDoubleTemplate.send(topic, hostName, systemMetricView);
this.kafkaDoubleTemplate.send(topic, kafkaKey, systemMetricView);
}
}

private String generateKafkaKey(DoubleMetric doubleMetric) {
StringBuilder sb = new StringBuilder();
sb.append(doubleMetric.getHostName());
sb.append("_");
sb.append(doubleMetric.getMetricName());
sb.append("_");
sb.append(doubleMetric.getFieldName());
return sb.toString();
}
}

0 comments on commit bf45093

Please sign in to comment.