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/08/14 10:30:36 UTC

[26/50] ignite git commit: Lazy worker key.

Lazy worker key.


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

Branch: refs/heads/ignite-5991-6019
Commit: 8c4527371b884b8244ecbf23aab1051a418eb69a
Parents: 40e45ad
Author: devozerov <vo...@gridgain.com>
Authored: Mon Aug 14 10:34:02 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Aug 14 10:34:02 2017 +0300

----------------------------------------------------------------------
 .../query/h2/twostep/GridMapQueryExecutor.java  |  3 +-
 .../h2/twostep/lazy/MapQueryLazyWorker.java     | 20 +++-
 .../h2/twostep/lazy/MapQueryLazyWorkerKey.java  | 97 ++++++++++++++++++++
 3 files changed, 114 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8c452737/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
index 9ca9246..3e2eb8b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
@@ -58,6 +58,7 @@ import org.apache.ignite.internal.processors.query.h2.opt.DistributedJoinMode;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2QueryContext;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2RetryException;
 import org.apache.ignite.internal.processors.query.h2.twostep.lazy.MapQueryLazyIgniteThread;
+import org.apache.ignite.internal.processors.query.h2.twostep.lazy.MapQueryLazyWorker;
 import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest;
 import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryFailResponse;
 import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest;
@@ -441,7 +442,7 @@ public class GridMapQueryExecutor {
             if (lazy) {
                 onQueryRequest0(node,
                     req.requestId(),
-                    0,
+                    segment,
                     req.schemaName(),
                     req.queries(),
                     cacheIds,

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c452737/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/lazy/MapQueryLazyWorker.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/lazy/MapQueryLazyWorker.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/lazy/MapQueryLazyWorker.java
index 1cf9457..0c4079b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/lazy/MapQueryLazyWorker.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/lazy/MapQueryLazyWorker.java
@@ -39,11 +39,11 @@ public class MapQueryLazyWorker extends GridWorker {
      * Constructor.
      *
      * @param instanceName Instance name.
-     * @param name Worker name.
+     * @param key Lazy worker key.
      * @param log Logger.
      */
-    public MapQueryLazyWorker(@Nullable String instanceName , String name, IgniteLogger log) {
-        super(instanceName, name, log);
+    public MapQueryLazyWorker(@Nullable String instanceName, MapQueryLazyWorkerKey key, IgniteLogger log) {
+        super(instanceName, workerName(key), log);
     }
 
     /** {@inheritDoc} */
@@ -78,15 +78,25 @@ public class MapQueryLazyWorker extends GridWorker {
     }
 
     /**
-     * @return Lazy worker flag.
+     * @return Lazy worker thread flag.
      */
-    private static boolean inLazyWorkerThread() {
+    public static boolean isLazyWorkerThread() {
         MapQueryLazyWorker worker = LAZY_WORKER.get();
 
         return worker != null;
     }
 
     /**
+     * Construct worker name.
+     *
+     * @param key Key.
+     * @return Name.
+     */
+    private static String workerName(MapQueryLazyWorkerKey key) {
+        return "query-lazy-worker_" + key.nodeId() + "_" + key.queryRequestId() + "_" + key.segment();
+    }
+
+    /**
      * Internal stop task.
      */
     private static class StopTask implements Runnable {

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c452737/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/lazy/MapQueryLazyWorkerKey.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/lazy/MapQueryLazyWorkerKey.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/lazy/MapQueryLazyWorkerKey.java
new file mode 100644
index 0000000..95af38f
--- /dev/null
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/lazy/MapQueryLazyWorkerKey.java
@@ -0,0 +1,97 @@
+/*
+ * 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.h2.twostep.lazy;
+
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+import java.util.UUID;
+
+/**
+ * Key to identify lazy worker.
+ */
+public class MapQueryLazyWorkerKey {
+    /** Client node ID. */
+    private final UUID nodeId;
+
+    /** Query request ID. */
+    private final long qryReqId;
+
+    /** Segment. */
+    private final int segment;
+
+    /**
+     * Constructor.
+     *
+     * @param nodeId Node ID.
+     * @param qryReqId Query request ID.
+     * @param segment Segment.
+     */
+    public MapQueryLazyWorkerKey(UUID nodeId, long qryReqId, int segment) {
+        this.nodeId = nodeId;
+        this.qryReqId = qryReqId;
+        this.segment = segment;
+    }
+
+    /**
+     * @return Node id.
+     */
+    public UUID nodeId() {
+        return nodeId;
+    }
+
+    /**
+     * @return Query request ID.
+     */
+    public long queryRequestId() {
+        return qryReqId;
+    }
+
+    /**
+     * @return Segment.
+     */
+    public int segment() {
+        return segment;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = nodeId.hashCode();
+
+        res = 31 * res + (int)(qryReqId ^ (qryReqId >>> 32));
+        res = 31 * res + segment;
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object obj) {
+        if (obj != null && obj instanceof MapQueryLazyWorkerKey) {
+            MapQueryLazyWorkerKey other = (MapQueryLazyWorkerKey)obj;
+
+            return F.eq(qryReqId, other.qryReqId) && F.eq(nodeId, other.nodeId) && F.eq(segment, other.segment);
+        }
+
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(MapQueryLazyWorkerKey.class, this);
+    }
+}