ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [15/40] incubator-ignite git commit: # IGNITE-692 Implemented special support for local caches.
Date Fri, 10 Apr 2015 17:07:11 GMT
# IGNITE-692 Implemented special support for local caches.


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

Branch: refs/heads/ignite-537
Commit: c72e8efc5eef5042d2cb4fc89184db897800fdf6
Parents: 85462e2
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Fri Apr 10 14:56:24 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Fri Apr 10 14:56:24 2015 +0700

----------------------------------------------------------------------
 .../internal/visor/query/VisorQueryArg.java     | 15 ++++++++++-
 .../internal/visor/query/VisorQueryTask.java    | 28 ++++++++++++++------
 2 files changed, 34 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c72e8efc/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryArg.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryArg.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryArg.java
index 080bb35..38fac1f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryArg.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryArg.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.visor.query;
 
 import java.io.*;
+import java.util.*;
 
 /**
  * Arguments for {@link VisorQueryTask}.
@@ -26,6 +27,9 @@ public class VisorQueryArg implements Serializable {
     /** */
     private static final long serialVersionUID = 0L;
 
+    /** Node ID in case of local cache. */
+    private final UUID locCacheNodeId;
+
     /** Cache name for query. */
     private final String cacheName;
 
@@ -36,17 +40,26 @@ public class VisorQueryArg implements Serializable {
     private final Integer pageSize;
 
     /**
+     * @param locCacheNodeId Node ID in case of local cache or {@code null} otherwise.
      * @param cacheName Cache name for query.
      * @param qryTxt Query text.
      * @param pageSize Result batch size.
      */
-    public VisorQueryArg(String cacheName, String qryTxt, Integer pageSize) {
+    public VisorQueryArg(UUID locCacheNodeId, String cacheName, String qryTxt, Integer pageSize)
{
+        this.locCacheNodeId = locCacheNodeId;
         this.cacheName = cacheName;
         this.qryTxt = qryTxt;
         this.pageSize = pageSize;
     }
 
     /**
+     * @return Node ID in case of local cache or {@code null} otherwise.
+     */
+    public UUID localCacheNodeId() {
+        return locCacheNodeId;
+    }
+
+    /**
      * @return Cache name.
      */
     public String cacheName() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c72e8efc/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
index e01737f..b320842 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
@@ -41,17 +41,29 @@ public class VisorQueryTask extends VisorOneNodeTask<VisorQueryArg,
IgniteBiTupl
         VisorTaskArgument<VisorQueryArg> arg) {
         String cacheName = taskArg.cacheName();
 
-        ClusterGroup prj = ignite.cluster().forDataNodes(cacheName);
+        ClusterNode node;
 
-        if (prj.nodes().isEmpty())
-            throw new IgniteException("No data nodes for cache: " + escapeName(cacheName));
+        if (taskArg.localCacheNodeId() == null) {
+            ClusterGroup prj = ignite.cluster().forDataNodes(cacheName);
 
-        // First try to take local node to avoid network hop.
-        ClusterNode node = prj.node(ignite.localNode().id());
+            if (prj.nodes().isEmpty())
+                throw new IgniteException("No data nodes for cache: " + escapeName(cacheName));
 
-        // Take any node from projection.
-        if (node == null)
-            node = prj.forRandom().node();
+            // First try to take local node to avoid network hop.
+            node = prj.node(ignite.localNode().id());
+
+            // Take any node from projection.
+            if (node == null)
+                node = prj.forRandom().node();
+        }
+        else {
+            node = ignite.cluster().node(taskArg.localCacheNodeId());
+
+            if (node == null)
+                throw new IgniteException("No data node for local cache: " + escapeName(cacheName));
+        }
+
+        assert node != null;
 
         return Collections.singletonMap(job(taskArg), node);
     }


Mime
View raw message