[
https://issues.apache.org/jira/browse/PHOENIX-7038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17780475#comment-17780475
]
ASF GitHub Bot commented on PHOENIX-7038:
-----------------------------------------
mihir6692 commented on code in PR #1682:
URL: https://github.com/apache/phoenix/pull/1682#discussion_r1374843852
##########
phoenix-core/src/test/java/org/apache/phoenix/monitoring/connqueryservice/ConnectionQueryServiceNameMetricsGenerateAndVerifyTestData.java:
##########
@@ -0,0 +1,82 @@
+/**
+ * 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.phoenix.monitoring.MetricType;
+import org.apache.phoenix.monitoring.PhoenixConnectionProfileMetric;
+
+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;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * This class is used primarily to populate data and
+ * verification methods
+ */
+
+public class ConnectionQueryServiceNameMetricsGenerateAndVerifyTestData {
+
+ public static final String[] connectionQueryServiceNames = { "USE_CASE_1",
"USE_CASE_2", "USE_CASE_3" };
+ public static Map<String, Map<MetricType, Long>>[]
connectionQueryServiceNameMetricMap = new
Map[connectionQueryServiceNames.length];
+ public static final long[] openPhoenixConnCounter = { 1, 1, 1 };
+ public static final long[] openInternalPhoenixConnCounter = { 1, 1, 1 };
+ public static final long[] phoenixConnThrottledCounter = { 1, 2, 3 };
+
+
+ public void populateMetrics() {
+ for (int i = 0; i < connectionQueryServiceNameMetricMap.length; i++) {
+ connectionQueryServiceNameMetricMap[i] = new HashMap<>();
+ }
+ for (int i = 0; i < connectionQueryServiceNames.length; i++) {
+ Map<MetricType, Long> metrics = new HashMap<>();
+ metrics.put(OPEN_PHOENIX_CONNECTIONS_COUNTER,
openPhoenixConnCounter[i]);
+ metrics.put(OPEN_INTERNAL_PHOENIX_CONNECTIONS_COUNTER,
openInternalPhoenixConnCounter[i]);
+ metrics.put(PHOENIX_CONNECTIONS_THROTTLED_COUNTER,
phoenixConnThrottledCounter[i]);
+
+
connectionQueryServiceNameMetricMap[i].put(connectionQueryServiceNames[i],
metrics);
+ }
+ }
+
+ public void verfyCountOfConnecitonQueryServices(int
noOfConnectionQueryServiceName) {
Review Comment:
Done
##########
phoenix-core/src/test/java/org/apache/phoenix/monitoring/connqueryservice/PhoenixConnectionQueryServiceMetricsTest.java:
##########
@@ -0,0 +1,99 @@
+/**
+ * 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.junit.Test;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+import static
org.apache.phoenix.monitoring.connqueryservice.ConnectionQueryServiceNameMetricsGenerateAndVerifyTestData.openInternalPhoenixConnCounter;
+import static
org.apache.phoenix.monitoring.connqueryservice.ConnectionQueryServiceNameMetricsGenerateAndVerifyTestData.openPhoenixConnCounter;
+import static
org.apache.phoenix.monitoring.connqueryservice.ConnectionQueryServiceNameMetricsGenerateAndVerifyTestData.connectionQueryServiceNames;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class PhoenixConnectionQueryServiceMetricsTest {
+ static Map<String, PhoenixConnectionQueryServiceMetrics>
phoxnixConnectionQueryServiceSet = new HashMap<>();
+
+ public boolean verifyConnectionQueryServiceName() {
+
+ if (phoxnixConnectionQueryServiceSet.isEmpty()) {
+ return false;
+ }
+ for (String connectionQueryServiceName : connectionQueryServiceNames) {
+ PhoenixConnectionQueryServiceMetrics instance =
phoxnixConnectionQueryServiceSet.get(connectionQueryServiceName);
+ if
(!instance.getConnectionQueryServiceName().equals(connectionQueryServiceName)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void verifyMetricsFromPhoenixConnectionQueryServiceMetrics() {
+ assertFalse(phoxnixConnectionQueryServiceSet.isEmpty());
+ for (int i = 0; i < connectionQueryServiceNames.length; i++) {
+ PhoenixConnectionQueryServiceMetrics instance =
phoxnixConnectionQueryServiceSet.get(connectionQueryServiceNames[i]);
+ assertEquals(instance.getConnectionQueryServiceName(),
connectionQueryServiceNames[i]);
+ List<PhoenixConnectionProfileMetric> metricList =
instance.getMetricMap();
+ for (PhoenixConnectionProfileMetric metric : metricList) {
+
+ if
(metric.getMetricType().equals(MetricType.OPEN_INTERNAL_PHOENIX_CONNECTIONS_COUNTER))
{
+ assertEquals(openInternalPhoenixConnCounter[i],
metric.getValue());
+ }
+ if
(metric.getMetricType().equals(MetricType.OPEN_PHOENIX_CONNECTIONS_COUNTER)) {
+ assertEquals(openPhoenixConnCounter[i], metric.getValue());
+ }
+ }
+ }
+ }
+
+ @Test
+ public void
testPhoenixConnectionQueryServiceMetricsforPhoenixConnectionQueryServiceName() {
+ Configuration conf = new Configuration();
+ for (int i = 0; i < connectionQueryServiceNames.length; i++) {
+ PhoenixConnectionQueryServiceMetrics instance = new
PhoenixConnectionQueryServiceMetrics(connectionQueryServiceNames[i], conf);
+
phoxnixConnectionQueryServiceSet.put(connectionQueryServiceNames[i], instance);
+ }
+ assertTrue(verifyConnectionQueryServiceName());
+ }
+
+ /**
+ * This test is for changeMetricValue() Method and getMetricMap()
+ */
+ @Test
+ public void testPhoenixconnectionQueryServiceMetrics() {
Review Comment:
done
##########
phoenix-core/src/test/java/org/apache/phoenix/monitoring/connqueryservice/PhoenixConnectionQueryServiceMetricsTest.java:
##########
@@ -0,0 +1,99 @@
+/**
+ * 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.junit.Test;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+import static
org.apache.phoenix.monitoring.connqueryservice.ConnectionQueryServiceNameMetricsGenerateAndVerifyTestData.openInternalPhoenixConnCounter;
+import static
org.apache.phoenix.monitoring.connqueryservice.ConnectionQueryServiceNameMetricsGenerateAndVerifyTestData.openPhoenixConnCounter;
+import static
org.apache.phoenix.monitoring.connqueryservice.ConnectionQueryServiceNameMetricsGenerateAndVerifyTestData.connectionQueryServiceNames;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class PhoenixConnectionQueryServiceMetricsTest {
+ static Map<String, PhoenixConnectionQueryServiceMetrics>
phoxnixConnectionQueryServiceSet = new HashMap<>();
Review Comment:
done
> Implement Connection Query Service Metrics
> ------------------------------------------
>
> Key: PHOENIX-7038
> URL: https://issues.apache.org/jira/browse/PHOENIX-7038
> Project: Phoenix
> Issue Type: New Feature
> Reporter: Mihir Monani
> Assignee: Mihir Monani
> Priority: Major
>
> With JDBC connection profile string, Clients can provide connection profile
> name. With use of Connection Profile, different kinds of clients/use-case in
> single JVM can create connection with different configuration like time-outs,
> retries, sleep between retries.
> Connection URL Example : jdbc:phoenix:localhost:2181:CONN_PROFILE_2
> Here CONN_PROFILE_2 is connection profile name.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)