ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [48/50] [abbrv] incubator-ignite git commit: IGNITE-342 Fixed review notes.
Date Mon, 02 Mar 2015 09:50:33 GMT
IGNITE-342 Fixed review notes.


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

Branch: refs/heads/ignite-342
Commit: 2f3b8fb6abc275e88176e535af44560ef2737b50
Parents: a69151b
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Mon Mar 2 12:45:20 2015 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Mon Mar 2 12:45:20 2015 +0300

----------------------------------------------------------------------
 .../affinity/GridAffinityAssignmentCache.java    |  8 +-------
 .../cache/GridCacheAffinityManager.java          | 13 ++-----------
 .../processors/cache/GridCacheContext.java       | 19 +++++++++++++++++++
 .../processors/cache/GridCacheProcessor.java     | 15 +++++++++++++++
 4 files changed, 37 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f3b8fb6/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index 9bfcca0..3cd5bb7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -59,9 +59,6 @@ public class GridAffinityAssignmentCache {
     /** Affinity mapper function. */
     private final CacheAffinityKeyMapper affMapper;
 
-    /** Default affinity mapper function. */
-    private final CacheAffinityKeyMapper dfltAffMapper;
-
     /** Affinity calculation results cache: topology version => partition => nodes.
*/
     private final ConcurrentMap<Long, GridAffinityAssignment> affCache;
 
@@ -87,7 +84,6 @@ public class GridAffinityAssignmentCache {
      * @param cacheName Cache name.
      * @param aff Affinity function.
      * @param affMapper Affinity key mapper.
-     * @param dfltAffMapper Default affinity key mapper.
      * @param backups Number of backups.
      */
     @SuppressWarnings("unchecked")
@@ -95,7 +91,6 @@ public class GridAffinityAssignmentCache {
         String cacheName,
         CacheAffinityFunction aff,
         CacheAffinityKeyMapper affMapper,
-        CacheAffinityKeyMapper dfltAffMapper,
         int backups)
     {
         this.ctx = ctx;
@@ -103,7 +98,6 @@ public class GridAffinityAssignmentCache {
         this.affMapper = affMapper;
         this.cacheName = cacheName;
         this.backups = backups;
-        this.dfltAffMapper = dfltAffMapper;
 
         log = ctx.logger(GridAffinityAssignmentCache.class);
 
@@ -322,7 +316,7 @@ public class GridAffinityAssignmentCache {
      * @return Affinity key.
      */
     private Object affinityKey(Object key) {
-        return (dfltAffMapper != null && key instanceof GridCacheInternal ? dfltAffMapper
: affMapper).affinityKey(key);
+        return (key instanceof GridCacheInternal ? ctx.defaultAffMapper() : affMapper).affinityKey(key);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f3b8fb6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
index 0e0b26b..d3510e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
@@ -44,17 +44,8 @@ public class GridCacheAffinityManager<K, V> extends GridCacheManagerAdapter<K,
V
 
     /** {@inheritDoc} */
     @Override public void start0() throws IgniteCheckedException {
-        GridCacheDefaultAffinityKeyMapper dfltAffKeyMapper = null;
-
-        if (!cctx.config().getAffinityMapper().getClass().equals(GridCacheDefaultAffinityKeyMapper.class))
{
-            dfltAffKeyMapper = new GridCacheDefaultAffinityKeyMapper();
-            
-            dfltAffKeyMapper.setIgnite(cctx.grid());
-            dfltAffKeyMapper.setLog(cctx.logger(GridCacheDefaultAffinityKeyMapper.class));
-        }
-
-        aff = new GridAffinityAssignmentCache(cctx, cctx.namex(), cctx.config().getAffinity(),

-            cctx.config().getAffinityMapper(), dfltAffKeyMapper, cctx.config().getBackups());
+        aff = new GridAffinityAssignmentCache(cctx, cctx.namex(), cctx.config().getAffinity(),
+            cctx.config().getAffinityMapper(), cctx.config().getBackups());
 
         // Generate internal keys for partitions.
         int partCnt = partitions();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f3b8fb6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 3ec013c..44f8e69 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache;
 
 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.internal.*;
@@ -164,6 +165,9 @@ public class GridCacheContext<K, V> implements Externalizable {
     /** Cached local rich node. */
     private ClusterNode locNode;
 
+    /** Default cache affinity mapper. */
+    private CacheAffinityKeyMapper affMapper;
+
     /**
      * Thread local projection. If it's set it means that method call was initiated
      * by child projection of initial cache.
@@ -1016,6 +1020,20 @@ public class GridCacheContext<K, V> implements Externalizable
{
     }
 
     /**
+     * @return Default affinity key mapper.
+     */
+    public CacheAffinityKeyMapper defaultAffMapper() {
+        return affMapper;
+    }
+
+    /**
+     * Sets default affinity key mapper.
+     */
+    public void defaultAffMapper(CacheAffinityKeyMapper dfltAffMapper) {
+        this.affMapper = dfltAffMapper;
+    }
+
+    /**
      * @param p Single predicate.
      * @return Array containing single predicate.
      */
@@ -1770,6 +1788,7 @@ public class GridCacheContext<K, V> implements Externalizable
{
         evictMgr = null;
         qryMgr = null;
         dataStructuresMgr = null;
+        affMapper = null;
 
         mgrs.clear();
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f3b8fb6/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 e99c706..45fcf1d 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
@@ -618,6 +618,17 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
             U.startLifecycleAware(lifecycleAwares(cfg, jta.tmLookup(), cfgStore));
 
+            // Init default key mapper.
+            CacheAffinityKeyMapper dfltAffMapper;
+            
+            if (cfg.getAffinityMapper().getClass().equals(GridCacheDefaultAffinityKeyMapper.class))
+                dfltAffMapper = cfg.getAffinityMapper();
+            else {
+                dfltAffMapper = new GridCacheDefaultAffinityKeyMapper();
+                
+                prepare(cfg, dfltAffMapper, false);
+            }
+
             cfgs[i] = cfg; // Replace original configuration value.
 
             GridCacheAffinityManager affMgr = new GridCacheAffinityManager();
@@ -655,6 +666,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 drMgr,
                 jta);
 
+            cacheCtx.defaultAffMapper(dfltAffMapper);
+
             GridCacheAdapter cache = null;
 
             switch (cfg.getCacheMode()) {
@@ -793,6 +806,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                     drMgr,
                     jta);
 
+                cacheCtx.defaultAffMapper(dfltAffMapper);
+
                 GridDhtCacheAdapter dht = null;
 
                 switch (cfg.getAtomicityMode()) {


Mime
View raw message