This is an automated email from the ASF dual-hosted git repository.
timoninmaxim pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 2f75257f8cc IGNITE-23397: Remove deprecated SpiQuery (#12376)
2f75257f8cc is described below
commit 2f75257f8ccbc1af4c54d542fa96fe151b52784e
Author: Kirill Anisimov <[email protected]>
AuthorDate: Fri Oct 17 14:14:03 2025 +0700
IGNITE-23397: Remove deprecated SpiQuery (#12376)
---
.../main/java/org/apache/ignite/IgniteCache.java | 2 -
.../java/org/apache/ignite/cache/query/Query.java | 2 -
.../org/apache/ignite/cache/query/SpiQuery.java | 80 -----
.../processors/cache/IgniteCacheProxyImpl.java | 21 +-
.../processors/cache/query/CacheQuery.java | 7 +-
.../cache/query/GridCacheQueryManager.java | 94 +-----
.../cache/query/GridCacheQueryRequest.java | 5 +-
.../main/resources/META-INF/classnames.properties | 1 -
.../query/GridCacheQueryTransformerSelfTest.java | 14 -
.../cache/query/IndexingSpiQuerySelfTest.java | 365 ---------------------
.../IndexingSpiQueryWithH2IndexingSelfTest.java | 36 --
.../query/IgniteQueryDedicatedPoolTest.java | 26 --
.../IgniteBinaryCacheQueryTestSuite.java | 4 -
13 files changed, 21 insertions(+), 636 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 1bfa2f0f6e8..da39381ff47 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -51,7 +51,6 @@ import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.QueryDetailMetrics;
import org.apache.ignite.cache.query.QueryMetrics;
import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.cache.query.SpiQuery;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.TextQuery;
import org.apache.ignite.cache.store.CacheStore;
@@ -425,7 +424,6 @@ public interface IgniteCache<K, V> extends
javax.cache.Cache<K, V>, IgniteAsyncS
* @see ScanQuery
* @see SqlFieldsQuery
* @see TextQuery
- * @see SpiQuery
*
*/
public <R> QueryCursor<R> query(Query<R> qry);
diff --git
a/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
b/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
index c2a1daa2380..cfd58d298cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
@@ -37,8 +37,6 @@ import org.apache.ignite.internal.util.typedef.internal.S;
* See {@link ScanQuery} for details.</li>
* <li><b>Continuous query.</b> Provides flexible way to process all existed
cache data and all future cache updates as well.
* See {@link ContinuousQuery} for details.</li>
- * <li><b>Spi query.</b> Allow run queries for pluggable user query engine
implementation.
- * See {@link SpiQuery} for details.</li>
* </ul>
*
* @see IgniteCache#query(Query)
diff --git
a/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java
b/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java
deleted file mode 100644
index cc56ddbcbe1..00000000000
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.cache.query;
-
-import javax.cache.Cache;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.spi.indexing.IndexingSpi;
-
-/**
- * Query to be used by {@link IndexingSpi} implementations.
- *
- * @see IgniteCache#query(Query)
- * @see ScanQuery
- * @see SqlFieldsQuery
- * @see IndexQuery
- *
- * @deprecated Use {@link ScanQuery}, {@link SqlFieldsQuery}, {@link
IndexQuery} instead.
- */
-@Deprecated
-public final class SpiQuery<K, V> extends Query<Cache.Entry<K, V>> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Arguments. */
- @GridToStringInclude
- private Object[] args;
-
- /**
- * Gets SQL arguments.
- *
- * @return SQL arguments.
- */
- public Object[] getArgs() {
- return args;
- }
-
- /**
- * Sets SQL arguments.
- *
- * @param args SQL arguments.
- * @return {@code this} For chaining.
- */
- public SpiQuery<K, V> setArgs(Object... args) {
- this.args = args;
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public SpiQuery<K, V> setPageSize(int pageSize) {
- return (SpiQuery<K, V>)super.setPageSize(pageSize);
- }
-
- /** {@inheritDoc} */
- @Override public SpiQuery<K, V> setLocal(boolean loc) {
- return (SpiQuery<K, V>)super.setLocal(loc);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(SpiQuery.class, this);
- }
-}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
index a11b583c041..629bb9433cb 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
@@ -68,7 +68,6 @@ import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.QueryDetailMetrics;
import org.apache.ignite.cache.query.QueryMetrics;
import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.cache.query.SpiQuery;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.cache.query.TextQuery;
@@ -525,19 +524,6 @@ public class IgniteCacheProxyImpl<K, V> extends
AsyncSupportAdapter<IgniteCache<
}
}, false);
}
- else if (query instanceof SpiQuery) {
- qry = ctx.queries().createSpiQuery(isKeepBinary);
-
- if (grp != null)
- qry.projection(grp);
-
- fut =
ctx.kernalContext().query().executeQuery(GridCacheQueryType.SPI,
query.getClass().getSimpleName(),
- ctx, new IgniteOutClosureX<CacheQueryFuture<Map.Entry<K,
V>>>() {
- @Override public CacheQueryFuture<Map.Entry<K, V>>
applyx() {
- return qry.execute(((SpiQuery)query).getArgs());
- }
- }, false);
- }
else if (query instanceof IndexQuery) {
IndexQuery q = (IndexQuery)query;
@@ -867,11 +853,6 @@ public class IgniteCacheProxyImpl<K, V> extends
AsyncSupportAdapter<IgniteCache<
convertToBinary(sqlQry.getArgs());
}
- else if (qry instanceof SpiQuery) {
- final SpiQuery spiQry = (SpiQuery)qry;
-
- convertToBinary(spiQry.getArgs());
- }
else if (qry instanceof SqlFieldsQuery) {
final SqlFieldsQuery fieldsQry = (SqlFieldsQuery)qry;
@@ -905,7 +886,7 @@ public class IgniteCacheProxyImpl<K, V> extends
AsyncSupportAdapter<IgniteCache<
if (!QueryUtils.isEnabled(ctx.config()) && !(qry instanceof ScanQuery)
&&
!(qry instanceof ContinuousQuery) && !(qry instanceof
ContinuousQueryWithTransformer) &&
- !(qry instanceof SpiQuery) && !(qry instanceof SqlQuery) && !(qry
instanceof SqlFieldsQuery) &&
+ !(qry instanceof SqlQuery) && !(qry instanceof SqlFieldsQuery) &&
!(qry instanceof IndexQuery))
throw new CacheException("Indexing is disabled for cache: " +
cacheName +
". Use setIndexedTypes or setTypeMetadata methods on
CacheConfiguration to enable.");
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
index 36fa60bc81d..6f394c2efce 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
@@ -79,7 +79,6 @@ import org.jetbrains.annotations.Nullable;
import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.INDEX;
import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SCAN;
import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SET;
-import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SPI;
import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SQL_FIELDS;
/**
@@ -336,7 +335,7 @@ public class CacheQuery<T> {
}
/**
- * Cache query adapter for SET, SPI, TEXT queries.
+ * Cache query adapter for SET, TEXT queries.
*
* @param cctx Context.
* @param type Query type.
@@ -653,7 +652,7 @@ public class CacheQuery<T> {
/** @throws IgniteCheckedException If query is invalid. */
public void validate() throws IgniteCheckedException {
- if ((type != SCAN && type != SET && type != SPI && type != INDEX)
+ if ((type != SCAN && type != SET && type != INDEX)
&& !QueryUtils.isEnabled(cctx.config()))
throw new IgniteCheckedException("Indexing is disabled for cache:
" + cctx.cache().name());
}
@@ -733,7 +732,7 @@ public class CacheQuery<T> {
boolean loc = nodes.size() == 1 &&
F.first(nodes).id().equals(cctx.localNodeId());
- if (type == SQL_FIELDS || type == SPI)
+ if (type == SQL_FIELDS)
return (CacheQueryFuture<R>)(loc ? qryMgr.queryFieldsLocal(bean) :
qryMgr.queryFieldsDistributed(bean, nodes));
else
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 6bfa2e616a2..dca2630eb61 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -125,7 +125,6 @@ import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.spi.IgniteSpiCloseableIterator;
import org.apache.ignite.spi.indexing.IndexingQueryFilter;
import org.apache.ignite.spi.indexing.IndexingQueryFilterImpl;
-import org.apache.ignite.spi.indexing.IndexingSpi;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -139,7 +138,6 @@ import static
org.apache.ignite.internal.processors.cache.distributed.dht.topolo
import static
org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING;
import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.INDEX;
import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SCAN;
-import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SPI;
import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SQL_FIELDS;
import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.TEXT;
import static
org.apache.ignite.internal.processors.security.SecurityUtils.securitySubjectId;
@@ -655,12 +653,9 @@ public abstract class GridCacheQueryManager<K, V> extends
GridCacheManagerAdapte
private FieldsResult executeFieldsQuery(CacheQuery<?> qry, @Nullable
Object[] args,
boolean loc, @Nullable String taskName, Object rcpt) throws
IgniteCheckedException {
assert qry != null;
+ assert qry.type() == SQL_FIELDS : "Unexpected query type: " +
qry.type();
- FieldsResult res;
-
- T2<String, List<Object>> resKey = null;
-
- if (qry.clause() == null && qry.type() != SPI) {
+ if (qry.clause() == null) {
assert !loc;
throw new IgniteCheckedException("Received next page request after
iterator was removed. " +
@@ -668,9 +663,8 @@ public abstract class GridCacheQueryManager<K, V> extends
GridCacheManagerAdapte
"CacheConfiguration.getMaxQueryIteratorsCount() configuration
property).");
}
- if (qry.type() == SQL_FIELDS) {
- if (cctx.events().isRecordable(EVT_CACHE_QUERY_EXECUTED)) {
- cctx.gridEvents().record(new CacheQueryExecutedEvent<>(
+ if (cctx.events().isRecordable(EVT_CACHE_QUERY_EXECUTED)) {
+ cctx.gridEvents().record(new CacheQueryExecutedEvent<>(
cctx.localNode(),
"SQL fields query executed.",
EVT_CACHE_QUERY_EXECUTED,
@@ -683,63 +677,23 @@ public abstract class GridCacheQueryManager<K, V> extends
GridCacheManagerAdapte
args,
securitySubjectId(cctx),
taskName));
- }
-
- // Attempt to get result from cache.
- resKey = new T2<>(qry.clause(), F.asList(args));
-
- res = (FieldsResult)qryResCache.get(resKey);
-
- if (res != null && res.addRecipient(rcpt))
- return res; // Cached result found.
-
- res = new FieldsResult(rcpt);
-
- if (qryResCache.putIfAbsent(resKey, res) != null)
- resKey = null; // Failed to cache result.
}
- else {
- assert qry.type() == SPI : "Unexpected query type: " + qry.type();
- if (cctx.events().isRecordable(EVT_CACHE_QUERY_EXECUTED)) {
- cctx.gridEvents().record(new CacheQueryExecutedEvent<>(
- cctx.localNode(),
- "SPI query executed.",
- EVT_CACHE_QUERY_EXECUTED,
- CacheQueryType.SPI.name(),
- cctx.name(),
- null,
- null,
- null,
- null,
- args,
- securitySubjectId(cctx),
- taskName));
- }
+ // Attempt to get result from cache.
+ T2<String, List<Object>> resKey = new T2<>(qry.clause(),
F.asList(args));
- res = new FieldsResult(rcpt);
- }
+ FieldsResult res = (FieldsResult)qryResCache.get(resKey);
- try {
- if (qry.type() == SPI) {
- IgniteSpiCloseableIterator<?> iter =
cctx.kernalContext().indexing().query(cacheName, F.asList(args),
- filter(qry));
+ if (res != null && res.addRecipient(rcpt))
+ return res; // Cached result found.
- res.onDone(iter);
- }
- else {
- assert qry.type() == SQL_FIELDS;
+ res = new FieldsResult(rcpt);
- throw new IllegalStateException("Should never be called.");
- }
- }
- catch (Exception e) {
- res.onDone(e);
- }
- finally {
- if (resKey != null)
- qryResCache.remove(resKey, res);
- }
+ if (qryResCache.putIfAbsent(resKey, res) != null)
+ resKey = null; // Failed to cache result.
+
+ if (resKey != null)
+ qryResCache.remove(resKey, res);
return res;
}
@@ -2827,24 +2781,6 @@ public abstract class GridCacheQueryManager<K, V>
extends GridCacheManagerAdapte
}
}
- /**
- * Query for {@link IndexingSpi}.
- *
- * @param keepBinary Keep binary flag.
- * @return Query.
- */
- public <R> CacheQuery<R> createSpiQuery(boolean keepBinary) {
- return new CacheQuery<>(cctx,
- SPI,
- null,
- null,
- null,
- keepBinary,
- false,
- null,
- null);
- }
-
/**
* Creates user's predicate based scan query.
*
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
index 2bb1840db43..132d11b356f 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
@@ -46,7 +46,6 @@ import org.jetbrains.annotations.Nullable;
import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.INDEX;
import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SCAN;
import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SET;
-import static
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SPI;
/**
* Query request.
@@ -362,8 +361,8 @@ public class GridCacheQueryRequest extends
GridCacheIdMessage implements GridCac
@Nullable Collection<KeyCacheObject> skipKeys
) {
assert type != null || fields;
- assert clause != null || (type == SCAN || type == SET || type == SPI
|| type == INDEX);
- assert clsName != null || fields || type == SCAN || type == SET ||
type == SPI;
+ assert clause != null || (type == SCAN || type == SET || type ==
INDEX);
+ assert clsName != null || fields || type == SCAN || type == SET;
this.cacheId = cacheId;
this.id = id;
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties
b/modules/core/src/main/resources/META-INF/classnames.properties
index 014ebcbb49b..ce5be10be7d 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -81,7 +81,6 @@ org.apache.ignite.cache.query.Query
org.apache.ignite.cache.query.QueryCancelledException
org.apache.ignite.cache.query.QueryRetryException
org.apache.ignite.cache.query.ScanQuery
-org.apache.ignite.cache.query.SpiQuery
org.apache.ignite.cache.query.SqlFieldsQuery
org.apache.ignite.cache.query.SqlQuery
org.apache.ignite.cache.query.TextQuery
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryTransformerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryTransformerSelfTest.java
index 8dd8fac3477..e6988d57455 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryTransformerSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryTransformerSelfTest.java
@@ -33,7 +33,6 @@ import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cache.query.ContinuousQuery;
import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.cache.query.SpiQuery;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.cache.query.TextQuery;
@@ -559,19 +558,6 @@ public class GridCacheQueryTransformerSelfTest extends
AbstractTransactionalQuer
"Transformers are supported only for SCAN queries."
);
- GridTestUtils.assertThrows(
- log,
- new Callable<Object>() {
- @Override public Object call() throws Exception {
- cache.query(new SpiQuery<Integer, Integer>(),
transformer);
-
- return null;
- }
- },
- UnsupportedOperationException.class,
- "Transformers are supported only for SCAN queries."
- );
-
GridTestUtils.assertThrows(
log,
new Callable<Object>() {
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
deleted file mode 100644
index 2afd595b52a..00000000000
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * 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.query;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.concurrent.Callable;
-import javax.cache.Cache;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteSystemProperties;
-import org.apache.ignite.IgniteTransactions;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.SpiQuery;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
-import
org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
-import org.apache.ignite.spi.IgniteSpiAdapter;
-import org.apache.ignite.spi.IgniteSpiException;
-import org.apache.ignite.spi.indexing.IndexingQueryFilter;
-import org.apache.ignite.spi.indexing.IndexingSpi;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.apache.ignite.transactions.Transaction;
-import org.apache.ignite.transactions.TransactionConcurrency;
-import org.apache.ignite.transactions.TransactionIsolation;
-import org.apache.ignite.transactions.TransactionState;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.junit.Test;
-
-/**
- * Indexing Spi query only test
- */
-public class IndexingSpiQuerySelfTest extends GridCommonAbstractTest {
- /** */
- private IndexingSpi indexingSpi;
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- cfg.setIndexingSpi(indexingSpi);
-
- return cfg;
- }
-
- /** */
- protected <K, V> CacheConfiguration<K, V> cacheConfiguration(String
cacheName) {
- return new CacheConfiguration<>(cacheName);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- stopAllGrids();
- }
-
- /**
- * @throws Exception If failed.
- */
- @Test
- public void testSimpleIndexingSpi() throws Exception {
- indexingSpi = new MyIndexingSpi();
-
- Ignite ignite = startGrid(0);
-
- CacheConfiguration<Integer, Integer> ccfg =
cacheConfiguration(DEFAULT_CACHE_NAME);
-
- IgniteCache<Integer, Integer> cache = ignite.createCache(ccfg);
-
- for (int i = 0; i < 10; i++)
- cache.put(i, i);
-
- QueryCursor<Cache.Entry<Integer, Integer>> cursor = cache.query(new
SpiQuery<Integer, Integer>().setArgs(2, 5));
-
- for (Cache.Entry<Integer, Integer> entry : cursor)
- System.out.println(entry);
- }
-
- /**
- * @throws Exception If failed.
- */
- @Test
- public void testIndexingSpiWithDisabledQueryProcessor() throws Exception {
- indexingSpi = new MyIndexingSpi();
-
- Ignite ignite = startGrid(0);
-
- CacheConfiguration<Integer, Integer> ccfg =
cacheConfiguration(DEFAULT_CACHE_NAME);
-
- IgniteCache<Integer, Integer> cache = ignite.createCache(ccfg);
-
- for (int i = 0; i < 10; i++)
- cache.put(i, i);
-
- QueryCursor<Cache.Entry<Integer, Integer>> cursor = cache.query(new
SpiQuery<Integer, Integer>().setArgs(2, 5));
-
- for (Cache.Entry<Integer, Integer> entry : cursor)
- System.out.println(entry);
- }
-
- /**
- * @throws Exception If failed.
- */
- @Test
- public void testBinaryIndexingSpi() throws Exception {
- indexingSpi = new MyBinaryIndexingSpi();
-
- Ignite ignite = startGrid(0);
-
- CacheConfiguration<PersonKey, Person> ccfg =
cacheConfiguration(DEFAULT_CACHE_NAME);
-
- IgniteCache<PersonKey, Person> cache = ignite.createCache(ccfg);
-
- for (int i = 0; i < 10; i++) {
- PersonKey key = new PersonKey(i);
-
- cache.put(key, new Person("John Doe " + i));
- }
-
- QueryCursor<Cache.Entry<PersonKey, Person>> cursor = cache.query(
- new SpiQuery<PersonKey, Person>().setArgs(new PersonKey(2), new
PersonKey(5)));
-
- for (Cache.Entry<PersonKey, Person> entry : cursor)
- System.out.println(entry);
-
- cache.remove(new PersonKey(9));
- }
-
-
- /**
- * @throws Exception If failed.
- */
- @Test
- public void testNonBinaryIndexingSpi() throws Exception {
-
System.setProperty(IgniteSystemProperties.IGNITE_UNWRAP_BINARY_FOR_INDEXING_SPI,
"true");
-
- try {
- indexingSpi = new MyIndexingSpi();
-
- Ignite ignite = startGrid(0);
-
- CacheConfiguration<PersonKey, Person> ccfg =
cacheConfiguration(DEFAULT_CACHE_NAME);
-
- IgniteCache<PersonKey, Person> cache = ignite.createCache(ccfg);
-
- for (int i = 0; i < 10; i++) {
- PersonKey key = new PersonKey(i);
-
- cache.put(key, new Person("John Doe " + i));
- }
-
- QueryCursor<Cache.Entry<PersonKey, Person>> cursor = cache.query(
- new SpiQuery<PersonKey, Person>().setArgs(new PersonKey(2),
new PersonKey(5)));
-
- for (Cache.Entry<PersonKey, Person> entry : cursor)
- System.out.println(entry);
-
- cache.remove(new PersonKey(9));
- }
- finally {
-
System.clearProperty(IgniteSystemProperties.IGNITE_UNWRAP_BINARY_FOR_INDEXING_SPI);
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- @Test
- public void testIndexingSpiFailure() throws Exception {
- indexingSpi = new MyBrokenIndexingSpi();
-
- Ignite ignite = startGrid(0);
-
- CacheConfiguration<Integer, Integer> ccfg =
cacheConfiguration(DEFAULT_CACHE_NAME);
-
- ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-
- final IgniteCache<Integer, Integer> cache = ignite.createCache(ccfg);
-
- final IgniteTransactions txs = ignite.transactions();
-
- for (final TransactionConcurrency concurrency :
TransactionConcurrency.values()) {
- for (final TransactionIsolation isolation :
TransactionIsolation.values()) {
- System.out.println("Run in transaction: " + concurrency + " "
+ isolation);
-
- GridTestUtils.assertThrowsWithCause(new Callable<Void>() {
- @Override public Void call() throws Exception {
- Transaction tx;
-
- try (Transaction tx0 = tx = txs.txStart(concurrency,
isolation)) {
- cache.put(1, 1);
-
- tx0.commit();
- }
-
- assertEquals(TransactionState.ROLLED_BACK, tx.state());
- return null;
- }
- }, IgniteTxHeuristicCheckedException.class);
- }
- }
- }
-
- /**
- * Indexing Spi implementation for test
- */
- private static class MyIndexingSpi extends IgniteSpiAdapter implements
IndexingSpi {
- /** Index. */
- private final SortedMap<Object, Object> idx = new TreeMap<>();
-
- /** {@inheritDoc} */
- @Override public void spiStart(@Nullable String igniteInstanceName)
throws IgniteSpiException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void spiStop() throws IgniteSpiException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public Iterator<Cache.Entry<?, ?>> query(@Nullable String
cacheName, Collection<Object> params,
- @Nullable IndexingQueryFilter filters) throws IgniteSpiException {
- if (params.size() < 2)
- throw new IgniteSpiException("Range parameters required.");
-
- Iterator<Object> paramsIt = params.iterator();
-
- Object from = paramsIt.next();
- Object to = paramsIt.next();
-
- from = from instanceof BinaryObject ?
((BinaryObject)from).deserialize() : from;
- to = to instanceof BinaryObject ? ((BinaryObject)to).deserialize()
: to;
-
- SortedMap<Object, Object> map = idx.subMap(from, to);
-
- Collection<Cache.Entry<?, ?>> res = new ArrayList<>(map.size());
-
- for (Map.Entry<Object, Object> entry : map.entrySet())
- res.add(new CacheEntryImpl<>(entry.getKey(),
entry.getValue()));
-
- return res.iterator();
- }
-
- /** {@inheritDoc} */
- @Override public void store(@Nullable String cacheName, Object key,
Object val, long expirationTime)
- throws IgniteSpiException {
- assertFalse(key instanceof BinaryObject);
- assertFalse(val instanceof BinaryObject);
-
- idx.put(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public void remove(@Nullable String cacheName, Object key)
throws IgniteSpiException {
- // No-op.
- }
- }
-
- /**
- * Indexing Spi implementation for test. Accepts binary objects only
- */
- private static class MyBinaryIndexingSpi extends MyIndexingSpi {
-
- /** {@inheritDoc} */
- @Override public void store(@Nullable String cacheName, Object key,
Object val,
- long expirationTime) throws IgniteSpiException {
- assertTrue(key instanceof BinaryObject);
-
- assertTrue(val instanceof BinaryObject);
-
- super.store(cacheName, ((BinaryObject)key).deserialize(),
((BinaryObject)val).deserialize(), expirationTime);
- }
-
- /** {@inheritDoc} */
- @Override public void remove(@Nullable String cacheName, Object key)
throws IgniteSpiException {
- assertTrue(key instanceof BinaryObject);
- }
- }
-
- /**
- * Broken Indexing Spi implementation for test
- */
- private static class MyBrokenIndexingSpi extends MyIndexingSpi {
- /** {@inheritDoc} */
- @Override public void store(@Nullable String cacheName, Object key,
Object val,
- long expirationTime) throws IgniteSpiException {
- throw new IgniteSpiException("Test exception");
- }
- }
-
- /**
- *
- */
- static class PersonKey implements Serializable, Comparable<PersonKey> {
- /** */
- private int id;
-
- /** */
- public PersonKey(int id) {
- this.id = id;
- }
-
- /** {@inheritDoc} */
- @Override public int compareTo(@NotNull PersonKey o) {
- return Integer.compare(id, o.id);
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
-
- PersonKey key = (PersonKey)o;
-
- return id == key.id;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return id;
- }
- }
-
- /**
- *
- */
- static class Person implements Serializable {
- /** */
- private String name;
-
- /** */
- Person(String name) {
- this.name = name;
- }
- }
-}
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryWithH2IndexingSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryWithH2IndexingSelfTest.java
deleted file mode 100644
index 954fc7f75ee..00000000000
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryWithH2IndexingSelfTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.query;
-
-import org.apache.ignite.configuration.CacheConfiguration;
-
-/**
- * Indexing Spi query with configured default indexer test
- */
-public class IndexingSpiQueryWithH2IndexingSelfTest extends
IndexingSpiQuerySelfTest {
- /** */
- @Override protected <K, V> CacheConfiguration<K, V>
cacheConfiguration(String cacheName) {
- CacheConfiguration<K, V> ccfg = super.cacheConfiguration(cacheName);
-
- ccfg.setIndexedTypes(PersonKey.class, Person.class);
-
- ccfg.setIndexedTypes(Integer.class, Integer.class);
-
- return ccfg;
- }
-}
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java
index 424771a84ea..000f1806381 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java
@@ -30,7 +30,6 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.cache.query.SpiQuery;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlFunction;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -162,31 +161,6 @@ public class IgniteQueryDedicatedPoolTest extends
GridCommonAbstractTest {
}
}
- /**
- * Tests that SPI queries are executed in dedicated pool
- * @throws Exception If failed.
- */
- @Test
- public void testSpiQueryUsesDedicatedThreadPool() throws Exception {
- startGrid("server");
-
- try (Ignite client = startClientGrid("client")) {
- IgniteCache<Byte, Byte> cache = client.cache(CACHE_NAME);
-
- for (byte b = 0; b < Byte.MAX_VALUE; ++b)
- cache.put(b, b);
-
- QueryCursor<Cache.Entry<Byte, Byte>> cursor = cache.query(new
SpiQuery<Byte, Byte>());
-
- List<Cache.Entry<Byte, Byte>> all = cursor.getAll();
-
- assertEquals(1, all.size());
- assertEquals(GridIoPolicy.QUERY_POOL, (byte)all.get(0).getValue());
-
- cursor.close();
- }
- }
-
/**
* Test for messages about query pool starvation in the logs.
*
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
index e5d4ef15244..90137635fbb 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
@@ -114,9 +114,7 @@ import
org.apache.ignite.internal.processors.cache.query.CacheDataPageScanQueryT
import
org.apache.ignite.internal.processors.cache.query.CacheScanQueryFailoverTest;
import
org.apache.ignite.internal.processors.cache.query.GridCacheQueryTransformerSelfTest;
import org.apache.ignite.internal.processors.cache.query.GridCircularQueueTest;
-import
org.apache.ignite.internal.processors.cache.query.IndexingSpiQuerySelfTest;
import
org.apache.ignite.internal.processors.cache.query.IndexingSpiQueryTxSelfTest;
-import
org.apache.ignite.internal.processors.cache.query.IndexingSpiQueryWithH2IndexingSelfTest;
import
org.apache.ignite.internal.processors.cache.transaction.DmlInsideTransactionTest;
import
org.apache.ignite.internal.processors.client.ClientConnectorConfigurationValidationSelfTest;
import
org.apache.ignite.internal.processors.database.baseline.IgniteStableBaselineBinObjFieldsQuerySelfTest;
@@ -305,7 +303,6 @@ import org.junit.runners.Suite;
IgniteBinaryObjectQueryArgumentsTest.class,
IgniteBinaryObjectLocalQueryArgumentsTest.class,
- IndexingSpiQuerySelfTest.class,
IndexingSpiQueryTxSelfTest.class,
IgniteCacheMultipleIndexedTypesTest.class,
@@ -313,7 +310,6 @@ import org.junit.runners.Suite;
IgniteSqlQueryStartFinishListenerTest.class,
GridCircularQueueTest.class,
- IndexingSpiQueryWithH2IndexingSelfTest.class,
// DDL.
H2DynamicIndexTransactionalReplicatedSelfTest.class,