ignite-12336 fix npe in cluster state processor on stop daemon client node

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

Branch: refs/heads/ignite-2.1.2-exchange
Commit: b9999269468cd6e91a8c855adb2efc6e017df09d
Parents: 7c515ee
Author: Dmitriy Govorukhin <[email protected]>
Authored: Thu Jun 22 13:55:44 2017 +0300
Committer: Dmitriy Govorukhin <[email protected]>
Committed: Thu Jun 22 13:55:44 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java    | 10 +++-
 .../IgniteStandByClusterTest.java               | 51 ++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b9999269/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 6750582..c425bfb 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
@@ -692,8 +692,16 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
         for (GridCacheSharedManager mgr : sharedCtx.managers())
             mgr.start(sharedCtx);
 
-        if (ctx.config().isDaemon())
+        if (ctx.config().isDaemon()) {
+            ctx.state().cacheProcessorStarted(new CacheJoinNodeDiscoveryData(
+                IgniteUuid.randomUuid(),
+                Collections.<String, CacheInfo>emptyMap(),
+                Collections.<String, CacheInfo>emptyMap(),
+                false
+            ));
+
             return;
+        }
 
         Map<String, CacheInfo> caches = new HashMap<>();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b9999269/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java
index 5eebc94..c3bdcda 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache.persistence.standbycluster;
 
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Map;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cluster.ClusterNode;
@@ -40,8 +41,12 @@ import org.junit.Assert;
  *
  */
 public class IgniteStandByClusterTest extends GridCommonAbstractTest {
+    /** */
     private static final TcpDiscoveryIpFinder vmIpFinder = new 
TcpDiscoveryVmIpFinder(true);
 
+    /**
+     *
+     */
     @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
 
@@ -52,6 +57,9 @@ public class IgniteStandByClusterTest extends 
GridCommonAbstractTest {
         return cfg;
     }
 
+    /**
+     * @throws Exception if fail.
+     */
     public void testNotStartDynamicCachesOnClientAfterActivation() throws 
Exception {
         final String cacheName0 = "cache0";
         final String cacheName = "cache";
@@ -117,6 +125,9 @@ public class IgniteStandByClusterTest extends 
GridCommonAbstractTest {
         assertNotNull(ig3.cache(cacheName));
     }
 
+    /**
+     * @throws Exception if fail.
+     */
     public void testStaticCacheStartAfterActivationWithCacheFilter() throws 
Exception {
         String cache1 = "cache1";
         String cache2 = "cache2";
@@ -187,6 +198,9 @@ public class IgniteStandByClusterTest extends 
GridCommonAbstractTest {
         Assert.assertNotNull(caches3.get(cache3));
     }
 
+    /**
+     * @throws Exception if fail.
+     */
     public void testSimple() throws Exception {
         IgniteEx ig = startGrid(0);
 
@@ -209,6 +223,29 @@ public class IgniteStandByClusterTest extends 
GridCommonAbstractTest {
         assertEquals("1", cache.get(1));
     }
 
+    /**
+     * @throws Exception if fail.
+     */
+    public void testJoinDaemonAndDaemonStop() throws Exception {
+        IgniteEx ig = startGrid(0);
+
+        IgniteEx daemon = startGrid(
+            getConfiguration("daemon")
+                .setDaemon(true)
+                .setClientMode(true)
+        );
+
+        Collection<ClusterNode> daemons = ig.cluster().forDaemons().nodes();
+
+        Assert.assertEquals(1, daemons.size());
+        assertEquals(daemon.localNode().id(), daemons.iterator().next().id());
+
+        daemon.close();
+    }
+
+    /**
+     * @throws Exception if fail.
+     */
     public void testRestartCluster() throws Exception {
         IgniteEx ig1 = startGrid(getConfiguration("node1"));
         IgniteEx ig2 = startGrid(getConfiguration("node2"));
@@ -241,18 +278,29 @@ public class IgniteStandByClusterTest extends 
GridCommonAbstractTest {
             assertEquals(String.valueOf(i), cache2.get(i));
     }
 
+    /**
+     *
+     */
     private static class NodeFilterIgnoreByName implements 
IgnitePredicate<ClusterNode> {
+        /** */
         private final String name;
 
+        /**
+         * @param name
+         */
         private NodeFilterIgnoreByName(String name) {
             this.name = name;
         }
 
+        /** */
         @Override public boolean apply(ClusterNode node) {
             return !name.equals(node.consistentId());
         }
     }
 
+    /**
+     *
+     */
     @Override protected void beforeTest() throws Exception {
         super.beforeTest();
 
@@ -261,6 +309,9 @@ public class IgniteStandByClusterTest extends 
GridCommonAbstractTest {
         deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), 
"db", true));
     }
 
+    /**
+     *
+     */
     @Override protected void afterTest() throws Exception {
         super.beforeTest();
 

Reply via email to