ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-5075
Date Fri, 12 May 2017 08:26:48 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-5075 fa86067ad -> d1c71ef42


ignite-5075


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

Branch: refs/heads/ignite-5075
Commit: d1c71ef4275611a2a01f7311adbfad9daf7490b9
Parents: fa86067
Author: sboikov <sboikov@gridgain.com>
Authored: Fri May 12 10:57:45 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri May 12 11:26:41 2017 +0300

----------------------------------------------------------------------
 .../cache/CacheAffinitySharedManager.java       |   2 +-
 .../processors/cache/CacheGroupDescriptor.java  |   2 +-
 .../cache/CacheGroupInfrastructure.java         |  10 ++
 .../processors/cache/ClusterCachesInfo.java     |  22 ++--
 .../processors/cache/ExchangeActions.java       |   8 +-
 .../dht/GridDhtPartitionTopologyImpl.java       |   5 +-
 .../GridDhtPartitionsExchangeFuture.java        |  17 ++-
 .../processors/cache/IgniteCacheGroupsTest.java | 131 ++++++++++++++++++-
 .../processors/cache/IgniteCacheStartTest.java  |   4 +-
 9 files changed, 165 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d1c71ef4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
index f67c08a..15fe7f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
@@ -394,7 +394,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
 
         for (CacheGroupInfrastructure grp : cctx.cache().cacheGroups()) {
             if (grp.affinity().lastVersion().equals(AffinityTopologyVersion.NONE))
-                initAffinity(registeredGrps.get(grp.groupId()), grp.affinity(), fut, lateAffAssign);
+                initAffinity(registeredGrps.get(grp.groupId()), grp.affinity(), fut, false);
         }
 
         if (crd) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/d1c71ef4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java
index 10acc36..0e85e7f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java
@@ -99,7 +99,7 @@ public class CacheGroupDescriptor {
     }
 
     boolean hasCaches() {
-        return caches != null;
+        return caches != null && !caches.isEmpty();
     }
 
     public boolean sharedGroup() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/d1c71ef4/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 f40acb6..d8752d4 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
@@ -326,6 +326,16 @@ public class CacheGroupInfrastructure {
     }
 
     /**
+     * @return Group name.
+     */
+    @Nullable public String nameForLog() {
+        if (ccfg.getGroupName() == null)
+            return "Cache-" + ccfg.getName();
+
+        return "CacheGroup-" + ccfg.getGroupName();
+    }
+
+    /**
      * @return Group ID.
      */
     public int groupId() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/d1c71ef4/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 b62a3cb..f5c76dd 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
@@ -17,9 +17,19 @@
 
 package org.apache.ignite.internal.processors.cache;
 
+import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
 import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.CacheExistsException;
@@ -37,18 +47,6 @@ import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.spi.discovery.DiscoveryDataBag;
 
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
 import static org.apache.ignite.cache.CacheMode.LOCAL;
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;

http://git-wip-us.apache.org/repos/asf/ignite/blob/d1c71ef4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
index 87d6345..a765c1b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
@@ -298,8 +298,8 @@ public class ExchangeActions {
 
     public boolean cacheGroupStarting(int grpId) {
         if (cacheGrpsToStart != null) {
-            for (CacheGroupDescriptor grpToStop : cacheGrpsToStart) {
-                if (grpToStop.groupId() == grpId)
+            for (CacheGroupDescriptor grp : cacheGrpsToStart) {
+                if (grp.groupId() == grpId)
                     return true;
             }
         }
@@ -320,8 +320,8 @@ public class ExchangeActions {
 
     public boolean cacheGroupStopping(int grpId) {
         if (cacheGrpsToStop != null) {
-            for (CacheGroupDescriptor grpToStop : cacheGrpsToStop) {
-                if (grpToStop.groupId() == grpId)
+            for (CacheGroupDescriptor grp : cacheGrpsToStop) {
+                if (grp.groupId() == grpId)
                     return true;
             }
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d1c71ef4/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 714d968..770c791 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
@@ -495,7 +495,6 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology
{
     /** {@inheritDoc} */
     @Override public void beforeExchange(GridDhtPartitionsExchangeFuture exchFut, boolean
affReady)
         throws IgniteCheckedException {
-
         DiscoveryEvent discoEvt = exchFut.discoveryEvent();
 
         ClusterState newState = exchFut.newClusterState();
@@ -1087,8 +1086,8 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology
{
         lock.readLock().lock();
 
         try {
-            assert node2part != null && node2part.valid() : "Invalid node2part [node2part:
" + node2part +
-                ", grp=" + grp.name() +
+            assert node2part != null && node2part.valid() : "Invalid node2part [node2part="
+ node2part +
+                ", grp=" + grp.nameForLog() +
                 ", stopping=" + stopping +
                 ", locNodeId=" + ctx.localNode().id() +
                 ", locName=" + ctx.igniteInstanceName() + ']';

http://git-wip-us.apache.org/repos/asf/ignite/blob/d1c71ef4/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 026b24e..4fff062 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
@@ -808,9 +808,8 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
 
         boolean topChanged = discoEvt.type() != EVT_DISCOVERY_CUSTOM_EVT || affChangeMsg
!= null;
 
-        //todo check
         for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
-            if (cacheCtx.isLocal() || stopping(cacheCtx.cacheId()))
+            if (cacheCtx.isLocal() || cacheStopping(cacheCtx.cacheId()))
                 continue;
 
             if (topChanged) {
@@ -832,10 +831,10 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
 
         // If a backup request, synchronously wait for backup start.
         if (discoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT) {
-            DiscoveryCustomMessage customMessage = ((DiscoveryCustomEvent)discoEvt).customMessage();
+            DiscoveryCustomMessage customMsg = ((DiscoveryCustomEvent)discoEvt).customMessage();
 
-            if (customMessage instanceof StartFullSnapshotAckDiscoveryMessage) {
-                StartFullSnapshotAckDiscoveryMessage backupMsg = (StartFullSnapshotAckDiscoveryMessage)customMessage;
+            if (customMsg instanceof StartFullSnapshotAckDiscoveryMessage) {
+                StartFullSnapshotAckDiscoveryMessage backupMsg = (StartFullSnapshotAckDiscoveryMessage)customMsg;
 
                 if (!cctx.localNode().isClient() && !cctx.localNode().isDaemon())
{
                     ClusterNode node = cctx.discovery().node(backupMsg.initiatorNodeId());
@@ -1025,7 +1024,11 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
             U.dumpThreads(log);
     }
 
-    public boolean cacheGroupStopping(int grpId) {
+    /**
+     * @param grpId Cache group ID to check.
+     * @return {@code True} if cache group us stopping by this exchange/
+     */
+    private boolean cacheGroupStopping(int grpId) {
         return exchActions != null && exchActions.cacheGroupStopping(grpId);
     }
 
@@ -1033,7 +1036,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
      * @param cacheId Cache ID to check.
      * @return {@code True} if cache is stopping by this exchange.
      */
-    public boolean stopping(int cacheId) {
+    private boolean cacheStopping(int cacheId) {
         return exchActions != null && exchActions.cacheStopped(cacheId);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d1c71ef4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
index ff20803..5933833 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
@@ -18,17 +18,24 @@
 package org.apache.ignite.internal.processors.cache;
 
 import java.io.Serializable;
+import java.util.concurrent.ThreadLocalRandom;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
 
 /**
  *
@@ -38,6 +45,12 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
     /** */
     private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
 
+    /** */
+    private static final String GROUP1 = "grp1";
+
+    /** */
+    private static final String GROUP2 = "grp2";
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -50,17 +63,88 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
     }
 
     /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        super.beforeTestsStarted();
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
 
-        startGrids(1);
+        super.afterTest();
     }
 
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        stopAllGrids();
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCreateDestroyCaches1() throws Exception {
+        createDestroyCaches(1);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCreateDestroyCaches2() throws Exception {
+        createDestroyCaches(5);
+    }
+
+    /**
+     * @param srvs Number of server nodes.
+     * @throws Exception If failed.
+     */
+    private void createDestroyCaches(int srvs) throws Exception {
+        startGridsMultiThreaded(srvs);
+
+        Ignite srv0 = ignite(0);
+
+        for (int i = 0; i < srvs; i++)
+            checkCacheGroup(i, GROUP1, false);
+
+        for (int iter = 0; iter < 3; iter++) {
+            log.info("Iteration: " + iter);
+
+            srv0.createCache(cacheConfiguration(GROUP1, "cache1", ATOMIC, 2));
+
+            for (int i = 0; i < srvs; i++) {
+                checkCacheGroup(i, GROUP1, true);
+
+                checkCache(i, "cache1");
+            }
+
+            srv0.createCache(cacheConfiguration(GROUP1, "cache2", ATOMIC, 2));
+
+            for (int i = 0; i < srvs; i++) {
+                checkCacheGroup(i, GROUP1, true);
 
-        super.afterTestsStopped();
+                checkCache(i, "cache2");
+            }
+
+            srv0.destroyCache("cache1");
+
+            for (int i = 0; i < srvs; i++) {
+                checkCacheGroup(i, GROUP1, true);
+
+                //checkCache(i, "cache2");
+            }
+
+            srv0.destroyCache("cache2");
+
+            for (int i = 0; i < srvs; i++)
+                checkCacheGroup(i, GROUP1, false);
+        }
+    }
+
+    /**
+     * @param idx Node index.
+     * @param cacheName Cache name.
+     */
+    private void checkCache(int idx, String cacheName) {
+        IgniteCache cache = ignite(idx).cache(cacheName);
+
+        ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+        for (int i = 0; i < 10; i++) {
+            Integer key = rnd.nextInt();
+
+            cache.put(key, i);
+
+            assertEquals(i, cache.get(key));
+        }
     }
 
     /**
@@ -198,7 +282,40 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
         ccfg.setGroupName(grpName);
         ccfg.setAtomicityMode(atomicityMode);
         ccfg.setBackups(backups);
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
 
         return ccfg;
     }
+
+    /**
+     * @param idx Node index.
+     * @param grpName Cache group name.
+     * @param expGrp {@code True} if cache group should be created.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void checkCacheGroup(int idx, final String grpName, final boolean expGrp) throws
IgniteCheckedException {
+        final IgniteKernal node = (IgniteKernal)ignite(idx);
+
+        assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                return expGrp == (cacheGroup(node, grpName) != null);
+            }
+        }, 1000));
+
+        assertNotNull(node.context().cache().cache(CU.UTILITY_CACHE_NAME));
+    }
+
+    /**
+     * @param node Node.
+     * @param grpName Cache group name.
+     * @return Cache group.
+     */
+    private CacheGroupInfrastructure cacheGroup(IgniteKernal node, String grpName) {
+        for (CacheGroupInfrastructure grp : node.context().cache().cacheGroups()) {
+            if (grpName.equals(grp.name()))
+                return grp;
+        }
+
+        return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d1c71ef4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java
index eb8077f..4b2d087 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache;
 
 import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
@@ -176,8 +177,9 @@ public class IgniteCacheStartTest extends GridCommonAbstractTest {
      * @param idx Node index.
      * @param cacheName Cache name.
      * @param expCache {@code True} if cache should be created.
+     * @throws IgniteCheckedException If failed.
      */
-    private void checkCache(int idx, final String cacheName, final boolean expCache) throws
IgniteInterruptedCheckedException {
+    private void checkCache(int idx, final String cacheName, final boolean expCache) throws
IgniteCheckedException {
         final IgniteKernal node = (IgniteKernal)ignite(idx);
 
         assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {


Mime
View raw message