You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/03/09 12:32:39 UTC

[2/2] ignite git commit: WIP on general wire-up.

WIP on general wire-up.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d8d2ad8f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d8d2ad8f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d8d2ad8f

Branch: refs/heads/ignite-4565-ddl
Commit: d8d2ad8f93efedd4787ec04a9886b28266f7ac8d
Parents: 157db2b
Author: devozerov <vo...@gridgain.com>
Authored: Thu Mar 9 15:32:28 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Thu Mar 9 15:32:28 2017 +0300

----------------------------------------------------------------------
 .../processors/query/GridQueryProcessor.java    | 42 +++++++++++++++++++-
 1 file changed, 40 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d8d2ad8f/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 cb46612..bb237ab 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
@@ -37,9 +37,12 @@ import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 import javax.cache.Cache;
 import javax.cache.CacheException;
 import org.apache.ignite.IgniteCheckedException;
@@ -99,6 +102,7 @@ import org.apache.ignite.spi.indexing.IndexingQueryFilter;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 
+import static java.lang.Enum.valueOf;
 import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_EXECUTED;
 import static org.apache.ignite.internal.IgniteComponentType.INDEXING;
 
@@ -341,6 +345,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                         altTypeId = new TypeId(ccfg.getName(), ctx.cacheObjects().typeId(qryEntity.getValueType()));
                     }
 
+                    desc.onInitialStateReady();
+
                     addTypeByName(ccfg, desc);
                     types.put(typeId, desc);
 
@@ -434,6 +440,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                         altTypeId = new TypeId(ccfg.getName(), ctx.cacheObjects().typeId(meta.getValueType()));
                     }
 
+                    desc.onInitialStateReady();
+
                     addTypeByName(ccfg, desc);
                     types.put(typeId, desc);
 
@@ -2327,6 +2335,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         @GridToStringInclude
         private final Map<String, IndexDescriptor> indexes = new HashMap<>();
 
+        /** Index state manager. */
+        private final IndexStateManager idxState = new IndexStateManager();
+
         /** */
         private IndexDescriptor fullTextIdx;
 
@@ -2488,8 +2499,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
          * @param descending Sorting order.
          * @throws IgniteCheckedException If failed.
          */
-        public void addFieldToIndex(String idxName, String field, int orderNum,
-            boolean descending) throws IgniteCheckedException {
+        public void addFieldToIndex(String idxName, String field, int orderNum, boolean descending)
+            throws IgniteCheckedException {
             IndexDescriptor desc = indexes.get(idxName);
 
             assert desc != null;
@@ -2623,6 +2634,13 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         }
 
         /**
+         * Callback invoked when initial type state is ready.
+         */
+        public void onInitialStateReady() {
+            idxState.onInitialStateReady(indexes);
+        }
+
+        /**
          * Initiate asynchronous index creation.
          *
          * @param idx Index description.
@@ -2715,6 +2733,26 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     }
 
     /**
+     * Index state manager.
+     */
+    private static class IndexStateManager {
+        /** Indexes. */
+        private final Map<String, IndexDescriptor> idxs = new ConcurrentHashMap<>();
+
+        /** RW lock. */
+        private final ReadWriteLock lock = new ReentrantReadWriteLock();
+
+        /**
+         * Callback invoked when original index state is ready.
+         *
+         * @param idxs Indexes.
+         */
+        public void onInitialStateReady(Map<String, IndexDescriptor> idxs) {
+            this.idxs.putAll(idxs);
+        }
+    }
+
+    /**
      * Identifying TypeDescriptor by space and value class.
      */
     private static class TypeId {