jiajunwang commented on a change in pull request #1377:
URL: https://github.com/apache/helix/pull/1377#discussion_r491152416



##########
File path: 
helix-rest/src/main/java/org/apache/helix/rest/metrics/JmxReporter.java
##########
@@ -0,0 +1,815 @@
+package org.apache.helix.rest.metrics;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Closeable;
+import java.lang.management.ManagementFactory;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.JMException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Gauge;
+import com.codahale.metrics.Histogram;
+import com.codahale.metrics.Meter;
+import com.codahale.metrics.Metered;
+import com.codahale.metrics.MetricFilter;
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.MetricRegistryListener;
+import com.codahale.metrics.Reporter;
+import com.codahale.metrics.Timer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A reporter which listens for new metrics and exposes them as namespaced 
MBeans.
+ * <p>
+ * The code is largely based on the {@code JmxReporter} class of the 
dropwizard metrics library
+ * <pre>See
+ * <a 
href="https://github.com/dropwizard/metrics/blob/master/metrics-core/src/main/java/io/
+ * dropwizard/metrics/JmxReporter.java">JmxReporter</a>
+ * </pre>
+ */
+public class JmxReporter implements Reporter, Closeable {

Review comment:
       Based on what you described, I have a simpler alternative design that 
might work.
   
   We implement our own ObjectNameFactory instead of JmxReporter. Let's call it 
NamespaceObjectNameFactory. It will be initialized with the namespace. Then you 
can put the namespace to the ObjectName whenever the reporter calls CreateName 
method.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to