ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [26/50] [abbrv] incubator-ignite git commit: # IGNITE-691: Fixed.
Date Fri, 10 Apr 2015 10:18:25 GMT
# IGNITE-691: Fixed.


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

Branch: refs/heads/ignite-676
Commit: e7fa0a9a09df44ffd7caaa675c30ab5b1c6b9344
Parents: 0391d27
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Thu Apr 9 17:54:05 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Thu Apr 9 17:54:05 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    | 11 +-----
 .../affinity/GridAffinityProcessor.java         |  5 ++-
 .../processors/cache/GridCacheProcessor.java    | 37 +++++++++++++-------
 .../cacheobject/IgniteCacheObjectProcessor.java |  5 +--
 .../IgniteCacheObjectProcessorImpl.java         | 34 +++++++-----------
 .../datastreamer/DataStreamerImpl.java          |  8 ++---
 6 files changed, 47 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7fa0a9a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 8e5779e..05667d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -2235,19 +2235,10 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
 
     /** {@inheritDoc} */
     @Override public <K, V> IgniteCache<K, V> cache(@Nullable String name) {
-        return cache(name, true);
-    }
-
-    /**
-     * @param name Cache name.
-     * @param failIfSys Fail if requestsed cache is system cache.
-     * @return Cache.
-     */
-    public <K, V> IgniteCache<K, V> cache(@Nullable String name, boolean failIfSys)
{
         guard();
 
         try {
-            return ctx.cache().publicJCache(name, true, failIfSys);
+            return ctx.cache().publicJCache(name, true);
         }
         catch (IgniteCheckedException e) {
             throw CU.convertToCacheException(e);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7fa0a9a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
index 46fc099..daa2bc2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
@@ -21,6 +21,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.affinity.*;
 import org.apache.ignite.cluster.*;
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.managers.eventstorage.*;
@@ -404,7 +405,9 @@ public class GridAffinityProcessor extends GridProcessorAdapter {
         f.reset();
         m.reset();
 
-        return new AffinityInfo(f, m, t.get3(), ctx.cacheObjects().contextForCache(n, cacheName,
null));
+        CacheConfiguration ccfg = ctx.cache().cacheConfiguration(cacheName);
+
+        return new AffinityInfo(f, m, t.get3(), ctx.cacheObjects().contextForCache(ccfg));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7fa0a9a/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 1dd1658..c0e84f8 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
@@ -60,7 +60,6 @@ import org.jetbrains.annotations.*;
 
 import javax.cache.configuration.*;
 import javax.cache.integration.*;
-import javax.cache.processor.*;
 import javax.management.*;
 import java.io.*;
 import java.util.*;
@@ -575,7 +574,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
             CacheConfiguration<?, ?> cfg = new CacheConfiguration(cfgs[i]);
 
-            CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(null, cfg.getName(),
cfg);
+            CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(cfg);
 
             // Initialize defaults.
             initialize(cfg, cacheObjCtx);
@@ -716,7 +715,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             IgnitePredicate filter = ccfg.getNodeFilter();
 
             if (filter.apply(locNode)) {
-                CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(null,
ccfg.getName(), ccfg);
+                CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(ccfg);
 
                 CachePluginManager pluginMgr = cache2PluginMgr.get(ccfg.getName());
                 
@@ -1433,7 +1432,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                     ccfg.setNearConfiguration(nearCfg);
             }
 
-            CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(null, ccfg.getName(),
ccfg);
+            CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(ccfg);
 
             GridCacheContext cacheCtx = createCache(ccfg, null, cacheType, cacheObjCtx);
 
@@ -1725,7 +1724,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      */
     public IgniteInternalFuture<?> getOrCreateFromTemplate(String cacheName) {
         try {
-            if (publicJCache(cacheName, false, true) != null) // Cache with given name already
started.
+            if (publicJCache(cacheName, false) != null) // Cache with given name already
started.
                 return new GridFinishedFuture<>();
 
             CacheConfiguration cfg = createConfigFromTemplate(cacheName);
@@ -1889,7 +1888,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 try {
                     CacheConfiguration cfg = new CacheConfiguration(ccfg);
 
-                    CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(null,
cfg.getName(), cfg);
+                    CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(cfg);
 
                     initialize(cfg, cacheObjCtx);
 
@@ -2524,22 +2523,21 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @throws IgniteCheckedException If failed.
      */
     public <K, V> IgniteCache<K, V> publicJCache(@Nullable String cacheName)
throws IgniteCheckedException {
-        return publicJCache(cacheName, true, true);
+        return publicJCache(cacheName, true);
     }
 
     /**
      * @param cacheName Cache name.
      * @param failIfNotStarted If {@code true} throws {@link IllegalArgumentException} if
cache is not started,
      *        otherwise returns {@code null} in this case.
-     * @param failIfSys Fail is cache is system.
      * @param <K> type of keys.
      * @param <V> type of values.
      * @return Cache instance for given name.
      * @throws IgniteCheckedException If failed.
      */
-    @SuppressWarnings("unchecked")
-    @Nullable public <K, V> IgniteCache<K, V> publicJCache(@Nullable String cacheName,
boolean failIfNotStarted,
-        boolean failIfSys) throws IgniteCheckedException
+    @SuppressWarnings({"unchecked", "ConstantConditions"})
+    @Nullable public <K, V> IgniteCache<K, V> publicJCache(@Nullable String cacheName,
boolean failIfNotStarted)
+        throws IgniteCheckedException
     {
         if (log.isDebugEnabled())
             log.debug("Getting public cache for name: " + cacheName);
@@ -2550,7 +2548,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         DynamicCacheDescriptor desc = registeredCaches.get(masked);
 
-        if (desc != null && !desc.cacheType().userCache() && failIfSys)
+        if (desc != null && !desc.cacheType().userCache())
             throw new IllegalStateException("Failed to get cache because it is a system cache:
" + cacheName);
 
         if (cache == null) {
@@ -2589,6 +2587,21 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     }
 
     /**
+     * Get configuration for the given cache.
+     *
+     * @param name Cache name.
+     * @return Cache configuration.
+     */
+    public CacheConfiguration cacheConfiguration(String name) {
+        DynamicCacheDescriptor desc = registeredCaches.get(maskNull(name));
+
+        if (desc == null || desc.cancelled())
+            throw new IllegalStateException("Cache doesn't exist: " + name);
+        else
+            return desc.cacheConfiguration();
+    }
+
+    /**
      * @param cacheCfg Cache configuration template.
      * @throws IgniteCheckedException If failed.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7fa0a9a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
index 358ef1a..a04692d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
@@ -116,12 +116,9 @@ public interface IgniteCacheObjectProcessor extends GridProcessor {
     public Object unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr) throws
IgniteCheckedException;
 
     /**
-     * @param node Node.
-     * @param cacheName Cache name.
      * @return Cache object context.
      */
-    public CacheObjectContext contextForCache(ClusterNode node, @Nullable String cacheName,
-        @Nullable CacheConfiguration ccfg);
+    public CacheObjectContext contextForCache(CacheConfiguration ccfg);
 
     /**
      * @param ctx Cache context.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7fa0a9a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index 95fb9f7..3e02acd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cacheobject;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
-import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.*;
@@ -186,26 +185,19 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
     }
 
     /** {@inheritDoc} */
-    @Override public CacheObjectContext contextForCache(ClusterNode node, @Nullable String
cacheName,
-        @Nullable CacheConfiguration ccfg) {
-        if (ccfg != null) {
-            CacheMemoryMode memMode = ccfg.getMemoryMode();
-
-            boolean storeVal = ctx.config().isPeerClassLoadingEnabled() ||
-                GridQueryProcessor.isEnabled(ccfg) ||
-                !ccfg.isCopyOnRead();
-
-            return new CacheObjectContext(ctx,
-                new GridCacheDefaultAffinityKeyMapper(),
-                ccfg.isCopyOnRead() && memMode == ONHEAP_TIERED,
-                storeVal);
-        }
-        else
-            return new CacheObjectContext(
-                ctx,
-                new GridCacheDefaultAffinityKeyMapper(),
-                false,
-                ctx.config().isPeerClassLoadingEnabled());
+    @Override public CacheObjectContext contextForCache(CacheConfiguration ccfg) {
+        assert ccfg != null;
+
+        CacheMemoryMode memMode = ccfg.getMemoryMode();
+
+        boolean storeVal = ctx.config().isPeerClassLoadingEnabled() ||
+            GridQueryProcessor.isEnabled(ccfg) ||
+            !ccfg.isCopyOnRead();
+
+        return new CacheObjectContext(ctx,
+            ccfg.getAffinityMapper() != null ? ccfg.getAffinityMapper() : new GridCacheDefaultAffinityKeyMapper(),
+            ccfg.isCopyOnRead() && memMode == ONHEAP_TIERED,
+            storeVal);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7fa0a9a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
index 2b470f6..a03a925 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.datastreamer;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.cluster.*;
@@ -180,12 +181,9 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K,
V>, Delayed
         if (log == null)
             log = U.logger(ctx, logRef, DataStreamerImpl.class);
 
-        ClusterNode node = F.first(ctx.grid().cluster().forCacheNodes(cacheName).nodes());
-
-        if (node == null)
-            throw new IllegalStateException("Cache doesn't exist: " + cacheName);
+        CacheConfiguration ccfg = ctx.cache().cacheConfiguration(cacheName);
 
-        this.cacheObjCtx = ctx.cacheObjects().contextForCache(node, cacheName, null);
+        this.cacheObjCtx = ctx.cacheObjects().contextForCache(ccfg);
         this.cacheName = cacheName;
         this.flushQ = flushQ;
 


Mime
View raw message