[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r343455244 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,198 @@ +/* + * 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.processors.cache.distributed.near; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.internal.processors.GridProcessor; +import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests distributed SQL queries default timeouts. + */ +public class IgniteCacheDistributedQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { +/** Grids count. */ +private static final int GRIDS_CNT = 3; + +/** Cache size. */ +public static final int CACHE_SIZE = 10_000; + +/** Default query timeout */ +private static final long DEFAULT_QUERY_TIMEOUT = 1000; + +/** Value size. */ +public static final int VAL_SIZE = 16; + +/** */ +private static final String QRY_1 = "select a._val, b._val from String a, String b"; + +/** */ +private static final String QRY_2 = "select a._key, count(*) from String a group by a._key"; + +/** */ +private static final String QRY_3 = "select a._val from String a"; + +/** {@inheritDoc} */ +@Override protected void beforeTestsStarted() throws Exception { +super.beforeTestsStarted(); + +startGridsMultiThreaded(GRIDS_CNT); +} + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + +CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); +ccfg.setIndexedTypes(Integer.class, String.class); + +cfg.setCacheConfiguration(ccfg); + +if ("client".equals(igniteInstanceName)) +cfg.setClientMode(true); + +cfg.setDefaultQueryTimeout(DEFAULT_QUERY_TIMEOUT); + +return cfg; +} + +/** {@inheritDoc} */ +@Override protected void afterTest() throws Exception { +super.afterTest(); + +grid(0).cache(DEFAULT_CACHE_NAME).removeAll(); +} + +/** */ +@Test +public void testRemoteQueryExecutionTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 500, TimeUnit.MILLISECONDS, true, true); +} + +/** */ +@Test +public void testRemoteQueryWithMergeTableTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_2, 500, TimeUnit.MILLISECONDS, true, false); +} + +/** */ +@Test +public void testRemoteQueryExecutionCancel0() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 1, TimeUnit.MILLISECONDS, false, true); +} + +/** */ +private void testQueryCancel(int keyCnt, int valSize, String sql, int timeoutUnits, TimeUnit timeUnit, +boolean timeout, boolean checkCanceled) throws Exception { +try (Ignite client = startGrid("client")) { +IgniteCache cache = client.cache(DEFAULT_CACHE_NAME); + +assertEquals(0, cache.localSize()); + +
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r339395082 ## File path: modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs ## @@ -72,6 +72,11 @@ public class IgniteConfiguration /// public const int DefaultJvmMaxMem = -1; +/// +/// Default query timeout. +/// +public static readonly TimeSpan DefaultQueryTimeout = TimeSpan.FromMilliseconds(0); Review comment: @ptupitsyn Thank you for reviewing and sharing your feedback. Can you please clarify if you are asking to rename the parameter from `DefaultQueryTimeout ` to `QueryTimeout ` or to remove this parameter from `IgniteConfiguration.cs` 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r339394098 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,199 @@ +/* + * 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.processors.cache.distributed.near; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.internal.processors.GridProcessor; +import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests distributed SQL queries default timeouts. + */ +public class IgniteCacheDistributedQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { +/** Grids count. */ +private static final int GRIDS_CNT = 3; + +/** Cache size. */ +public static final int CACHE_SIZE = 10_000; + +/** Default query timeout */ +private static final long DEFAULT_QUERY_TIMEOUT = 1000; + +/** Value size. */ +public static final int VAL_SIZE = 16; + +/** */ +private static final String QRY_1 = "select a._val, b._val from String a, String b"; + +/** */ +private static final String QRY_2 = "select a._key, count(*) from String a group by a._key"; + +/** */ +private static final String QRY_3 = "select a._val from String a"; + +/** {@inheritDoc} */ +@Override protected void beforeTestsStarted() throws Exception { +super.beforeTestsStarted(); + +startGridsMultiThreaded(GRIDS_CNT); +} + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + +CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); +ccfg.setIndexedTypes(Integer.class, String.class); + +cfg.setCacheConfiguration(ccfg); + +if ("client".equals(igniteInstanceName)) +cfg.setClientMode(true); + +cfg.setDefaultQueryTimeout(DEFAULT_QUERY_TIMEOUT); + +return cfg; +} + +/** {@inheritDoc} */ +@Override protected void afterTest() throws Exception { +super.afterTest(); + +G.ignite().cache(DEFAULT_CACHE_NAME).removeAll(); Review comment: yes updated 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r339394035 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,199 @@ +/* + * 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.processors.cache.distributed.near; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.internal.processors.GridProcessor; +import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests distributed SQL queries default timeouts. + */ +public class IgniteCacheDistributedQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { +/** Grids count. */ +private static final int GRIDS_CNT = 3; + +/** Cache size. */ +public static final int CACHE_SIZE = 10_000; + +/** Default query timeout */ +private static final long DEFAULT_QUERY_TIMEOUT = 1000; + +/** Value size. */ +public static final int VAL_SIZE = 16; + +/** */ +private static final String QRY_1 = "select a._val, b._val from String a, String b"; + +/** */ +private static final String QRY_2 = "select a._key, count(*) from String a group by a._key"; + +/** */ +private static final String QRY_3 = "select a._val from String a"; + +/** {@inheritDoc} */ +@Override protected void beforeTestsStarted() throws Exception { +super.beforeTestsStarted(); + +startGridsMultiThreaded(GRIDS_CNT); +} + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + +CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); +ccfg.setIndexedTypes(Integer.class, String.class); + +cfg.setCacheConfiguration(ccfg); + +if ("client".equals(igniteInstanceName)) +cfg.setClientMode(true); + +cfg.setDefaultQueryTimeout(DEFAULT_QUERY_TIMEOUT); + +return cfg; +} + +/** {@inheritDoc} */ +@Override protected void afterTest() throws Exception { +super.afterTest(); + +G.ignite().cache(DEFAULT_CACHE_NAME).removeAll(); +} + +/** */ +@Test +public void testRemoteQueryExecutionTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 500, TimeUnit.MILLISECONDS, true, true); +} + +/** */ +@Test +public void testRemoteQueryWithMergeTableTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_2, 500, TimeUnit.MILLISECONDS, true, false); +} + +/** */ +@Test +public void testRemoteQueryExecutionCancel0() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 1, TimeUnit.MILLISECONDS, false, true); +} + +/** */ +private void testQueryCancel(int keyCnt, int valSize, String sql, int timeoutUnits, TimeUnit timeUnit, +boolean timeout, boolean checkCanceled) throws Exception { +try (Ignite client = startGrid("client")) { +IgniteCache cache = client.cache(DEFAULT_CACHE_NAME); + +
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r339394035 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,199 @@ +/* + * 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.processors.cache.distributed.near; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.internal.processors.GridProcessor; +import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests distributed SQL queries default timeouts. + */ +public class IgniteCacheDistributedQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { +/** Grids count. */ +private static final int GRIDS_CNT = 3; + +/** Cache size. */ +public static final int CACHE_SIZE = 10_000; + +/** Default query timeout */ +private static final long DEFAULT_QUERY_TIMEOUT = 1000; + +/** Value size. */ +public static final int VAL_SIZE = 16; + +/** */ +private static final String QRY_1 = "select a._val, b._val from String a, String b"; + +/** */ +private static final String QRY_2 = "select a._key, count(*) from String a group by a._key"; + +/** */ +private static final String QRY_3 = "select a._val from String a"; + +/** {@inheritDoc} */ +@Override protected void beforeTestsStarted() throws Exception { +super.beforeTestsStarted(); + +startGridsMultiThreaded(GRIDS_CNT); +} + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + +CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); +ccfg.setIndexedTypes(Integer.class, String.class); + +cfg.setCacheConfiguration(ccfg); + +if ("client".equals(igniteInstanceName)) +cfg.setClientMode(true); + +cfg.setDefaultQueryTimeout(DEFAULT_QUERY_TIMEOUT); + +return cfg; +} + +/** {@inheritDoc} */ +@Override protected void afterTest() throws Exception { +super.afterTest(); + +G.ignite().cache(DEFAULT_CACHE_NAME).removeAll(); +} + +/** */ +@Test +public void testRemoteQueryExecutionTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 500, TimeUnit.MILLISECONDS, true, true); +} + +/** */ +@Test +public void testRemoteQueryWithMergeTableTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_2, 500, TimeUnit.MILLISECONDS, true, false); +} + +/** */ +@Test +public void testRemoteQueryExecutionCancel0() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 1, TimeUnit.MILLISECONDS, false, true); +} + +/** */ +private void testQueryCancel(int keyCnt, int valSize, String sql, int timeoutUnits, TimeUnit timeUnit, +boolean timeout, boolean checkCanceled) throws Exception { +try (Ignite client = startGrid("client")) { +IgniteCache cache = client.cache(DEFAULT_CACHE_NAME); + +
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r336758010 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,200 @@ +/* + * 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.processors.cache.distributed.near; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.internal.processors.GridProcessor; +import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests distributed SQL queries default timeouts. + */ +public class IgniteCacheDistributedQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { +/** Grids count. */ +private static final int GRIDS_CNT = 3; + +/** Cache size. */ +public static final int CACHE_SIZE = 10_000; + +/** Default query timeout */ +private static final long DEFAULT_QUERY_TIMEOUT = 1000; + +/** Value size. */ +public static final int VAL_SIZE = 16; + +/** */ +private static final String QRY_1 = "select a._val, b._val from String a, String b"; + +/** */ +private static final String QRY_2 = "select a._key, count(*) from String a group by a._key"; + +/** */ +private static final String QRY_3 = "select a._val from String a"; + +/** {@inheritDoc} */ +@Override protected void beforeTestsStarted() throws Exception { +super.beforeTestsStarted(); + +startGridsMultiThreaded(GRIDS_CNT); +} + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + +CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); +ccfg.setIndexedTypes(Integer.class, String.class); + +cfg.setCacheConfiguration(ccfg); + +if ("client".equals(igniteInstanceName)) +cfg.setClientMode(true); + +cfg.setDefaultQueryTimeout(DEFAULT_QUERY_TIMEOUT); + +return cfg; +} + +/** {@inheritDoc} */ +@Override protected void afterTest() throws Exception { +super.afterTest(); + +for (Ignite g : G.allGrids()) +g.cache(DEFAULT_CACHE_NAME).removeAll(); +} + +/** */ +@Test +public void testRemoteQueryExecutionTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 500, TimeUnit.MILLISECONDS, true, true); +} + +/** */ +@Test +public void testRemoteQueryWithMergeTableTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_2, 500, TimeUnit.MILLISECONDS, true, false); +} + +/** */ +@Test +public void testRemoteQueryExecutionCancel0() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 1, TimeUnit.MILLISECONDS, false, true); +} + +/** */ +private void testQueryCancel(int keyCnt, int valSize, String sql, int timeoutUnits, TimeUnit timeUnit, +boolean timeout, boolean checkCanceled) throws Exception { +try (Ignite client = startGrid("client")) { +IgniteCache cache =
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r336758022 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,200 @@ +/* + * 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.processors.cache.distributed.near; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.internal.processors.GridProcessor; +import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests distributed SQL queries default timeouts. + */ +public class IgniteCacheDistributedQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { +/** Grids count. */ +private static final int GRIDS_CNT = 3; + +/** Cache size. */ +public static final int CACHE_SIZE = 10_000; + +/** Default query timeout */ +private static final long DEFAULT_QUERY_TIMEOUT = 1000; + +/** Value size. */ +public static final int VAL_SIZE = 16; + +/** */ +private static final String QRY_1 = "select a._val, b._val from String a, String b"; + +/** */ +private static final String QRY_2 = "select a._key, count(*) from String a group by a._key"; + +/** */ +private static final String QRY_3 = "select a._val from String a"; + +/** {@inheritDoc} */ +@Override protected void beforeTestsStarted() throws Exception { +super.beforeTestsStarted(); + +startGridsMultiThreaded(GRIDS_CNT); +} + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + +CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); +ccfg.setIndexedTypes(Integer.class, String.class); + +cfg.setCacheConfiguration(ccfg); + +if ("client".equals(igniteInstanceName)) +cfg.setClientMode(true); + +cfg.setDefaultQueryTimeout(DEFAULT_QUERY_TIMEOUT); + +return cfg; +} + +/** {@inheritDoc} */ +@Override protected void afterTest() throws Exception { +super.afterTest(); + +for (Ignite g : G.allGrids()) +g.cache(DEFAULT_CACHE_NAME).removeAll(); +} + +/** */ +@Test +public void testRemoteQueryExecutionTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 500, TimeUnit.MILLISECONDS, true, true); +} + +/** */ +@Test +public void testRemoteQueryWithMergeTableTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_2, 500, TimeUnit.MILLISECONDS, true, false); +} + +/** */ +@Test +public void testRemoteQueryExecutionCancel0() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 1, TimeUnit.MILLISECONDS, false, true); +} + +/** */ +private void testQueryCancel(int keyCnt, int valSize, String sql, int timeoutUnits, TimeUnit timeUnit, +boolean timeout, boolean checkCanceled) throws Exception { +try (Ignite client = startGrid("client")) { +IgniteCache cache =
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r336758024 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,200 @@ +/* + * 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.processors.cache.distributed.near; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.internal.processors.GridProcessor; +import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests distributed SQL queries default timeouts. + */ +public class IgniteCacheDistributedQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { +/** Grids count. */ +private static final int GRIDS_CNT = 3; + +/** Cache size. */ +public static final int CACHE_SIZE = 10_000; + +/** Default query timeout */ +private static final long DEFAULT_QUERY_TIMEOUT = 1000; + +/** Value size. */ +public static final int VAL_SIZE = 16; + +/** */ +private static final String QRY_1 = "select a._val, b._val from String a, String b"; + +/** */ +private static final String QRY_2 = "select a._key, count(*) from String a group by a._key"; + +/** */ +private static final String QRY_3 = "select a._val from String a"; + +/** {@inheritDoc} */ +@Override protected void beforeTestsStarted() throws Exception { +super.beforeTestsStarted(); + +startGridsMultiThreaded(GRIDS_CNT); +} + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + +CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); +ccfg.setIndexedTypes(Integer.class, String.class); + +cfg.setCacheConfiguration(ccfg); + +if ("client".equals(igniteInstanceName)) +cfg.setClientMode(true); + +cfg.setDefaultQueryTimeout(DEFAULT_QUERY_TIMEOUT); + +return cfg; +} + +/** {@inheritDoc} */ +@Override protected void afterTest() throws Exception { +super.afterTest(); + +for (Ignite g : G.allGrids()) Review comment: yes updated the PR 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r336757954 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,200 @@ +/* + * 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.processors.cache.distributed.near; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.internal.processors.GridProcessor; +import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests distributed SQL queries default timeouts. + */ +public class IgniteCacheDistributedQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { +/** Grids count. */ +private static final int GRIDS_CNT = 3; + +/** Cache size. */ +public static final int CACHE_SIZE = 10_000; + +/** Default query timeout */ +private static final long DEFAULT_QUERY_TIMEOUT = 1000; + +/** Value size. */ +public static final int VAL_SIZE = 16; + +/** */ +private static final String QRY_1 = "select a._val, b._val from String a, String b"; + +/** */ +private static final String QRY_2 = "select a._key, count(*) from String a group by a._key"; + +/** */ +private static final String QRY_3 = "select a._val from String a"; + +/** {@inheritDoc} */ +@Override protected void beforeTestsStarted() throws Exception { +super.beforeTestsStarted(); + +startGridsMultiThreaded(GRIDS_CNT); +} + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + +CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); +ccfg.setIndexedTypes(Integer.class, String.class); + +cfg.setCacheConfiguration(ccfg); + +if ("client".equals(igniteInstanceName)) +cfg.setClientMode(true); + +cfg.setDefaultQueryTimeout(DEFAULT_QUERY_TIMEOUT); + +return cfg; +} + +/** {@inheritDoc} */ +@Override protected void afterTest() throws Exception { +super.afterTest(); + +for (Ignite g : G.allGrids()) +g.cache(DEFAULT_CACHE_NAME).removeAll(); +} + +/** */ +@Test +public void testRemoteQueryExecutionTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 500, TimeUnit.MILLISECONDS, true, true); +} + +/** */ +@Test +public void testRemoteQueryWithMergeTableTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_2, 500, TimeUnit.MILLISECONDS, true, false); +} + +/** */ +@Test +public void testRemoteQueryExecutionCancel0() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 1, TimeUnit.MILLISECONDS, false, true); +} + +/** */ +private void testQueryCancel(int keyCnt, int valSize, String sql, int timeoutUnits, TimeUnit timeUnit, +boolean timeout, boolean checkCanceled) throws Exception { +try (Ignite client = startGrid("client")) { +IgniteCache cache =
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r336757891 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,153 @@ +/* + * 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.processors.cache.local; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +import static org.apache.ignite.cache.CacheMode.LOCAL; + +/** + * Tests local query default timeouts. + */ +public class IgniteCacheLocalQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { +/** Cache size. */ +private static final int CACHE_SIZE = 10_000; + +/** Default query timeout */ +private static final long DEFAULT_QUERY_TIMEOUT = 1000; + +/** */ +private static final String QUERY = "select a._val, b._val from String a, String b"; + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + +CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); +ccfg.setIndexedTypes(Integer.class, String.class); +ccfg.setCacheMode(LOCAL); + +cfg.setCacheConfiguration(ccfg); +cfg.setDefaultQueryTimeout(DEFAULT_QUERY_TIMEOUT); + +return cfg; +} + +/** {@inheritDoc} */ +@Override protected void beforeTestsStarted() throws Exception { +super.beforeTestsStarted(); + +startGrid(0); +} + +/** {@inheritDoc} */ +@Override protected void afterTest() throws Exception { +super.afterTest(); + +for (Ignite g : G.allGrids()) +g.cache(DEFAULT_CACHE_NAME).removeAll(); +} + +/** + * @param cache Cache. + */ +private void loadCache(IgniteCache cache) { +int p = 1; + +for (int i = 1; i <= CACHE_SIZE; i++) { +char[] tmp = new char[256]; +Arrays.fill(tmp, ' '); +cache.put(i, new String(tmp)); + +if (i / (float)CACHE_SIZE >= p / 10f) { +log().info("Loaded " + i + " of " + CACHE_SIZE); + +p++; +} +} +} + +/** + * Tests query execution with default query timeout. + */ +@Test +public void testQueryZeroTimeout() { +testQuery(false, 1, TimeUnit.MILLISECONDS); +} + +/** + * Tests query execution with query timeout. + */ +@Test +public void testQueryTimeout() { +testQuery(true, 1, TimeUnit.SECONDS); +} + +/** + * Tests cancellation. + */ +private void testQuery(boolean timeout, int timeoutUnits, TimeUnit timeUnit) { +Ignite ignite = grid(0); + +IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); + +loadCache(cache); + +SqlFieldsQuery qry = new SqlFieldsQuery(QUERY); + +final QueryCursor> cursor; +if (timeout) { +qry.setTimeout(timeoutUnits, timeUnit); + +cursor = cache.query(qry); +} else { Review comment: updated the PR 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: us...@infra.apache.org With regards, Apache Git
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r336757876 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,200 @@ +/* + * 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.processors.cache.distributed.near; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.internal.processors.GridProcessor; +import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests distributed SQL queries default timeouts. + */ +public class IgniteCacheDistributedQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { Review comment: added the test in IgniteBinaryCacheQueryTestSuite2 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r336757895 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,153 @@ +/* + * 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.processors.cache.local; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +import static org.apache.ignite.cache.CacheMode.LOCAL; + +/** + * Tests local query default timeouts. + */ +public class IgniteCacheLocalQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { +/** Cache size. */ +private static final int CACHE_SIZE = 10_000; + +/** Default query timeout */ +private static final long DEFAULT_QUERY_TIMEOUT = 1000; + +/** */ +private static final String QUERY = "select a._val, b._val from String a, String b"; + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + +CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); +ccfg.setIndexedTypes(Integer.class, String.class); +ccfg.setCacheMode(LOCAL); + +cfg.setCacheConfiguration(ccfg); +cfg.setDefaultQueryTimeout(DEFAULT_QUERY_TIMEOUT); + +return cfg; +} + +/** {@inheritDoc} */ +@Override protected void beforeTestsStarted() throws Exception { +super.beforeTestsStarted(); + +startGrid(0); +} + +/** {@inheritDoc} */ +@Override protected void afterTest() throws Exception { +super.afterTest(); + +for (Ignite g : G.allGrids()) +g.cache(DEFAULT_CACHE_NAME).removeAll(); +} + +/** + * @param cache Cache. + */ +private void loadCache(IgniteCache cache) { +int p = 1; + +for (int i = 1; i <= CACHE_SIZE; i++) { +char[] tmp = new char[256]; +Arrays.fill(tmp, ' '); +cache.put(i, new String(tmp)); + +if (i / (float)CACHE_SIZE >= p / 10f) { +log().info("Loaded " + i + " of " + CACHE_SIZE); + +p++; +} +} +} + +/** + * Tests query execution with default query timeout. + */ +@Test +public void testQueryZeroTimeout() { +testQuery(false, 1, TimeUnit.MILLISECONDS); +} + +/** + * Tests query execution with query timeout. + */ +@Test +public void testQueryTimeout() { +testQuery(true, 1, TimeUnit.SECONDS); +} + +/** + * Tests cancellation. + */ +private void testQuery(boolean timeout, int timeoutUnits, TimeUnit timeUnit) { +Ignite ignite = grid(0); + +IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); + +loadCache(cache); + +SqlFieldsQuery qry = new SqlFieldsQuery(QUERY); + +final QueryCursor> cursor; +if (timeout) { +qry.setTimeout(timeoutUnits, timeUnit); + +cursor = cache.query(qry); +} else { +cursor = cache.query(qry); + +ignite.scheduler().runLocal(new Runnable() { +@Override public void run() { +cursor.close(); +} +}, timeoutUnits, timeUnit); +} + +try(QueryCursor> ignored = cursor) { Review comment: yes, updated the PR
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r336757887 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,153 @@ +/* + * 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.processors.cache.local; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +import static org.apache.ignite.cache.CacheMode.LOCAL; + +/** + * Tests local query default timeouts. + */ +public class IgniteCacheLocalQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { +/** Cache size. */ +private static final int CACHE_SIZE = 10_000; + +/** Default query timeout */ +private static final long DEFAULT_QUERY_TIMEOUT = 1000; + +/** */ +private static final String QUERY = "select a._val, b._val from String a, String b"; + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + +CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); +ccfg.setIndexedTypes(Integer.class, String.class); +ccfg.setCacheMode(LOCAL); + +cfg.setCacheConfiguration(ccfg); +cfg.setDefaultQueryTimeout(DEFAULT_QUERY_TIMEOUT); + +return cfg; +} + +/** {@inheritDoc} */ +@Override protected void beforeTestsStarted() throws Exception { +super.beforeTestsStarted(); + +startGrid(0); +} + +/** {@inheritDoc} */ +@Override protected void afterTest() throws Exception { +super.afterTest(); + +for (Ignite g : G.allGrids()) Review comment: updated the PR 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r336757873 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,153 @@ +/* + * 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.processors.cache.local; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +import static org.apache.ignite.cache.CacheMode.LOCAL; + +/** + * Tests local query default timeouts. + */ +public class IgniteCacheLocalQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { Review comment: added the test in IgniteBinaryCacheQueryTestSuite2 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r336756445 ## File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryDefaultTimeoutSelfTest.java ## @@ -0,0 +1,200 @@ +/* + * 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.processors.cache.distributed.near; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.cache.query.QueryCancelledException; +import org.apache.ignite.internal.processors.GridProcessor; +import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests distributed SQL queries default timeouts. + */ +public class IgniteCacheDistributedQueryDefaultTimeoutSelfTest extends GridCommonAbstractTest { +/** Grids count. */ +private static final int GRIDS_CNT = 3; + +/** Cache size. */ +public static final int CACHE_SIZE = 10_000; + +/** Default query timeout */ +private static final long DEFAULT_QUERY_TIMEOUT = 1000; + +/** Value size. */ +public static final int VAL_SIZE = 16; + +/** */ +private static final String QRY_1 = "select a._val, b._val from String a, String b"; + +/** */ +private static final String QRY_2 = "select a._key, count(*) from String a group by a._key"; + +/** */ +private static final String QRY_3 = "select a._val from String a"; + +/** {@inheritDoc} */ +@Override protected void beforeTestsStarted() throws Exception { +super.beforeTestsStarted(); + +startGridsMultiThreaded(GRIDS_CNT); +} + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + +CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); +ccfg.setIndexedTypes(Integer.class, String.class); + +cfg.setCacheConfiguration(ccfg); + +if ("client".equals(igniteInstanceName)) +cfg.setClientMode(true); + +cfg.setDefaultQueryTimeout(DEFAULT_QUERY_TIMEOUT); + +return cfg; +} + +/** {@inheritDoc} */ +@Override protected void afterTest() throws Exception { +super.afterTest(); + +for (Ignite g : G.allGrids()) +g.cache(DEFAULT_CACHE_NAME).removeAll(); +} + +/** */ +@Test +public void testRemoteQueryExecutionTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 500, TimeUnit.MILLISECONDS, true, true); +} + +/** */ +@Test +public void testRemoteQueryWithMergeTableTimeout() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_2, 500, TimeUnit.MILLISECONDS, true, false); +} + +/** */ +@Test +public void testRemoteQueryExecutionCancel0() throws Exception { +testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 1, TimeUnit.MILLISECONDS, false, true); +} + +/** */ +private void testQueryCancel(int keyCnt, int valSize, String sql, int timeoutUnits, TimeUnit timeUnit, +boolean timeout, boolean checkCanceled) throws Exception { +try (Ignite client = startGrid("client")) { +IgniteCache cache =
[GitHub] [ignite] samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout
samaitra commented on a change in pull request #6490: IGNITE-7285 Add default query timeout URL: https://github.com/apache/ignite/pull/6490#discussion_r326871383 ## File path: modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java ## @@ -134,6 +135,49 @@ public QueryParserResult parse(String schemaName, SqlFieldsQuery qry, boolean re return res; } +/** + * Create parameters from query. + * + * @param qry Query. + * @return Parameters. + */ +public QueryParameters fromQuery(SqlFieldsQuery qry) { +NestedTxMode nestedTxMode = NestedTxMode.DEFAULT; +boolean autoCommit = true; +List batchedArgs = null; + +if (qry instanceof SqlFieldsQueryEx) { +SqlFieldsQueryEx qry0 = (SqlFieldsQueryEx)qry; + +if (qry0.getNestedTxMode() != null) +nestedTxMode = qry0.getNestedTxMode(); + +autoCommit = qry0.isAutoCommit(); + +batchedArgs = qry0.batchedArguments(); +} + +int timeout = 0; + +if (qry.getTimeout() > 0) +timeout = qry.getTimeout(); +else +timeout = (int)idx.kernalContext().config().getDefaultQueryTimeout(); Review comment: yes, we validate timeout in `QueryUtils.validateTimeout` which is invoked inside `SqlFieldsQuery.setTimeout`. I think `int` is mainly used since we check remaining timeout in IgniteH2Indexing.operationTimeout using Math.min/Math.max methods 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: us...@infra.apache.org With regards, Apache Git Services