mihir6692 commented on code in PR #1682:
URL: https://github.com/apache/phoenix/pull/1682#discussion_r1374838430


##########
phoenix-core/src/main/java/org/apache/phoenix/monitoring/connqueryservice/ConnectionQueryServicesMetricsManager.java:
##########
@@ -0,0 +1,375 @@
+/*
+ * 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.
+ */
+package org.apache.phoenix.monitoring.connqueryservice;
+
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
+import org.apache.phoenix.monitoring.HistogramDistribution;
+import org.apache.phoenix.monitoring.MetricPublisherSupplierFactory;
+import org.apache.phoenix.monitoring.MetricServiceResolver;
+import org.apache.phoenix.monitoring.MetricType;
+import org.apache.phoenix.monitoring.PhoenixConnectionProfileMetric;
+import org.apache.phoenix.query.QueryServicesOptions;
+import 
org.apache.phoenix.thirdparty.com.google.common.annotations.VisibleForTesting;
+import org.apache.phoenix.thirdparty.com.google.common.base.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Central place where we keep track of all the Connection Query Service 
metrics. Register each
+ * Connection Query Service and store the instance of it associated with 
ConnectionServiceName in a
+ * map This class exposes following functions as static methods to help catch 
all exception
+ * 1.clearConnectionQueryServiceMetrics
+ * 2.getTableMetricsMethod
+ * 3.pushMetricsFromConnInstanceMethod
+ * 4.updateMetricsMethod
+ */
+public class ConnectionQueryServicesMetricsManager {
+    private static final Logger LOGGER =
+            
LoggerFactory.getLogger(ConnectionQueryServicesMetricsManager.class);
+    private static boolean isConnectionQueryServiceMetricsEnabled;
+    private static boolean isConnectionQueryServiceMetricPublisherEnabled;
+    private static ConcurrentMap<String, PhoenixConnectionQueryServiceMetrics>
+            connectionQueryServiceMetricsMapping;
+    // Singleton object
+    private static volatile ConnectionQueryServicesMetricsManager
+            connectionQueryServicesMetricsManager = null;
+    private static volatile MetricPublisherSupplierFactory mPublisher = null;
+    private static volatile QueryServicesOptions options;
+
+    @VisibleForTesting
+    public ConnectionQueryServicesMetricsManager(QueryServicesOptions opts) {
+        options = opts;
+        isConnectionQueryServiceMetricsEnabled = 
options.isConnectionQueryServiceMetricsEnabled();
+        connectionQueryServiceMetricsMapping = new ConcurrentHashMap<>();
+        LOGGER.info("Phoenix connection query service metrics enabled status: "
+                + isConnectionQueryServiceMetricsEnabled);
+        // Return simply if connection query service metrics are not enabled
+        if (!isConnectionQueryServiceMetricsEnabled) {
+            return;

Review Comment:
   Done



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

Reply via email to