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 B3FD518E61 for ; Thu, 9 Jul 2015 15:15:19 +0000 (UTC) Received: (qmail 43225 invoked by uid 500); 9 Jul 2015 15:15:19 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 43152 invoked by uid 500); 9 Jul 2015 15:15:19 -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 43136 invoked by uid 99); 9 Jul 2015 15:15:19 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jul 2015 15:15:19 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 32980D34D4 for ; Thu, 9 Jul 2015 15:15:19 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.452 X-Spam-Level: * X-Spam-Status: No, score=1.452 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.329, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id zVXI6Y7V_OHt for ; Thu, 9 Jul 2015 15:15:11 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 7027B43A5B for ; Thu, 9 Jul 2015 15:15:11 +0000 (UTC) Received: (qmail 42806 invoked by uid 99); 9 Jul 2015 15:15:11 -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; Thu, 09 Jul 2015 15:15:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AF45EE6830; Thu, 9 Jul 2015 15:15:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Thu, 09 Jul 2015 15:15:10 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [01/50] incubator-ignite git commit: IGNITE-1026 - Always create client cache Repository: incubator-ignite Updated Branches: refs/heads/ignite-901 15ef9b9e3 -> fa007b1f5 IGNITE-1026 - Always create client cache Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/eef2b372 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/eef2b372 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/eef2b372 Branch: refs/heads/ignite-901 Commit: eef2b372fe83f7626981f9ce1364d99da5d0c60a Parents: af829d0 Author: Valentin Kulichenko Authored: Wed Jun 17 19:24:25 2015 -0700 Committer: Valentin Kulichenko Committed: Wed Jun 17 19:24:25 2015 -0700 ---------------------------------------------------------------------- .../processors/cache/GridCacheProcessor.java | 71 +++++--------------- 1 file changed, 16 insertions(+), 55 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eef2b372/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java index 2f7f22c..e6a0994 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java @@ -1917,7 +1917,7 @@ public class GridCacheProcessor extends GridProcessorAdapter { req.clientStartOnly(true); } else - return new GridFinishedFuture<>(); + req.clientStartOnly(true); req.deploymentId(desc.deploymentId()); @@ -1948,14 +1948,14 @@ public class GridCacheProcessor extends GridProcessorAdapter { ccfg = desc.cacheConfiguration(); if (ccfg == null) - return new GridFinishedFuture<>(new CacheExistsException("Failed to start near cache " + + return new GridFinishedFuture<>(new CacheExistsException("Failed to start client cache " + "(a cache with the given name is not started): " + cacheName)); if (CU.affinityNode(ctx.discovery().localNode(), ccfg.getNodeFilter())) { if (ccfg.getNearConfiguration() != null) return new GridFinishedFuture<>(); else - return new GridFinishedFuture<>(new IgniteCheckedException("Failed to start near cache " + + return new GridFinishedFuture<>(new IgniteCheckedException("Failed to start client cache " + "(local node is an affinity node for cache): " + cacheName)); } @@ -2523,12 +2523,17 @@ public class GridCacheProcessor extends GridProcessorAdapter { if (log.isDebugEnabled()) log.debug("Getting cache for name: " + name); - IgniteCache jcache = (IgniteCache)jCacheProxies.get(maskNull(name)); + String masked = maskNull(name); - if (jcache == null) - jcache = startJCache(name, true); + IgniteCacheProxy cache = jCacheProxies.get(masked); + + if (cache == null) { + dynamicStartCache(null, name, null, false); + + cache = jCacheProxies.get(masked); + } - return jcache == null ? null : ((IgniteCacheProxy)jcache).internalProxy(); + return cache == null ? null : (IgniteInternalCache)cache.internalProxy(); } /** @@ -2638,57 +2643,13 @@ public class GridCacheProcessor extends GridProcessorAdapter { if (desc != null && !desc.cacheType().userCache()) throw new IllegalStateException("Failed to get cache because it is a system cache: " + cacheName); - if (cache == null) - cache = startJCache(cacheName, failIfNotStarted); - - return (IgniteCacheProxy)cache; - } - - /** - * @param cacheName Cache name. - * @param failIfNotStarted If {@code true} throws {@link IllegalArgumentException} if cache is not started, - * otherwise returns {@code null} in this case. - * @return Cache instance for given name. - * @throws IgniteCheckedException If failed. - */ - private IgniteCacheProxy startJCache(String cacheName, boolean failIfNotStarted) throws IgniteCheckedException { - checkEmptyTransactions(); - - String masked = maskNull(cacheName); - - DynamicCacheDescriptor desc = registeredCaches.get(masked); + if (cache == null) { + dynamicStartCache(null, cacheName, null, false).get(); - if (desc == null || desc.cancelled()) { - if (failIfNotStarted) - throw new IllegalArgumentException("Cache is not started: " + cacheName); - - return null; + cache = jCacheProxies.get(masked); } - DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(cacheName, ctx.localNodeId()); - - req.cacheName(cacheName); - - req.deploymentId(desc.deploymentId()); - - CacheConfiguration cfg = new CacheConfiguration(desc.cacheConfiguration()); - - cfg.setNearConfiguration(null); - - req.startCacheConfiguration(cfg); - - req.cacheType(desc.cacheType()); - - req.clientStartOnly(true); - - F.first(initiateCacheChanges(F.asList(req), false)).get(); - - IgniteCacheProxy cache = jCacheProxies.get(masked); - - if (cache == null && failIfNotStarted) - throw new IllegalArgumentException("Cache is not started: " + cacheName); - - return cache; + return (IgniteCacheProxy)cache; } /**