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 14:03:47 UTC
[2/5] ignite git commit: Minors.
Minors.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/752e7149
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/752e7149
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/752e7149
Branch: refs/heads/ignite-4565-ddl
Commit: 752e71490b79f27fb182353ae7c7babb84f0b0fd
Parents: 539f1d8
Author: devozerov <vo...@gridgain.com>
Authored: Thu Mar 9 16:53:54 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Thu Mar 9 16:53:54 2017 +0300
----------------------------------------------------------------------
.../processors/query/GridQueryIndexHandler.java | 35 ---------
.../processors/query/GridQueryProcessor.java | 70 +-----------------
.../processors/query/QueryIndexHandler.java | 76 ++++++++++++++++++++
3 files changed, 78 insertions(+), 103 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/752e7149/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexHandler.java
deleted file mode 100644
index e996ac1..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexHandler.java
+++ /dev/null
@@ -1,35 +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.query;
-
-/**
- * Handler responsible for all index-related operations.
- */
-public class GridQueryIndexHandler {
- /** Query processor. */
- private final GridQueryProcessor qryProc;
-
- /**
- * Constructor.
- *
- * @param qryProc Query processor.
- */
- public GridQueryIndexHandler(GridQueryProcessor qryProc) {
- this.qryProc = qryProc;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/752e7149/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 63a21a9..f217fab 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
@@ -36,12 +36,9 @@ 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;
@@ -83,7 +80,6 @@ import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor;
import org.apache.ignite.internal.util.GridSpinBusyLock;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
-import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.GridCloseableIterator;
import org.apache.ignite.internal.util.lang.GridClosureException;
import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
@@ -1984,7 +1980,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
/**
* Descriptor of type.
*/
- private class TypeDescriptor implements GridQueryTypeDescriptor {
+ private static class TypeDescriptor implements GridQueryTypeDescriptor {
/** Space. */
private String space;
@@ -2010,7 +2006,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
private final Map<String, IndexDescriptor> indexes = new HashMap<>();
/** Index state manager. */
- private final IndexStateManager idxState = new IndexStateManager();
+ private final QueryIndexHandler idxState = new QueryIndexHandler();
/** */
private IndexDescriptor fullTextIdx;
@@ -2406,68 +2402,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
}
/**
- * Index state manager.
- */
- private class IndexStateManager {
- /** Indexes. */
- private final Map<String, IndexDescriptor> idxs = new ConcurrentHashMap<>();
-
- /** Client futures. */
- private final Map<UUID, GridFutureAdapter> cliFuts = new ConcurrentHashMap<>();
-
- /** RW lock. */
- private final ReadWriteLock lock = new ReentrantReadWriteLock();
-
- /**
- * Handle initial index state.
- *
- * @param idxs Indexes.
- */
- public void onInitialStateReady(Map<String, IndexDescriptor> idxs) {
- this.idxs.putAll(idxs);
- }
-
- /**
- * Handle dynamic index creation.
- *
- * @param idx Index.
- * @param ifNotExists IF-NOT-EXISTS flag.
- * @return Future completed when index is created.
- */
- public IgniteInternalFuture<?> onCreateIndex(QueryIndex idx, boolean ifNotExists) {
- lock.writeLock().lock();
-
- try {
- String idxName = idx.getName() != null ? idx.getName() : QueryEntity.defaultIndexName(idx);
-
- IndexDescriptor oldIdx = idxs.get(idxName);
-
- if (oldIdx != null) {
- if (ifNotExists)
- return new GridFinishedFuture<>();
- else
- return new GridFinishedFuture<>(new IgniteException("Index already exists [idxName=" +
- idxName + ']'));
- }
-
- UUID opId = UUID.randomUUID();
- GridFutureAdapter fut = new GridFutureAdapter();
-
- GridFutureAdapter oldFut = cliFuts.put(opId, fut);
-
- assert oldFut == null;
-
- // TODO: Start discovery.
-
- return fut;
- }
- finally {
- lock.writeLock().unlock();
- }
- }
- }
-
- /**
* The way to index.
*/
private enum IndexType {
http://git-wip-us.apache.org/repos/asf/ignite/blob/752e7149/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryIndexHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryIndexHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryIndexHandler.java
new file mode 100644
index 0000000..4edb07d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryIndexHandler.java
@@ -0,0 +1,76 @@
+package org.apache.ignite.internal.processors.query;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.future.GridFinishedFuture;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * Index state manager.
+ */
+public class QueryIndexHandler {
+ /** Indexes. */
+ private final Map<String, GridQueryProcessor.IndexDescriptor> idxs = new ConcurrentHashMap<>();
+
+ /** Client futures. */
+ private final Map<UUID, GridFutureAdapter> cliFuts = new ConcurrentHashMap<>();
+
+ /** RW lock. */
+ private final ReadWriteLock lock = new ReentrantReadWriteLock();
+
+ /**
+ * Handle initial index state.
+ *
+ * @param idxs Indexes.
+ */
+ public void onInitialStateReady(Map<String, GridQueryProcessor.IndexDescriptor> idxs) {
+ this.idxs.putAll(idxs);
+ }
+
+ /**
+ * Handle dynamic index creation.
+ *
+ * @param idx Index.
+ * @param ifNotExists IF-NOT-EXISTS flag.
+ * @return Future completed when index is created.
+ */
+ public IgniteInternalFuture<?> onCreateIndex(QueryIndex idx, boolean ifNotExists) {
+ lock.writeLock().lock();
+
+ try {
+ String idxName = idx.getName() != null ? idx.getName() : QueryEntity.defaultIndexName(idx);
+
+ GridQueryProcessor.IndexDescriptor oldIdx = idxs.get(idxName);
+
+ if (oldIdx != null) {
+ if (ifNotExists)
+ return new GridFinishedFuture<>();
+ else
+ return new GridFinishedFuture<>(new IgniteException("Index already exists [idxName=" +
+ idxName + ']'));
+ }
+
+ UUID opId = UUID.randomUUID();
+ GridFutureAdapter fut = new GridFutureAdapter();
+
+ GridFutureAdapter oldFut = cliFuts.put(opId, fut);
+
+ assert oldFut == null;
+
+ // TODO: Start discovery.
+
+ return fut;
+ }
+ finally {
+ lock.writeLock().unlock();
+ }
+ }
+}