You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ygerzhedovich (via GitHub)" <gi...@apache.org> on 2023/07/21 15:23:18 UTC
[GitHub] [ignite-3] ygerzhedovich opened a new pull request, #2343: IGNITE-19861: Introduce SQL metrics.
ygerzhedovich opened a new pull request, #2343:
URL: https://github.com/apache/ignite-3/pull/2343
(no comment)
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] lowka commented on a diff in pull request #2343: IGNITE-19861: Introduce SQL metrics.
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #2343:
URL: https://github.com/apache/ignite-3/pull/2343#discussion_r1274351473
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java:
##########
@@ -385,6 +386,8 @@ private PartialNode startPartialNode(
var indexManager = new IndexManager(tablesConfig, schemaManager, tableManager);
+ var metricManager = new MetricManager();
Review Comment:
Why don't we use the existing MetricManager, defined in IgniteImpl?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] lowka commented on a diff in pull request #2343: IGNITE-19861: Introduce SQL metrics.
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #2343:
URL: https://github.com/apache/ignite-3/pull/2343#discussion_r1274351473
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java:
##########
@@ -385,6 +386,8 @@ private PartialNode startPartialNode(
var indexManager = new IndexManager(tablesConfig, schemaManager, tableManager);
+ var metricManager = new MetricManager();
Review Comment:
Why we do not use the existing MetricManager, defined in IgniteImpl?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] zstan commented on a diff in pull request #2343: IGNITE-19861: Introduce SQL metrics.
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #2343:
URL: https://github.com/apache/ignite-3/pull/2343#discussion_r1276370771
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlClientMetricsTest.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.ignite.internal.sql.api;
+
+import static org.apache.ignite.internal.sql.engine.util.SqlTestUtils.assertThrowsSqlException;
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition;
+import static org.apache.ignite.lang.ErrorGroups.Sql;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.internal.metrics.MetricManager;
+import org.apache.ignite.internal.metrics.MetricSet;
+import org.apache.ignite.internal.sql.engine.ClusterPerClassIntegrationTest;
+import org.apache.ignite.internal.sql.metrics.SqlClientMetricSource;
+import org.apache.ignite.lang.IgniteException;
+import org.apache.ignite.sql.IgniteSql;
+import org.apache.ignite.sql.ResultSet;
+import org.apache.ignite.sql.Session;
+import org.apache.ignite.sql.SqlRow;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.function.Executable;
+
+/** Test SQL client metrics. */
+public class ItSqlClientMetricsTest extends ClusterPerClassIntegrationTest {
+ private MetricManager metricManager;
+ private IgniteSql sql;
+ private MetricSet clientMetricSet;
+
+ @BeforeAll
+ void beforeAll() {
+ metricManager = queryProcessor().metricManager();
+ sql = igniteSql();
+ clientMetricSet = metricManager.enable(SqlClientMetricSource.NAME);
+
+ createAndPopulateTable();
+ }
+
+ @AfterEach
+ void afterEach() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+ assertTrue(queryProcessor().liveSessions().isEmpty());
+ }
+
+
+ @Override
+ protected int nodes() {
+ return 1;
+ }
+
+
+ @Test
+ public void testNormalFlow() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+
+ Session session = sql.createSession();
+ ResultSet<SqlRow> rs1 = session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME);
+
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+ //ToDo: https://issues.apache.org/jira/browse/IGNITE-20022 - We could implement auto cleanup resources when result set is fully read
+ rs1.forEachRemaining(c -> {});
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ ResultSet<SqlRow> rs2 = session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME);
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 2);
+
+ rs1.close();
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ session.close();
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ rs2.close();
+
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+ }
+
+ @Test
+ public void testMetricsDuringTimeouts() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+
+ Session session = sql.sessionBuilder().idleTimeout(1, TimeUnit.SECONDS).build();
+
+ ResultSet<SqlRow> rs1 = session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME);
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ waitForCondition(() -> queryProcessor().liveSessions().isEmpty(), 10_000);
Review Comment:
need to append assertTrue(waitForCondition ... for more clear test
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] zstan commented on a diff in pull request #2343: IGNITE-19861: Introduce SQL metrics.
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #2343:
URL: https://github.com/apache/ignite-3/pull/2343#discussion_r1276362530
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlClientMetricsTest.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.ignite.internal.sql.api;
+
+import static org.apache.ignite.internal.sql.engine.util.SqlTestUtils.assertThrowsSqlException;
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition;
+import static org.apache.ignite.lang.ErrorGroups.Sql;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.internal.metrics.MetricManager;
+import org.apache.ignite.internal.metrics.MetricSet;
+import org.apache.ignite.internal.sql.engine.ClusterPerClassIntegrationTest;
+import org.apache.ignite.internal.sql.metrics.SqlClientMetricSource;
+import org.apache.ignite.lang.IgniteException;
+import org.apache.ignite.sql.IgniteSql;
+import org.apache.ignite.sql.ResultSet;
+import org.apache.ignite.sql.Session;
+import org.apache.ignite.sql.SqlRow;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.function.Executable;
+
+/** Test SQL client metrics. */
+public class ItSqlClientMetricsTest extends ClusterPerClassIntegrationTest {
+ private MetricManager metricManager;
+ private IgniteSql sql;
+ private MetricSet clientMetricSet;
+
+ @BeforeAll
+ void beforeAll() {
+ metricManager = queryProcessor().metricManager();
+ sql = igniteSql();
+ clientMetricSet = metricManager.enable(SqlClientMetricSource.NAME);
+
+ createAndPopulateTable();
+ }
+
+ @AfterEach
+ void afterEach() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+ assertTrue(queryProcessor().liveSessions().isEmpty());
+ }
+
+
+ @Override
+ protected int nodes() {
+ return 1;
+ }
+
+
Review Comment:
and here
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] lowka commented on a diff in pull request #2343: IGNITE-19861: Introduce SQL metrics.
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #2343:
URL: https://github.com/apache/ignite-3/pull/2343#discussion_r1274351473
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java:
##########
@@ -385,6 +386,8 @@ private PartialNode startPartialNode(
var indexManager = new IndexManager(tablesConfig, schemaManager, tableManager);
+ var metricManager = new MetricManager();
Review Comment:
Why don't we use the existing MetricManager, defined in IgniteImpl?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] AMashenkov commented on a diff in pull request #2343: IGNITE-19861: Introduce SQL metrics.
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #2343:
URL: https://github.com/apache/ignite-3/pull/2343#discussion_r1274890940
##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/metrics/PlanningCacheMetricsTest.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.ignite.internal.sql.metrics;
+
+import static org.apache.ignite.internal.sql.engine.prepare.PrepareServiceImpl.DEFAULT_PLANNER_TIMEOUT;
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Collections;
+import org.apache.ignite.internal.metrics.MetricManager;
+import org.apache.ignite.internal.metrics.MetricSet;
+import org.apache.ignite.internal.sql.engine.planner.AbstractPlannerTest;
+import org.apache.ignite.internal.sql.engine.prepare.PrepareService;
+import org.apache.ignite.internal.sql.engine.prepare.PrepareServiceImpl;
+import org.apache.ignite.internal.sql.engine.schema.IgniteSchema;
+import org.apache.ignite.internal.sql.engine.sql.ParsedResult;
+import org.apache.ignite.internal.sql.engine.sql.ParserService;
+import org.apache.ignite.internal.sql.engine.sql.ParserServiceImpl;
+import org.apache.ignite.internal.sql.engine.trait.IgniteDistributions;
+import org.apache.ignite.internal.sql.engine.util.BaseQueryContext;
+import org.apache.ignite.internal.sql.engine.util.EmptyCacheFactory;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test planning cache metrics.
+ */
+public class PlanningCacheMetricsTest extends AbstractPlannerTest {
+
+ @Test
+ public void plannerCacheStatisticsTest() throws Exception {
+ MetricManager metricManager = new MetricManager();
+ PrepareService prepareService = new PrepareServiceImpl("test", 2, null, DEFAULT_PLANNER_TIMEOUT, metricManager);
+
+ prepareService.start();
+
+ MetricSet metricSet = metricManager.enable(SqlPlanCacheMetricSource.NAME);
+
+ try {
+ checkCachePlanStatistics("SELECT * FROM T", prepareService, metricSet, 0, 1);
+ checkCachePlanStatistics("SELECT * FROM T", prepareService, metricSet, 1, 1);
+
+ checkCachePlanStatistics("SELECT * FROM T t1, T t2", prepareService, metricSet, 1, 2);
+ checkCachePlanStatistics("SELECT * FROM T t1, T t2", prepareService, metricSet, 2, 2);
+ checkCachePlanStatistics("SELECT * FROM T t1, T t2", prepareService, metricSet, 3, 2);
+
+ checkCachePlanStatistics("SELECT * FROM T", prepareService, metricSet, 4, 2);
+
+ checkCachePlanStatistics("SELECT * FROM T t1, T t2, T t3", prepareService, metricSet, 4, 3);
+
+ checkCachePlanStatistics("SELECT * FROM T", prepareService, metricSet, 4, 4);
Review Comment:
```suggestion
// Here, the very first plan has been evicted from cache.
checkCachePlanStatistics("SELECT * FROM T", prepareService, metricSet, 4, 4);
```
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] ygerzhedovich commented on a diff in pull request #2343: IGNITE-19861: Introduce SQL metrics.
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2343:
URL: https://github.com/apache/ignite-3/pull/2343#discussion_r1276402428
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlClientMetricsTest.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.ignite.internal.sql.api;
+
+import static org.apache.ignite.internal.sql.engine.util.SqlTestUtils.assertThrowsSqlException;
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition;
+import static org.apache.ignite.lang.ErrorGroups.Sql;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.internal.metrics.MetricManager;
+import org.apache.ignite.internal.metrics.MetricSet;
+import org.apache.ignite.internal.sql.engine.ClusterPerClassIntegrationTest;
+import org.apache.ignite.internal.sql.metrics.SqlClientMetricSource;
+import org.apache.ignite.lang.IgniteException;
+import org.apache.ignite.sql.IgniteSql;
+import org.apache.ignite.sql.ResultSet;
+import org.apache.ignite.sql.Session;
+import org.apache.ignite.sql.SqlRow;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.function.Executable;
+
+/** Test SQL client metrics. */
+public class ItSqlClientMetricsTest extends ClusterPerClassIntegrationTest {
+ private MetricManager metricManager;
+ private IgniteSql sql;
+ private MetricSet clientMetricSet;
+
+ @BeforeAll
+ void beforeAll() {
+ metricManager = queryProcessor().metricManager();
+ sql = igniteSql();
+ clientMetricSet = metricManager.enable(SqlClientMetricSource.NAME);
+
+ createAndPopulateTable();
+ }
+
+ @AfterEach
+ void afterEach() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+ assertTrue(queryProcessor().liveSessions().isEmpty());
+ }
+
+
+ @Override
+ protected int nodes() {
+ return 1;
+ }
+
+
+ @Test
+ public void testNormalFlow() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+
+ Session session = sql.createSession();
+ ResultSet<SqlRow> rs1 = session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME);
+
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+ //ToDo: https://issues.apache.org/jira/browse/IGNITE-20022 - We could implement auto cleanup resources when result set is fully read
+ rs1.forEachRemaining(c -> {});
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ ResultSet<SqlRow> rs2 = session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME);
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 2);
+
+ rs1.close();
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ session.close();
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ rs2.close();
+
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+ }
+
+ @Test
+ public void testMetricsDuringTimeouts() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+
+ Session session = sql.sessionBuilder().idleTimeout(1, TimeUnit.SECONDS).build();
+
+ ResultSet<SqlRow> rs1 = session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME);
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ waitForCondition(() -> queryProcessor().liveSessions().isEmpty(), 10_000);
+
+ assertInternalSqlException("Session not found", () -> session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME));
+
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+ rs1.close();
+ session.close();
+ }
+
+ private static void assertInternalSqlException(String expectedText, Executable executable) {
+ IgniteException err = assertThrows(IgniteException.class, executable);
+ assertThat(err.getMessage(), containsString(expectedText));
+ }
+
+ @Test
+ public void testErroneousFlow() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
Review Comment:
agree
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] ygerzhedovich commented on a diff in pull request #2343: IGNITE-19861: Introduce SQL metrics.
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2343:
URL: https://github.com/apache/ignite-3/pull/2343#discussion_r1276379885
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlClientMetricsTest.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.ignite.internal.sql.api;
+
+import static org.apache.ignite.internal.sql.engine.util.SqlTestUtils.assertThrowsSqlException;
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition;
+import static org.apache.ignite.lang.ErrorGroups.Sql;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.internal.metrics.MetricManager;
+import org.apache.ignite.internal.metrics.MetricSet;
+import org.apache.ignite.internal.sql.engine.ClusterPerClassIntegrationTest;
+import org.apache.ignite.internal.sql.metrics.SqlClientMetricSource;
+import org.apache.ignite.lang.IgniteException;
+import org.apache.ignite.sql.IgniteSql;
+import org.apache.ignite.sql.ResultSet;
+import org.apache.ignite.sql.Session;
+import org.apache.ignite.sql.SqlRow;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.function.Executable;
+
+/** Test SQL client metrics. */
+public class ItSqlClientMetricsTest extends ClusterPerClassIntegrationTest {
+ private MetricManager metricManager;
+ private IgniteSql sql;
+ private MetricSet clientMetricSet;
+
+ @BeforeAll
+ void beforeAll() {
+ metricManager = queryProcessor().metricManager();
+ sql = igniteSql();
+ clientMetricSet = metricManager.enable(SqlClientMetricSource.NAME);
+
+ createAndPopulateTable();
+ }
+
+ @AfterEach
+ void afterEach() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+ assertTrue(queryProcessor().liveSessions().isEmpty());
+ }
+
+
+ @Override
+ protected int nodes() {
+ return 1;
+ }
+
+
+ @Test
+ public void testNormalFlow() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+
+ Session session = sql.createSession();
+ ResultSet<SqlRow> rs1 = session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME);
+
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+ //ToDo: https://issues.apache.org/jira/browse/IGNITE-20022 - We could implement auto cleanup resources when result set is fully read
+ rs1.forEachRemaining(c -> {});
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ ResultSet<SqlRow> rs2 = session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME);
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 2);
+
+ rs1.close();
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ session.close();
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ rs2.close();
+
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+ }
+
+ @Test
+ public void testMetricsDuringTimeouts() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+
+ Session session = sql.sessionBuilder().idleTimeout(1, TimeUnit.SECONDS).build();
+
+ ResultSet<SqlRow> rs1 = session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME);
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ waitForCondition(() -> queryProcessor().liveSessions().isEmpty(), 10_000);
Review Comment:
yep!
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] zstan commented on a diff in pull request #2343: IGNITE-19861: Introduce SQL metrics.
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #2343:
URL: https://github.com/apache/ignite-3/pull/2343#discussion_r1276362158
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlClientMetricsTest.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.ignite.internal.sql.api;
+
+import static org.apache.ignite.internal.sql.engine.util.SqlTestUtils.assertThrowsSqlException;
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition;
+import static org.apache.ignite.lang.ErrorGroups.Sql;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.internal.metrics.MetricManager;
+import org.apache.ignite.internal.metrics.MetricSet;
+import org.apache.ignite.internal.sql.engine.ClusterPerClassIntegrationTest;
+import org.apache.ignite.internal.sql.metrics.SqlClientMetricSource;
+import org.apache.ignite.lang.IgniteException;
+import org.apache.ignite.sql.IgniteSql;
+import org.apache.ignite.sql.ResultSet;
+import org.apache.ignite.sql.Session;
+import org.apache.ignite.sql.SqlRow;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.function.Executable;
+
+/** Test SQL client metrics. */
+public class ItSqlClientMetricsTest extends ClusterPerClassIntegrationTest {
+ private MetricManager metricManager;
+ private IgniteSql sql;
+ private MetricSet clientMetricSet;
+
+ @BeforeAll
+ void beforeAll() {
+ metricManager = queryProcessor().metricManager();
+ sql = igniteSql();
+ clientMetricSet = metricManager.enable(SqlClientMetricSource.NAME);
+
+ createAndPopulateTable();
+ }
+
+ @AfterEach
+ void afterEach() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+ assertTrue(queryProcessor().liveSessions().isEmpty());
+ }
+
+
Review Comment:
redundant line
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] ygerzhedovich commented on a diff in pull request #2343: IGNITE-19861: Introduce SQL metrics.
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2343:
URL: https://github.com/apache/ignite-3/pull/2343#discussion_r1276365410
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlAsynchronousApiTest.java:
##########
@@ -296,7 +277,7 @@ public void implicitTransactionsStates() {
}
// No new transactions through ddl.
- assertEquals(0, txManagerInternal.finished() - txPrevCnt);
+ assertEquals(0, txManager.finished() - txPrevCnt);
Review Comment:
yes, but after merge the ticket only.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] zstan commented on a diff in pull request #2343: IGNITE-19861: Introduce SQL metrics.
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #2343:
URL: https://github.com/apache/ignite-3/pull/2343#discussion_r1276361534
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlAsynchronousApiTest.java:
##########
@@ -296,7 +277,7 @@ public void implicitTransactionsStates() {
}
// No new transactions through ddl.
- assertEquals(0, txManagerInternal.finished() - txPrevCnt);
+ assertEquals(0, txManager.finished() - txPrevCnt);
Review Comment:
https://issues.apache.org/jira/browse/IGNITE-19916 probably we can close ?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] zstan commented on a diff in pull request #2343: IGNITE-19861: Introduce SQL metrics.
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #2343:
URL: https://github.com/apache/ignite-3/pull/2343#discussion_r1276382813
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlClientMetricsTest.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.ignite.internal.sql.api;
+
+import static org.apache.ignite.internal.sql.engine.util.SqlTestUtils.assertThrowsSqlException;
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition;
+import static org.apache.ignite.lang.ErrorGroups.Sql;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.internal.metrics.MetricManager;
+import org.apache.ignite.internal.metrics.MetricSet;
+import org.apache.ignite.internal.sql.engine.ClusterPerClassIntegrationTest;
+import org.apache.ignite.internal.sql.metrics.SqlClientMetricSource;
+import org.apache.ignite.lang.IgniteException;
+import org.apache.ignite.sql.IgniteSql;
+import org.apache.ignite.sql.ResultSet;
+import org.apache.ignite.sql.Session;
+import org.apache.ignite.sql.SqlRow;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.function.Executable;
+
+/** Test SQL client metrics. */
+public class ItSqlClientMetricsTest extends ClusterPerClassIntegrationTest {
+ private MetricManager metricManager;
+ private IgniteSql sql;
+ private MetricSet clientMetricSet;
+
+ @BeforeAll
+ void beforeAll() {
+ metricManager = queryProcessor().metricManager();
+ sql = igniteSql();
+ clientMetricSet = metricManager.enable(SqlClientMetricSource.NAME);
+
+ createAndPopulateTable();
+ }
+
+ @AfterEach
+ void afterEach() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+ assertTrue(queryProcessor().liveSessions().isEmpty());
+ }
+
+
+ @Override
+ protected int nodes() {
+ return 1;
+ }
+
+
+ @Test
+ public void testNormalFlow() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+
+ Session session = sql.createSession();
+ ResultSet<SqlRow> rs1 = session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME);
+
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+ //ToDo: https://issues.apache.org/jira/browse/IGNITE-20022 - We could implement auto cleanup resources when result set is fully read
+ rs1.forEachRemaining(c -> {});
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ ResultSet<SqlRow> rs2 = session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME);
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 2);
+
+ rs1.close();
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ session.close();
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ rs2.close();
+
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+ }
+
+ @Test
+ public void testMetricsDuringTimeouts() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
+
+ Session session = sql.sessionBuilder().idleTimeout(1, TimeUnit.SECONDS).build();
+
+ ResultSet<SqlRow> rs1 = session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME);
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+
+ waitForCondition(() -> queryProcessor().liveSessions().isEmpty(), 10_000);
+
+ assertInternalSqlException("Session not found", () -> session.execute(null, "SELECT * from " + DEFAULT_TABLE_NAME));
+
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 1);
+ rs1.close();
+ session.close();
+ }
+
+ private static void assertInternalSqlException(String expectedText, Executable executable) {
+ IgniteException err = assertThrows(IgniteException.class, executable);
+ assertThat(err.getMessage(), containsString(expectedText));
+ }
+
+ @Test
+ public void testErroneousFlow() throws Exception {
+ assertMetricValue(clientMetricSet, SqlClientMetricSource.METRIC_CURSOR_OPEN, 0);
Review Comment:
probably it more clear to move this check into @beforeEach ?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org