ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [20/20] ignite git commit: ignite-3483 Use server nodes filter as default for services deployed from configuration
Date Mon, 18 Jul 2016 09:38:01 GMT
ignite-3483 Use server nodes filter as default for services deployed from configuration


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

Branch: refs/heads/ignite-3483
Commit: b5713555f692a89da9289f1007ca3a1ad178cca2
Parents: 4897315
Author: sboikov <sboikov@gridgain.com>
Authored: Mon Jul 18 12:31:40 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Mon Jul 18 12:31:40 2016 +0300

----------------------------------------------------------------------
 .../internal/cluster/ClusterGroupAdapter.java   |  9 +++-
 .../service/GridServiceProcessor.java           |  7 ++-
 .../service/GridServiceClientNodeTest.java      | 48 ++++++++++++++++++++
 3 files changed, 62 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b5713555/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
index c664f1e..a180928 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
@@ -390,7 +390,7 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable
{
 
     /** {@inheritDoc} */
     @Override public ClusterGroup forServers() {
-        return forPredicate(new AttributeFilter(IgniteNodeAttributes.ATTR_CLIENT_MODE, false));
+        return forPredicate(serversFilter());
     }
 
     /** {@inheritDoc} */
@@ -738,6 +738,13 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable
{
     }
 
     /**
+     * @return Server nodes filter.
+     */
+    public static IgnitePredicate<ClusterNode> serversFilter() {
+        return new AttributeFilter(IgniteNodeAttributes.ATTR_CLIENT_MODE, false);
+    }
+
+    /**
      */
     private static class CachesFilter implements IgnitePredicate<ClusterNode> {
         /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5713555/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 b418ba2..63181da 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
@@ -52,6 +52,7 @@ import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
 import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
 import org.apache.ignite.internal.processors.GridProcessorAdapter;
@@ -250,8 +251,12 @@ public class GridServiceProcessor extends GridProcessorAdapter {
         if (cfgs != null) {
             Collection<IgniteInternalFuture<?>> futs = new ArrayList<>();
 
-            for (ServiceConfiguration c : ctx.config().getServiceConfiguration())
+            for (ServiceConfiguration c : ctx.config().getServiceConfiguration()) {
+                if (c.getNodeFilter() == null)
+                    c.setNodeFilter(ClusterGroupAdapter.serversFilter());
+
                 futs.add(deploy(c));
+            }
 
             // Await for services to deploy.
             for (IgniteInternalFuture<?> f : futs)

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5713555/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java
index 665294d..cec8949 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java
@@ -17,11 +17,14 @@
 
 package org.apache.ignite.internal.processors.service;
 
+import java.util.Collection;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.services.ServiceConfiguration;
+import org.apache.ignite.services.ServiceDescriptor;
 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;
@@ -35,8 +38,14 @@ public class GridServiceClientNodeTest extends GridCommonAbstractTest {
     protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
 
     /** */
+    private static String CFG_SRVC_NAME = "testService";
+
+    /** */
     private boolean client;
 
+    /** */
+    private boolean deployFromCfg;
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -45,6 +54,16 @@ public class GridServiceClientNodeTest extends GridCommonAbstractTest {
         ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setMaxMissedClientHeartbeats(30);
         ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setHeartbeatFrequency(1000);
 
+        if (deployFromCfg) {
+            ServiceConfiguration sCfg = new ServiceConfiguration();
+            sCfg.setName(CFG_SRVC_NAME);
+            sCfg.setService(new DummyService());
+            sCfg.setMaxPerNodeCount(1);
+            sCfg.setTotalCount(3);
+
+            cfg.setServiceConfiguration(sCfg);
+        }
+
         cfg.setClientMode(client);
 
         return cfg;
@@ -60,6 +79,35 @@ public class GridServiceClientNodeTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testNoDeployOnClient() throws Exception {
+        CountDownLatch latch = new CountDownLatch(1);
+
+        DummyService.exeLatch(CFG_SRVC_NAME, latch);
+
+        deployFromCfg = true;
+
+        startGrid(1);
+
+        deployFromCfg = false;
+        client = true;
+
+        Ignite ignite = startGrid(2);
+
+        assertTrue(latch.await(5000, TimeUnit.MILLISECONDS));
+
+        Collection<ServiceDescriptor> descriptors = ignite.services().serviceDescriptors();
+
+        assertEquals(1, descriptors.size());
+
+        ServiceDescriptor desc = descriptors.iterator().next();
+
+        // Service must not be deployed by default on a client node.
+        assertNull(desc.topologySnapshot().get(ignite.cluster().localNode().id()));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testDeployFromClient() throws Exception {
         startGrids(3);
 


Mime
View raw message