IGNITE-8754 Node outside of baseline does not start when service configured

Signed-off-by: Andrey Gura <ag...@apache.org>


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

Branch: refs/heads/ignite-8446
Commit: b1832673eba37919ad33f9d1c42b9b6bfa7e5a34
Parents: c540c5d
Author: vd-pyatkov <vpyat...@gridgain.com>
Authored: Fri Jul 6 18:11:55 2018 +0300
Committer: Andrey Gura <ag...@apache.org>
Committed: Fri Jul 6 18:11:55 2018 +0300

----------------------------------------------------------------------
 .../service/GridServiceProcessor.java           |  6 +-
 .../ServiceDeploymentOutsideBaselineTest.java   | 99 +++++++++++++++++++-
 2 files changed, 100 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b1832673/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index 377a592..0e4a318 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -1528,7 +1528,11 @@ public class GridServiceProcessor extends 
GridProcessorAdapter implements Ignite
 
             qry.keepAll(false);
 
-            if (!cache.context().affinityNode()) {
+            DiscoveryDataClusterState clusterState = 
ctx.state().clusterState();
+
+            if ((clusterState.hasBaselineTopology()
+                && !CU.baselineNode(ctx.cluster().get().localNode(), 
clusterState))
+                || !cache.context().affinityNode()) {
                 ClusterNode oldestSrvNode =
                     
ctx.discovery().oldestAliveServerNode(AffinityTopologyVersion.NONE);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b1832673/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java
index 1a5b630..878ec0d 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java
@@ -25,11 +25,17 @@ import 
org.apache.ignite.configuration.DataRegionConfiguration;
 import org.apache.ignite.configuration.DataStorageConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.GridStringBuilder;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.services.ServiceConfiguration;
 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;
 
 /** */
@@ -148,6 +154,78 @@ public class ServiceDeploymentOutsideBaselineTest extends 
GridCommonAbstractTest
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testStaticDeployFromEachPersistentNodes() throws Exception {
+        checkDeployFromEachNodes(true, true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDeployFromEachNodes() throws Exception {
+        checkDeployFromEachNodes(false, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testStaticDeployFromEachNodes() throws Exception {
+        checkDeployFromEachNodes(false, true);
+    }
+
+    /**
+     * @param persistence If {@code true}, then persistence will be enabled.
+     * @param staticDeploy If {@code true}, then static deployment will be 
used instead of a dynamic one.
+     * @throws Exception If failed.
+     */
+    private void checkDeployFromEachNodes(boolean persistence, boolean 
staticDeploy) throws Exception {
+        this.persistence = persistence;
+
+        CountDownLatch exeLatch = new CountDownLatch(1);
+
+        DummyService.exeLatch(SERVICE_NAME, exeLatch);
+
+        Ignite ignite0 = deployServiceFromNewNode(staticDeploy, 0);
+
+        if (persistence)
+            ignite0.cluster().active(true);
+        else {
+            IgniteCluster cluster = ignite0.cluster();
+
+            cluster.setBaselineTopology(cluster.topologyVersion());
+        }
+
+        assertTrue(exeLatch.await(10, TimeUnit.SECONDS));
+
+        IgniteInternalFuture startFut = GridTestUtils.runAsync(() -> {
+            try {
+                deployServiceFromNewNode(staticDeploy);
+            }
+            catch (Exception e) {
+                fail(e.getMessage());
+            }
+        });
+
+        try {
+            startFut.get(10, TimeUnit.SECONDS);
+        }
+        catch (IgniteFutureTimeoutCheckedException e) {
+            GridStringBuilder sb = new SB()
+                .a("Node can not start out of baseline till ")
+                .a(10_000L)
+                .a("ms")
+                .a(U.nl());
+
+            for (Thread t: Thread.getAllStackTraces().keySet())
+                if (t.getName().startsWith("async-runnable-runner"))
+                    U.printStackTrace(t.getId(), sb);
+
+            fail(sb.toString());
+        }
+    }
+
+    /**
      * @param persistence If {@code true}, then persistence will be enabled.
      * @param staticDeploy If {@code true}, then static deployment will be 
used instead of a dynamic one.
      * @throws Exception If failed.
@@ -251,19 +329,32 @@ public class ServiceDeploymentOutsideBaselineTest extends 
GridCommonAbstractTest
      * @param staticDeploy If {@code true}, then static deployment will be 
used instead of a dynamic one.
      * @throws Exception If node failed to start.
      */
-    private void deployServiceFromNewNode(boolean staticDeploy) throws 
Exception {
+    private Ignite deployServiceFromNewNode(boolean staticDeploy) throws 
Exception {
+        return deployServiceFromNewNode(staticDeploy, 1);
+    }
+
+    /**
+     * @param staticDeploy If {@code true}, then static deployment will be 
used instead of a dynamic one.
+     * @param nodeNum Nouber of test node.
+     * @throws Exception If node failed to start.
+     */
+    private Ignite deployServiceFromNewNode(boolean staticDeploy, int nodeNum) 
throws Exception {
+        Ignite ignite;
+
         if (staticDeploy) {
             srvcCfg = getClusterSingletonServiceConfiguration();
 
-            startGrid(1);
+            ignite = startGrid(nodeNum);
         }
         else {
-            Ignite node = startGrid(1);
+            ignite = startGrid(nodeNum);
 
-            IgniteFuture<Void> depFut = 
node.services().deployClusterSingletonAsync(SERVICE_NAME, new DummyService());
+            IgniteFuture<Void> depFut = 
ignite.services().deployClusterSingletonAsync(SERVICE_NAME, new DummyService());
 
             depFut.get(10, TimeUnit.SECONDS);
         }
+
+        return ignite;
     }
 
     /**

Reply via email to