Repository: ignite
Updated Branches:
  refs/heads/ignite-5075 84b56f505 -> e65697d29


ignite-5075


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

Branch: refs/heads/ignite-5075
Commit: e65697d290132fccef3b982fd436b4ffb3b7ac0a
Parents: 84b56f5
Author: sboikov <sboi...@gridgain.com>
Authored: Fri May 19 11:57:14 2017 +0300
Committer: sboikov <sboi...@gridgain.com>
Committed: Fri May 19 12:16:42 2017 +0300

----------------------------------------------------------------------
 .../affinity/GridAffinityProcessor.java         |  2 +-
 .../processors/affinity/GridAffinityUtils.java  |  2 +-
 .../cache/CacheGroupInfrastructure.java         | 25 ++++++++++++++
 .../processors/cache/ClusterCachesInfo.java     |  5 ++-
 .../cache/GridCacheAffinityManager.java         |  2 +-
 .../processors/cache/GridCacheProcessor.java    | 36 +++++++++++++++-----
 .../cache/affinity/GridCacheAffinityImpl.java   |  7 +---
 .../dht/GridDhtPartitionTopologyImpl.java       |  2 +-
 .../GridDhtPartitionsExchangeFuture.java        |  8 ++---
 ...niteTopologyValidatorGridSplitCacheTest.java |  8 ++++-
 10 files changed, 73 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e65697d2/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 e57cf54..b137d29 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
@@ -395,7 +395,7 @@ public class GridAffinityProcessor extends 
GridProcessorAdapter {
                     new GridAffinityAssignment(topVer, assign0.assignment(), 
assign0.idealAssignment());
 
                 AffinityInfo info = new AffinityInfo(
-                    cctx.config().getAffinity(),
+                    cctx.group().config().getAffinity(),
                     cctx.config().getAffinityMapper(),
                     assign,
                     cctx.cacheObjectContext());

http://git-wip-us.apache.org/repos/asf/ignite/blob/e65697d2/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
index abd5292..35fe965 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
@@ -187,7 +187,7 @@ class GridAffinityUtils {
                 new GridAffinityAssignment(topVer, assign0.assignment(), 
assign0.idealAssignment());
 
             return F.t(
-                affinityMessage(ctx, cctx.config().getAffinity()),
+                affinityMessage(ctx, cctx.group().affinityFunction()),
                 affinityMessage(ctx, cctx.config().getAffinityMapper()),
                 assign);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/e65697d2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupInfrastructure.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupInfrastructure.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupInfrastructure.java
index 1e28144..1fc548e 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupInfrastructure.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupInfrastructure.java
@@ -18,13 +18,17 @@
 package org.apache.ignite.internal.processors.cache;
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cache.affinity.AffinityFunction;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.DataPageEvictionMode;
+import org.apache.ignite.configuration.TopologyValidator;
 import org.apache.ignite.events.CacheRebalancingEvent;
 import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
 import org.apache.ignite.internal.IgniteInternalFuture;
@@ -519,6 +523,27 @@ public class CacheGroupInfrastructure {
     }
 
     /**
+     * @return Configured user objects which should be initialized/stopped on 
group start/stop.
+     */
+    Collection<?> configuredUserObjects() {
+        return Arrays.asList(ccfg.getAffinity(), ccfg.getNodeFilter(), 
ccfg.getTopologyValidator());
+    }
+
+    /**
+     * @return Configured topology validator.
+     */
+    @Nullable public TopologyValidator topologyValidator() {
+        return ccfg.getTopologyValidator();
+    }
+
+    /**
+     * @return Configured affinity function.
+     */
+    public AffinityFunction affinityFunction() {
+        return ccfg.getAffinity();
+    }
+
+    /**
      * @return Affinity.
      */
     public GridAffinityAssignmentCache affinity() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/e65697d2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index 50333db..eb8aa91 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@ -145,7 +145,7 @@ class ClusterCachesInfo {
         CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "cacheMode", 
"Cache mode",
             locAttr.cacheMode(), rmtAttr.cacheMode(), true);
 
-        CU.checkAttributeMismatch(log, rmtCfg.getGroupName(), rmt, 
"groupName", "Group name",
+        CU.checkAttributeMismatch(log, rmtCfg.getGroupName(), rmt, 
"groupName", "Cache group name",
             locCfg.getGroupName(), rmtCfg.getGroupName(), true);
 
         if (rmtAttr.cacheMode() != LOCAL) {
@@ -158,6 +158,9 @@ class ClusterCachesInfo {
             CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, 
"cachePreloadMode",
                 "Cache preload mode", locAttr.cacheRebalanceMode(), 
rmtAttr.cacheRebalanceMode(), true);
 
+            CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, 
"topologyValidator",
+                "Cache topology validator", 
locAttr.topologyValidatorClassName(), rmtAttr.topologyValidatorClassName(), 
true);
+
             ClusterNode rmtNode = ctx.discovery().node(rmt);
 
             if (CU.affinityNode(ctx.discovery().localNode(), 
locCfg.getNodeFilter())

http://git-wip-us.apache.org/repos/asf/ignite/blob/e65697d2/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 59071b9..71df0eb 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
@@ -58,7 +58,7 @@ public class GridCacheAffinityManager extends 
GridCacheManagerAdapter {
 
     /** {@inheritDoc} */
     @Override public void start0() throws IgniteCheckedException {
-        affFunction = cctx.group().config().getAffinity();
+        affFunction = cctx.group().affinityFunction();
         affMapper = cctx.config().getAffinityMapper();
 
         aff = cctx.group().affinity();

http://git-wip-us.apache.org/repos/asf/ignite/blob/e65697d2/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 662d558..e00ba5f 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
@@ -539,11 +539,9 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
      */
     private void prepare(CacheConfiguration cfg, Collection<Object> objs) 
throws IgniteCheckedException {
         prepare(cfg, cfg.getEvictionPolicy(), false);
-        prepare(cfg, cfg.getAffinity(), false);
         prepare(cfg, cfg.getAffinityMapper(), false);
         prepare(cfg, cfg.getEvictionFilter(), false);
         prepare(cfg, cfg.getInterceptor(), false);
-        prepare(cfg, cfg.getTopologyValidator(), false);
 
         NearCacheConfiguration nearCfg = cfg.getNearConfiguration();
 
@@ -577,11 +575,9 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
         CacheConfiguration cfg = cctx.config();
 
         cleanup(cfg, cfg.getEvictionPolicy(), false);
-        cleanup(cfg, cfg.getAffinity(), false);
         cleanup(cfg, cfg.getAffinityMapper(), false);
         cleanup(cfg, cfg.getEvictionFilter(), false);
         cleanup(cfg, cfg.getInterceptor(), false);
-        cleanup(cfg, cfg.getTopologyValidator(), false);
         cleanup(cfg, cctx.store().configuredStore(), false);
 
         if (!CU.isUtilityCache(cfg.getName()) && 
!CU.isSystemCache(cfg.getName())) {
@@ -598,6 +594,16 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
     }
 
     /**
+     * @param grp Cache group.
+     */
+    private void cleanup(CacheGroupInfrastructure grp) {
+        CacheConfiguration cfg = grp.config();
+
+        for (Object obj : grp.configuredUserObjects())
+            cleanup(cfg, obj, false);
+    }
+
+    /**
      * @param cfg Cache configuration.
      * @param rsrc Resource.
      * @param near Near flag.
@@ -1159,7 +1165,7 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
                         stopCache(cache, true, false);
 
                         if (!grp.hasCaches())
-                            grp.stopGroup();
+                            stopCacheGroup(grp);
                     }
                 }
             });
@@ -1965,6 +1971,11 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
             reuseList,
             exchTopVer);
 
+        for (Object obj : grp.configuredUserObjects())
+            prepare(cfg, obj, false);
+
+        U.startLifecycleAware(grp.configuredUserObjects());
+
         grp.start();
 
         CacheGroupInfrastructure old = cacheGrps.put(desc.groupId(), grp);
@@ -2099,7 +2110,18 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
         CacheGroupInfrastructure grp = cacheGrps.remove(grpId);
 
         if (grp != null)
-            grp.stopGroup();
+            stopCacheGroup(grp);
+    }
+
+    /**
+     * @param grp Cache group.
+     */
+    private void stopCacheGroup(CacheGroupInfrastructure grp) {
+        grp.stopGroup();
+
+        U.stopLifecycleAware(log, grp.configuredUserObjects());
+
+        cleanup(grp);
     }
 
     /**
@@ -3415,12 +3437,10 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
     private Iterable<Object> lifecycleAwares(CacheConfiguration ccfg, 
Object... objs) {
         Collection<Object> ret = new ArrayList<>(7 + objs.length);
 
-        ret.add(ccfg.getAffinity());
         ret.add(ccfg.getAffinityMapper());
         ret.add(ccfg.getEvictionFilter());
         ret.add(ccfg.getEvictionPolicy());
         ret.add(ccfg.getInterceptor());
-        ret.add(ccfg.getTopologyValidator());
 
         NearCacheConfiguration nearCfg = ccfg.getNearConfiguration();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e65697d2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java
index f6032fa..1cdeb3f 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java
@@ -63,12 +63,7 @@ public class GridCacheAffinityImpl<K, V> implements 
Affinity<K> {
 
     /** {@inheritDoc} */
     @Override public int partitions() {
-        CacheConfiguration ccfg = cctx.config();
-
-        if (ccfg == null)
-            throw new IgniteException(FAILED_TO_FIND_CACHE_ERR_MSG + 
cctx.name());
-
-        return ccfg.getAffinity().partitions();
+        return cctx.group().affinityFunction().partitions();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/e65697d2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 5876304..1a36e4d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -153,7 +153,7 @@ public class GridDhtPartitionTopologyImpl implements 
GridDhtPartitionTopology {
 
         log = ctx.logger(getClass());
 
-        locParts = new 
AtomicReferenceArray<>(grp.config().getAffinity().partitions());
+        locParts = new 
AtomicReferenceArray<>(grp.affinityFunction().partitions());
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/e65697d2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index 14558e3..6725773 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -1178,8 +1178,8 @@ public class GridDhtPartitionsExchangeFuture extends 
GridFutureAdapter<AffinityT
 
                 boolean valid = true;
 
-                if (grp.config().getTopologyValidator() != null && 
!grp.systemCache())
-                    valid = 
grp.config().getTopologyValidator().validate(discoEvt.topologyNodes());
+                if (grp.topologyValidator() != null && !grp.systemCache())
+                    valid = 
grp.topologyValidator().validate(discoEvt.topologyNodes());
 
                 m.put(grp.groupId(), new CacheValidation(valid, lostParts));
             }
@@ -1206,7 +1206,7 @@ public class GridDhtPartitionsExchangeFuture extends 
GridFutureAdapter<AffinityT
 
             if (exchId.isLeft()) {
                 for (CacheGroupInfrastructure grp : cctx.cache().cacheGroups())
-                    grp.config().getAffinity().removeNode(exchId.nodeId());
+                    grp.affinityFunction().removeNode(exchId.nodeId());
             }
 
             exchActions = null;
@@ -1251,7 +1251,7 @@ public class GridDhtPartitionsExchangeFuture extends 
GridFutureAdapter<AffinityT
                     cctx.name());
         }
 
-        if (grp.needsRecovery() || grp.config().getTopologyValidator() != 
null) {
+        if (grp.needsRecovery() || grp.topologyValidator() != null) {
             CacheValidation validation = grpValidRes.get(grp.groupId());
 
             if (validation == null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/e65697d2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java
index 057b0d6..2e551f9 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java
@@ -202,6 +202,8 @@ public class IgniteTopologyValidatorGridSplitCacheTest 
extends GridCommonAbstrac
 
     /**
      * Resolves split by client node join.
+     *
+     * @throws Exception If failed.
      */
     private void resolveSplit() throws Exception {
         startGrid(RESOLVER_GRID_IDX);
@@ -305,6 +307,7 @@ public class IgniteTopologyValidatorGridSplitCacheTest 
extends GridCommonAbstrac
             return true;
         }
 
+        /** {@inheritDoc} */
         @Override public void start() throws IgniteException {
             if (ignite.cluster().localNode().isClient())
                 return;
@@ -327,12 +330,15 @@ public class IgniteTopologyValidatorGridSplitCacheTest 
extends GridCommonAbstrac
 
         /**
          * @param node Node.
+         * @return {@code True} if this is marker node.
          */
         private boolean isMarkerNode(ClusterNode node) {
             return node.isClient() && node.attribute(ACTIVATOR_NODE_ATTR) != 
null;
         }
 
-        @Override public void stop() throws IgniteException {
+        /** {@inheritDoc} */
+        @Override public void stop() {
+            // No-op.
         }
     }
 }
\ No newline at end of file

Reply via email to