IGNITE-3443 WIP.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/aebeffea Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/aebeffea Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/aebeffea Branch: refs/heads/ignite-3443 Commit: aebeffeafbe06153078dc35d0d235dde4e9a79fd Parents: 0c5e84f Author: Alexey Kuznetsov <akuznet...@apache.org> Authored: Thu Sep 1 18:21:39 2016 +0700 Committer: Alexey Kuznetsov <akuznet...@apache.org> Committed: Thu Sep 1 18:21:39 2016 +0700 ---------------------------------------------------------------------- .../ignite/cache/query/QueryDetailsMetrics.java | 4 ++-- .../processors/cache/IgniteCacheProxy.java | 8 ++++---- .../processors/cache/query/CacheQueryType.java | 20 +------------------- .../cache/query/GridCacheQueryAdapter.java | 2 +- .../GridCacheQueryDetailsMetricsAdapter.java | 6 +++--- .../query/GridCacheQueryFutureAdapter.java | 15 +-------------- .../cache/query/GridCacheQueryManager.java | 6 +++--- .../query/GridCacheQueryMetricsAdapter.java | 10 +++++----- .../processors/query/GridQueryProcessor.java | 18 ++++++++---------- .../cache/VisorCacheQueryDetailsMetrics.java | 6 +++--- 10 files changed, 31 insertions(+), 64 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/aebeffea/modules/core/src/main/java/org/apache/ignite/cache/query/QueryDetailsMetrics.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryDetailsMetrics.java b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryDetailsMetrics.java index fd2d4fa..0ebe5b7 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryDetailsMetrics.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryDetailsMetrics.java @@ -17,7 +17,7 @@ package org.apache.ignite.cache.query; -import org.apache.ignite.internal.processors.cache.query.CacheQueryType; +import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType; /** * Per individual query metrics aggregated by query type and Textual representation. @@ -26,7 +26,7 @@ public interface QueryDetailsMetrics { /** * @return Query type. */ - public CacheQueryType queryType(); + public GridCacheQueryType queryType(); /** * @return Textual representation of query. http://git-wip-us.apache.org/repos/asf/ignite/blob/aebeffea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index ddadcf4..e82c479 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -66,7 +66,7 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.query.CacheQuery; import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture; -import org.apache.ignite.internal.processors.cache.query.CacheQueryType; +import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType; import org.apache.ignite.internal.processors.query.GridQueryProcessor; import org.apache.ignite.internal.util.GridCloseableIteratorAdapter; import org.apache.ignite.internal.util.GridEmptyIterator; @@ -493,7 +493,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V if (grp != null) qry.projection(grp); - final GridCloseableIterator<R> iter = ctx.kernalContext().query().executeQuery(CacheQueryType.SCAN, ctx.name(), ctx, + final GridCloseableIterator<R> iter = ctx.kernalContext().query().executeQuery(GridCacheQueryType.SCAN, ctx.name(), ctx, new IgniteOutClosureX<GridCloseableIterator<R>>() { @Override public GridCloseableIterator<R> applyx() throws IgniteCheckedException { final GridCloseableIterator iter0 = qry.executeScanQuery(); @@ -549,7 +549,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V if (grp != null) qry.projection(grp); - fut = ctx.kernalContext().query().executeQuery(CacheQueryType.FULL_TEXT, p.getText(), ctx, + fut = ctx.kernalContext().query().executeQuery(GridCacheQueryType.TEXT, p.getText(), ctx, new IgniteOutClosureX<CacheQueryFuture<Map.Entry<K, V>>>() { @Override public CacheQueryFuture<Map.Entry<K, V>> applyx() throws IgniteCheckedException { return qry.execute(); @@ -562,7 +562,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V if (grp != null) qry.projection(grp); - fut = ctx.kernalContext().query().executeQuery(CacheQueryType.SPI, "", ctx, + fut = ctx.kernalContext().query().executeQuery(GridCacheQueryType.SPI, "", ctx, new IgniteOutClosureX<CacheQueryFuture<Map.Entry<K, V>>>() { @Override public CacheQueryFuture<Map.Entry<K, V>> applyx() throws IgniteCheckedException { return qry.execute(((SpiQuery)filter).getArgs()); http://git-wip-us.apache.org/repos/asf/ignite/blob/aebeffea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryType.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryType.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryType.java index 0ebe8af..fa0f3df 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryType.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryType.java @@ -17,8 +17,6 @@ package org.apache.ignite.internal.processors.cache.query; -import org.jetbrains.annotations.Nullable; - /** * Cache query type. * <p> @@ -45,21 +43,5 @@ public enum CacheQueryType { CONTINUOUS, /** SPI query. */ - SPI, - - /** Cache set items query. */ - SET; - - /** Enumerated values. */ - private static final CacheQueryType[] VALS = values(); - - /** - * Efficiently gets enumerated value from its ordinal. - * - * @param ord Ordinal value. - * @return Enumerated value. - */ - @Nullable public static CacheQueryType fromOrdinal(byte ord) { - return ord >= 0 && ord < VALS.length ? VALS[ord] : null; - } + SPI } http://git-wip-us.apache.org/repos/asf/ignite/blob/aebeffea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java index 487ec35..32d823a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java @@ -442,7 +442,7 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> { * @param startTime Start time. * @param duration Duration. */ - public void onCompleted(CacheQueryType qryType, String qry, Object res, Throwable err, long startTime, long duration) { + public void onCompleted(GridCacheQueryType qryType, String qry, Object res, Throwable err, long startTime, long duration) { GridQueryProcessor.onCompleted(qryType, qry, cctx, res, err, startTime, duration, log); } http://git-wip-us.apache.org/repos/asf/ignite/blob/aebeffea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryDetailsMetricsAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryDetailsMetricsAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryDetailsMetricsAdapter.java index 6af75f8..cbc144e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryDetailsMetricsAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryDetailsMetricsAdapter.java @@ -33,13 +33,13 @@ public class GridCacheQueryDetailsMetricsAdapter extends GridCacheQueryBaseMetri private static final long serialVersionUID = 0L; /** Query type to track metrics. */ - private CacheQueryType qryType; + private GridCacheQueryType qryType; /** Query text representation. */ private String qry; /** {@inheritDoc} */ - @Override public CacheQueryType queryType() { + @Override public GridCacheQueryType queryType() { return qryType; } @@ -73,7 +73,7 @@ public class GridCacheQueryDetailsMetricsAdapter extends GridCacheQueryBaseMetri @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); - qryType = CacheQueryType.fromOrdinal(in.readByte()); + qryType = GridCacheQueryType.fromOrdinal(in.readByte()); qry = U.readString(in); } http://git-wip-us.apache.org/repos/asf/ignite/blob/aebeffea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java index b759a37..7d0ac20 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java @@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.cache.query; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.EnumMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; @@ -64,18 +63,6 @@ public abstract class GridCacheQueryFutureAdapter<K, V, R> extends GridFutureAda /** */ private static final Object NULL = new Object(); - /** */ - private static final Map<GridCacheQueryType, CacheQueryType> QRY_TYPES = new EnumMap<>(GridCacheQueryType.class); - - static { - QRY_TYPES.put(GridCacheQueryType.SPI, CacheQueryType.SPI); - QRY_TYPES.put(GridCacheQueryType.SCAN, CacheQueryType.SCAN); - QRY_TYPES.put(GridCacheQueryType.SQL, CacheQueryType.SQL); - QRY_TYPES.put(GridCacheQueryType.SQL_FIELDS, CacheQueryType.SQL_FIELDS); - QRY_TYPES.put(GridCacheQueryType.TEXT, CacheQueryType.FULL_TEXT); - QRY_TYPES.put(GridCacheQueryType.SET, CacheQueryType.SET); - } - /** Cache context. */ protected GridCacheContext<K, V> cctx; @@ -170,7 +157,7 @@ public abstract class GridCacheQueryFutureAdapter<K, V, R> extends GridFutureAda GridCacheQueryAdapter<?> qryAdapter = qry.query(); - qry.query().onCompleted(QRY_TYPES.get(qryAdapter.type()), qryAdapter.clause(), res, err, startTime(), duration()); + qry.query().onCompleted(qryAdapter.type(), qryAdapter.clause(), res, err, startTime(), duration()); return super.onDone(res, err); } http://git-wip-us.apache.org/repos/asf/ignite/blob/aebeffea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java ---------------------------------------------------------------------- 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 4c28310..50d4646 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 @@ -1729,7 +1729,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte if (updStatisticsIfNeeded) { needUpdStatistics = false; - cctx.queries().onCompleted(CacheQueryType.SCAN, namex, U.currentTimeMillis() - startTime, false); + cctx.queries().onCompleted(GridCacheQueryType.SCAN, namex, U.currentTimeMillis() - startTime, false); } final boolean readEvt = cctx.gridEvents().isRecordable(EVT_CACHE_QUERY_OBJECT_READ); @@ -1795,7 +1795,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte } catch (Exception e) { if (needUpdStatistics) - cctx.queries().onCompleted(CacheQueryType.SCAN, namex, U.currentTimeMillis() - startTime, true); + cctx.queries().onCompleted(GridCacheQueryType.SCAN, namex, U.currentTimeMillis() - startTime, true); throw e; } @@ -2096,7 +2096,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte * @param duration Execution duration. * @param fail {@code true} if execution failed. */ - public void onCompleted(CacheQueryType qryType, String qry, long duration, boolean fail) { + public void onCompleted(GridCacheQueryType qryType, String qry, long duration, boolean fail) { metrics.onQueryCompleted(qryType, qry, duration, fail); } http://git-wip-us.apache.org/repos/asf/ignite/blob/aebeffea/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryMetricsAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryMetricsAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryMetricsAdapter.java index 5ffeef5..8658f2c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryMetricsAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryMetricsAdapter.java @@ -66,7 +66,7 @@ public class GridCacheQueryMetricsAdapter extends GridCacheQueryBaseMetricsAdapt * @param duration Duration of queue execution. * @param fail {@code True} query executed unsuccessfully {@code false} otherwise. */ - public void onQueryCompleted(CacheQueryType qryType, String qry, long duration, boolean fail) { + public void onQueryCompleted(GridCacheQueryType qryType, String qry, long duration, boolean fail) { onQueryCompleted(duration, fail); QueryMetricsKey key = new QueryMetricsKey(qryType, qry); @@ -122,7 +122,7 @@ public class GridCacheQueryMetricsAdapter extends GridCacheQueryBaseMetricsAdapt */ private static class QueryMetricsKey implements Externalizable { /** Query type. */ - private CacheQueryType qryType; + private GridCacheQueryType qryType; /** Query text descriptor: SQL, cache name, search text, ... */ private String qry; @@ -141,7 +141,7 @@ public class GridCacheQueryMetricsAdapter extends GridCacheQueryBaseMetricsAdapt * @param qryType Query type. * @param qry Query text descriptor. */ - public QueryMetricsKey(CacheQueryType qryType, String qry) { + public QueryMetricsKey(GridCacheQueryType qryType, String qry) { this.qryType = qryType; this.qry = qry; } @@ -149,7 +149,7 @@ public class GridCacheQueryMetricsAdapter extends GridCacheQueryBaseMetricsAdapt /** * @return Query type. */ - public CacheQueryType queryType() { + public GridCacheQueryType queryType() { return qryType; } @@ -168,7 +168,7 @@ public class GridCacheQueryMetricsAdapter extends GridCacheQueryBaseMetricsAdapt /** {@inheritDoc} */ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - qryType = CacheQueryType.fromOrdinal(in.readByte()); + qryType = GridCacheQueryType.fromOrdinal(in.readByte()); qry = U.readString(in); } http://git-wip-us.apache.org/repos/asf/ignite/blob/aebeffea/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java index 6766b51..db7be8b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java @@ -73,6 +73,7 @@ import org.apache.ignite.internal.processors.cache.QueryCursorImpl; import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl; import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture; import org.apache.ignite.internal.processors.cache.query.CacheQueryType; +import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType; import org.apache.ignite.internal.util.GridSpinBusyLock; import org.apache.ignite.internal.util.future.GridCompoundFuture; import org.apache.ignite.internal.util.future.GridFinishedFuture; @@ -730,7 +731,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { throw new IllegalStateException("Failed to execute query (grid is stopping)."); try { - return executeQuery(CacheQueryType.SQL_FIELDS, qry.getSql(), cctx, new IgniteOutClosureX<QueryCursor<List<?>>>() { + return executeQuery(GridCacheQueryType.SQL_FIELDS, qry.getSql(), cctx, new IgniteOutClosureX<QueryCursor<List<?>>>() { @Override public QueryCursor<List<?>> applyx() throws IgniteCheckedException { return idx.queryTwoStep(cctx, qry); } @@ -756,7 +757,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { throw new IllegalStateException("Failed to execute query (grid is stopping)."); try { - return executeQuery(CacheQueryType.SQL, qry.getSql(), cctx, new IgniteOutClosureX<QueryCursor<Cache.Entry<K, V>>>() { + return executeQuery(GridCacheQueryType.SQL, qry.getSql(), cctx, new IgniteOutClosureX<QueryCursor<Cache.Entry<K, V>>>() { @Override public QueryCursor<Cache.Entry<K, V>> applyx() throws IgniteCheckedException { return idx.queryTwoStep(cctx, qry); } @@ -785,10 +786,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { throw new IllegalStateException("Failed to execute query (grid is stopping)."); try { - return executeQuery( - CacheQueryType.SQL, - qry.getSql(), - cctx, + return executeQuery(GridCacheQueryType.SQL, qry.getSql(), cctx, new IgniteOutClosureX<Iterator<Cache.Entry<K, V>>>() { @Override public Iterator<Cache.Entry<K, V>> applyx() throws IgniteCheckedException { String space = cctx.name(); @@ -888,7 +886,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { try { final boolean keepBinary = cctx.keepBinary(); - return executeQuery(CacheQueryType.SQL_FIELDS, qry.getSql(), cctx, + return executeQuery(GridCacheQueryType.SQL_FIELDS, qry.getSql(), cctx, new IgniteOutClosureX<QueryCursor<List<?>>>() { @Override public QueryCursor<List<?>> applyx() throws IgniteCheckedException { String space = cctx.name(); @@ -1042,7 +1040,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { try { final GridCacheContext<?, ?> cctx = ctx.cache().internalCache(space).context(); - return executeQuery(CacheQueryType.FULL_TEXT, clause, cctx, + return executeQuery(GridCacheQueryType.TEXT, clause, cctx, new IgniteOutClosureX<GridCloseableIterator<IgniteBiTuple<K, V>>>() { @Override public GridCloseableIterator<IgniteBiTuple<K, V>> applyx() throws IgniteCheckedException { TypeDescriptor type = typesByName.get(new TypeName(space, resType)); @@ -1662,7 +1660,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { * @param clo Closure. * @param complete Complete. */ - public <R> R executeQuery(CacheQueryType qryType, String qry, GridCacheContext<?, ?> cctx, IgniteOutClosureX<R> clo, boolean complete) + public <R> R executeQuery(GridCacheQueryType qryType, String qry, GridCacheContext<?, ?> cctx, IgniteOutClosureX<R> clo, boolean complete) throws IgniteCheckedException { final long startTime = U.currentTimeMillis(); @@ -1714,7 +1712,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { * @param duration Duration. * @param log Logger. */ - public static void onCompleted(CacheQueryType qryType, String qry, GridCacheContext<?, ?> cctx, Object res, Throwable err, + public static void onCompleted(GridCacheQueryType qryType, String qry, GridCacheContext<?, ?> cctx, Object res, Throwable err, long startTime, long duration, IgniteLogger log) { boolean fail = err != null; http://git-wip-us.apache.org/repos/asf/ignite/blob/aebeffea/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryDetailsMetrics.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryDetailsMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryDetailsMetrics.java index ef8eeb8..b053c28 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryDetailsMetrics.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryDetailsMetrics.java @@ -18,7 +18,7 @@ package org.apache.ignite.internal.visor.cache; import org.apache.ignite.cache.query.QueryDetailsMetrics; -import org.apache.ignite.internal.processors.cache.query.CacheQueryType; +import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType; import org.apache.ignite.internal.util.typedef.internal.S; /** @@ -29,7 +29,7 @@ public class VisorCacheQueryDetailsMetrics extends VisorCacheQueryBaseMetrics { private static final long serialVersionUID = 0L; /** Query type. */ - private CacheQueryType qryType; + private GridCacheQueryType qryType; /** Textual representation of query. */ private String qry; @@ -50,7 +50,7 @@ public class VisorCacheQueryDetailsMetrics extends VisorCacheQueryBaseMetrics { /** * @return Query type. */ - public CacheQueryType queryType() { + public GridCacheQueryType queryType() { return qryType; }