ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: IGNITE-3443 WIP
Date Thu, 06 Oct 2016 12:57:41 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-3443 b85f5706d -> 18e370edb


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/18e370ed
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/18e370ed
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/18e370ed

Branch: refs/heads/ignite-3443
Commit: 18e370edb8787878d4486b822f1de7bc1bc3939c
Parents: b85f570
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Thu Oct 6 19:58:57 2016 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Thu Oct 6 19:58:57 2016 +0700

----------------------------------------------------------------------
 .../cache/query/GridCacheQueryManager.java      | 93 ++++++++++++++++----
 1 file changed, 77 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/18e370ed/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 0d2cd9b..ccbedeb 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
@@ -41,6 +41,9 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentMap;
 import javax.cache.Cache;
 import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
@@ -64,7 +67,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheInternal;
 import org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheOffheapSwapEntry;
 import org.apache.ignite.internal.processors.cache.GridCacheSwapEntryImpl;
-import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
 import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
@@ -116,6 +118,7 @@ import org.apache.ignite.spi.indexing.IndexingSpi;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 
+import static java.awt.SystemColor.info;
 import static org.apache.ignite.cache.CacheMode.LOCAL;
 import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_EXECUTED;
 import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_OBJECT_READ;
@@ -2097,23 +2100,10 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
 
         // TODO IGNITE-3443 execute in separate thread and use entry processor.
         try {
-            IgniteInternalCache<GridCacheQueryDetailsMetricsKey, Map<String, GridCacheQueryDetailsMetricsAdapter>>
cache =
+            IgniteInternalCache<GridCacheQueryDetailsMetricsKey, Map<Integer, GridCacheQueryDetailsMetricsAdapter>>
cache =
                 (IgniteInternalCache)cctx.grid().utilityCache();
 
-            cache.invoke(GridCacheQueryDetailsMetricsKey.INSTANCE)
-
-            Map<String, GridCacheQueryDetailsMetricsAdapter> metricsMap = cache.get(GridCacheQueryDetailsMetricsKey.INSTANCE);
-
-                GridCacheQueryDetailsMetricsKey key = new GridCacheQueryDetailsMetricsKey(qryType,
qry);
-
-            GridCacheQueryDetailsMetricsAdapter val = cache.get(key);
-
-            if (cache == null)
-                val = new GridCacheQueryDetailsMetricsAdapter(qryType, qry);
-
-            // TODO IGNITE-3443 val.onCompleted(duration, fail);
-
-            cache.put(key, val);
+            cache.invoke(GridCacheQueryDetailsMetricsKey.INSTANCE, new AddMetricsProcessor(qryType,
qry));  /* TODO IGNITE-3443 val.onCompleted(duration, fail); */
         }
         catch (IgniteCheckedException e) {
             throw new IgniteException(e);
@@ -3568,4 +3558,75 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
             return canceled != null && canceled.contains(key);
         }
     }
+
+    /**
+     * Entry processor to add metrics.
+     */
+    private static class AddMetricsProcessor implements
+        EntryProcessor<GridCacheQueryDetailsMetricsKey, Map<Integer, GridCacheQueryDetailsMetricsAdapter>,
Void>,
+        Externalizable {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
+        private GridCacheQueryType qryType;
+
+        /** */
+        private String qry;
+
+        /**
+         * Required by {@link Externalizable}.
+         */
+        public AddMetricsProcessor() {
+            // No-op.
+        }
+
+        /**
+         * Full constructor.
+         *
+         * @param qryType Query type.
+         * @param qry Query description.
+         */
+        public AddMetricsProcessor(GridCacheQueryType qryType, String qry) {
+            this.qryType = qryType;
+            this.qry = qry;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
+
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void process(
+            MutableEntry<GridCacheQueryDetailsMetricsKey, Map<Integer, GridCacheQueryDetailsMetricsAdapter>>
entry,
+            Object... arguments) throws EntryProcessorException {
+            Map<Integer, GridCacheQueryDetailsMetricsAdapter> map = entry.getValue();
+
+            Integer qryHash = 31 * qryType.hashCode() + qry.hashCode();
+
+            if (map == null)
+                map = new HashMap<>();
+            else
+                map = new HashMap<>(map);
+
+            GridCacheQueryDetailsMetricsAdapter qryMetrics = map.get(qryHash);
+
+            if (qryMetrics == null)
+                qryMetrics = new GridCacheQueryDetailsMetricsAdapter(qryType, qry);
+
+            // TODO: update metrics
+
+            map.put(qryHash, qryMetrics);
+
+            entry.setValue(map);
+
+            return null;
+        }
+    }
 }


Mime
View raw message