Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2691217583 for ; Fri, 10 Apr 2015 17:47:59 +0000 (UTC) Received: (qmail 80533 invoked by uid 500); 10 Apr 2015 17:47:59 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 80498 invoked by uid 500); 10 Apr 2015 17:47:59 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 80382 invoked by uid 99); 10 Apr 2015 17:47:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Apr 2015 17:47:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 10 Apr 2015 17:47:33 +0000 Received: (qmail 78312 invoked by uid 99); 10 Apr 2015 17:47:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Apr 2015 17:47:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 40BB5E04B7; Fri, 10 Apr 2015 17:47:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agoncharuk@apache.org To: commits@ignite.incubator.apache.org Date: Fri, 10 Apr 2015 17:47:45 -0000 Message-Id: <5b923be6098a46e0aa214136748e381a@git.apache.org> In-Reply-To: <3ee709519e044ed48510e74b6c357a1a@git.apache.org> References: <3ee709519e044ed48510e74b6c357a1a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [15/42] incubator-ignite git commit: # IGNITE-692 Implemented special support for local caches. X-Virus-Checked: Checked by ClamAV on apache.org # 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-721 Commit: c72e8efc5eef5042d2cb4fc89184db897800fdf6 Parents: 85462e2 Author: AKuznetsov Authored: Fri Apr 10 14:56:24 2015 +0700 Committer: AKuznetsov 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 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); }