Pengzna commented on code in PR #11410:
URL: https://github.com/apache/iotdb/pull/11410#discussion_r1375853654
##########
iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/AbstractMetricManager.java:
##########
@@ -51,12 +52,44 @@ public abstract class AbstractMetricManager {
protected Map<String, MetricInfo.MetaInfo> nameToMetaInfo;
/** The map from metricInfo to metric. */
protected Map<MetricInfo, IMetric> metrics;
+ /** The bind IoTDBJmxReporter */
+ protected JmxReporter bindJmxReporter = null;
protected AbstractMetricManager() {
nameToMetaInfo = new ConcurrentHashMap<>();
metrics = new ConcurrentHashMap<>();
}
+ /**
+ * Notify IoTDB JmxReporter to register metric in JMX
+ *
+ * @param metric the created metric
+ * @param metricInfo the created metric info
+ */
+ private void notifyReporterOnAdd(IMetric metric, MetricInfo metricInfo) {
+ // if the reporter type is not JMX
+ if (bindJmxReporter == null) {
Review Comment:
Elegant!
##########
iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/AbstractMetricManager.java:
##########
@@ -51,12 +52,44 @@ public abstract class AbstractMetricManager {
protected Map<String, MetricInfo.MetaInfo> nameToMetaInfo;
/** The map from metricInfo to metric. */
protected Map<MetricInfo, IMetric> metrics;
+ /** The bind IoTDBJmxReporter */
+ protected JmxReporter bindJmxReporter = null;
protected AbstractMetricManager() {
nameToMetaInfo = new ConcurrentHashMap<>();
metrics = new ConcurrentHashMap<>();
}
+ /**
+ * Notify IoTDB JmxReporter to register metric in JMX
+ *
+ * @param metric the created metric
+ * @param metricInfo the created metric info
+ */
+ private void notifyReporterOnAdd(IMetric metric, MetricInfo metricInfo) {
+ // if the reporter type is not JMX
+ if (bindJmxReporter == null) {
Review Comment:
Elegant!
##########
iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/AbstractMetricManager.java:
##########
@@ -51,12 +52,44 @@ public abstract class AbstractMetricManager {
protected Map<String, MetricInfo.MetaInfo> nameToMetaInfo;
/** The map from metricInfo to metric. */
protected Map<MetricInfo, IMetric> metrics;
+ /** The bind IoTDBJmxReporter */
+ protected JmxReporter bindJmxReporter = null;
protected AbstractMetricManager() {
nameToMetaInfo = new ConcurrentHashMap<>();
metrics = new ConcurrentHashMap<>();
}
+ /**
+ * Notify IoTDB JmxReporter to register metric in JMX
+ *
+ * @param metric the created metric
+ * @param metricInfo the created metric info
+ */
+ private void notifyReporterOnAdd(IMetric metric, MetricInfo metricInfo) {
+ // if the reporter type is not JMX
+ if (bindJmxReporter == null) {
+ return;
+ }
+ // register the new metric
+ bindJmxReporter.registerMetric(metric, metricInfo);
+ }
+
+ /**
+ * Notify IoTDB JmxReporter to remove metric in JMX
+ *
+ * @param metric the removed metric
+ * @param metricInfo the removed metric info
+ */
+ private void notifyReporterOnRemove(IMetric metric, MetricInfo metricInfo) {
+ // if the reporter type is not JMX
+ if (bindJmxReporter == null) {
+ return;
+ }
+ // register the new metric
+ bindJmxReporter.unregisterMetric(metric, metricInfo);
Review Comment:
Have fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]