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


##########
phoenix-core/src/main/java/org/apache/phoenix/monitoring/connqueryservice/PhoenixConnectionQueryServiceMetrics.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * 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.conf.Configuration;
+import org.apache.phoenix.monitoring.MetricType;
+import org.apache.phoenix.monitoring.PhoenixConnectionProfileMetric;
+import org.apache.phoenix.monitoring.PhoenixConnectionProfileMetricImpl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.phoenix.monitoring.MetricType.OPEN_INTERNAL_PHOENIX_CONNECTIONS_COUNTER;
+import static 
org.apache.phoenix.monitoring.MetricType.OPEN_PHOENIX_CONNECTIONS_COUNTER;
+import static 
org.apache.phoenix.monitoring.MetricType.PHOENIX_CONNECTIONS_THROTTLED_COUNTER;
+
+public class PhoenixConnectionQueryServiceMetrics {
+    public enum ConnectionQueryServiceMetrics {
+        
CONNECTION_QUERY_SERVICE_OPEN_PHOENIX_CONNECTIONS_COUNTER(OPEN_PHOENIX_CONNECTIONS_COUNTER),
+        
CONNECTION_QUERY_SERVICE_OPEN_INTERNAL_PHOENIX_CONNECTIONS_COUNTER(OPEN_INTERNAL_PHOENIX_CONNECTIONS_COUNTER),
+        
CONNECTION_QUERY_SERVICE_PHOENIX_CONNECTIONS_THROTTLED_COUNTER(PHOENIX_CONNECTIONS_THROTTLED_COUNTER);
+
+        private MetricType metricType;
+        private PhoenixConnectionProfileMetric metric;
+
+        ConnectionQueryServiceMetrics(MetricType metricType) {
+            this.metricType = metricType;
+        }
+    }
+
+    private final String connectionQueryServiceName;
+    private Map<MetricType, PhoenixConnectionProfileMetric> metricRegister;
+    private ConnectionQueryServiceMetricsHistograms 
connectionQueryServiceMetricsHistograms;
+
+    public PhoenixConnectionQueryServiceMetrics(final String 
connectionQueryServiceName,
+            Configuration conf) {
+        this.connectionQueryServiceName = connectionQueryServiceName;
+        metricRegister = new HashMap<>();
+        for (ConnectionQueryServiceMetrics connectionQueryServiceMetric
+                : ConnectionQueryServiceMetrics.values()) {
+            connectionQueryServiceMetric.metric =
+                    new 
PhoenixConnectionProfileMetricImpl(connectionQueryServiceMetric.metricType);
+            metricRegister.put(connectionQueryServiceMetric.metricType,
+                    connectionQueryServiceMetric.metric);
+        }
+        connectionQueryServiceMetricsHistograms =
+                new 
ConnectionQueryServiceMetricsHistograms(connectionQueryServiceName, conf);
+    }
+
+    /**
+     * This function is used to update the value of Metric
+     * In case of counter val will be passed as 1.
+     *
+     * @param type metric type
+     * @param val update value. In case of counters, this will be 1
+     */
+    public void changeMetricValue(MetricType type, long val) {
+        if (!metricRegister.containsKey(type)) {
+            return;
+        }
+        PhoenixConnectionProfileMetric metric = metricRegister.get(type);
+        metric.set(val);
+    }
+
+    /**
+     * This function is used to get the value of Metric.
+     *
+     * @param type metric type
+     * @return val current value of metric.
+     */
+    public long getMetricValue(MetricType type) {
+        if (!metricRegister.containsKey(type)) {
+            return 0;
+        }
+        PhoenixConnectionProfileMetric metric = metricRegister.get(type);
+        return metric.getValue();
+    }
+
+    public String getConnectionQueryServiceName() {
+        return connectionQueryServiceName;
+    }
+
+    /**
+     * This method is called to aggregate all the Metrics across all 
Connection Query Service.
+     *
+     * @return map of Connection Query Service name -> list of 
ConnectionQueryServiceMetric.
+     */
+    public List<PhoenixConnectionProfileMetric> getMetricMap() {

Review Comment:
   Changed name to `getAllMetrics()`



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