ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [12/50] incubator-ignite git commit: # IGNITE-943 Remove TcpDiscoverySpi.clientMode, create TcpDiscoverySpi.forceServerMode
Date Mon, 01 Jun 2015 17:24:03 GMT
# IGNITE-943 Remove TcpDiscoverySpi.clientMode, create TcpDiscoverySpi.forceServerMode


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

Branch: refs/heads/ignite-218
Commit: e2e90c4bd57ec74c6816f1c595ff8ff867b5a757
Parents: 77d1dcb
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Thu May 28 14:45:15 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Thu May 28 14:46:52 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/internal/IgnitionEx.java  | 13 +------
 .../discovery/GridDiscoveryManager.java         |  2 +-
 .../ignite/spi/discovery/DiscoverySpi.java      |  5 ++-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      | 39 +++++++++++++-------
 .../spi/discovery/tcp/TcpDiscoverySpiMBean.java |  5 ++-
 .../internal/GridReleaseTypeSelfTest.java       |  2 -
 .../GridDiscoveryManagerAliveCacheSelfTest.java |  4 +-
 .../GridDiscoveryManagerAttributesSelfTest.java | 17 ++++-----
 .../discovery/GridDiscoveryManagerSelfTest.java | 17 ++++-----
 ...acheTcpClientDiscoveryMultiThreadedTest.java |  4 +-
 .../IgniteClientDataStructuresAbstractTest.java |  4 +-
 .../GridCacheClientModesAbstractSelfTest.java   |  3 ++
 ...ientModesTcpClientDiscoveryAbstractTest.java |  6 +--
 ...pClientDiscoveryMarshallerCheckSelfTest.java |  8 +---
 .../tcp/TcpClientDiscoverySpiSelfTest.java      | 35 ++----------------
 .../tcp/TcpDiscoveryConcurrentStartTest.java    |  8 +---
 .../tcp/TcpDiscoveryMultiThreadedTest.java      | 16 +-------
 .../tcp/TcpDiscoverySpiConfigSelfTest.java      |  8 ----
 18 files changed, 65 insertions(+), 131 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 7eb6262..6e4efb5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -1743,13 +1743,6 @@ public class IgnitionEx {
                 myCfg.setFileSystemConfiguration(clone);
             }
 
-            if (myCfg.isClientMode() == null || !myCfg.isClientMode()) {
-                if (myCfg.getDiscoverySpi() != null && myCfg.getDiscoverySpi().isClientMode())
{
-                    throw new IgniteCheckedException("DiscoverySpi is in client mode, but
node is not in client mode" +
-                        "(consider changing 'IgniteConfiguration.clientMode' to 'true').");
-                }
-            }
-
             initializeDefaultSpi(myCfg);
 
             initializeDefaultCacheConfiguration(myCfg);
@@ -1814,13 +1807,9 @@ public class IgnitionEx {
          * @param cfg Ignite configuration.
          */
         private void initializeDefaultSpi(IgniteConfiguration cfg) {
-            if (cfg.getDiscoverySpi() == null) {
+            if (cfg.getDiscoverySpi() == null)
                 cfg.setDiscoverySpi(new TcpDiscoverySpi());
 
-                if (Boolean.TRUE.equals(cfg.isClientMode()))
-                    ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setClientMode(true);
-            }
-
             if (cfg.getDiscoverySpi() instanceof TcpDiscoverySpi) {
                 TcpDiscoverySpi tcpDisco = (TcpDiscoverySpi)cfg.getDiscoverySpi();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 0f79084..a910950 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -285,7 +285,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
     /** {@inheritDoc} */
     @Override protected void onKernalStart0() throws IgniteCheckedException {
         if (Boolean.TRUE.equals(ctx.config().isClientMode()) && !getSpi().isClientMode())
-            ctx.performance().add("Enable client mode for TcpDiscoverySpi (set TcpDiscoverySpi.clientMode
to true)");
+            ctx.performance().add("Enable client mode for TcpDiscoverySpi (set TcpDiscoverySpi.forceServerMode
to true)");
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpi.java
index f9cec34..e7fbadc 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpi.java
@@ -154,9 +154,10 @@ public interface DiscoverySpi extends IgniteSpi {
     public void failNode(UUID nodeId);
 
     /**
-     * Whether or not discovery is in client mode.
+     * Whether or not discovery is started in client mode.
      *
      * @return {@code true} if node is in client mode.
+     * @throws IllegalStateException If discovery SPI has not started.
      */
-    public boolean isClientMode();
+    public boolean isClientMode() throws IllegalStateException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index aa8fb76..5a2ddd6 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -53,9 +53,11 @@ import java.util.concurrent.atomic.*;
  * Nodes are organized in ring. So almost all network exchange (except few cases) is
  * done across it.
  * <p>
- * Node may be started in client mode, in this case node does not insert to the ring,
+ * If node is configured as client node (see {@link IgniteConfiguration#clientMode})
+ * TcpDiscoverySpi starts in client mode too. In this case node does not insert to the ring,
  * it connects to any node in the ring router and communicated with that node only.
- * Thereby slowing or shutdown of client node will not affect whole cluster.
+ * Thereby slowing or shutdown of client node will not affect whole cluster. If you want
to start TcpDiscoverySpi in
+ * server mode regardless {@link IgniteConfiguration#clientMode} you can set {@link #forceSrvMode}
to true.
  * <p>
  * At startup SPI tries to send messages to random IP taken from
  * {@link TcpDiscoveryIpFinder} about self start (stops when send succeeds)
@@ -97,6 +99,7 @@ import java.util.concurrent.atomic.*;
  * <li>Thread priority for threads started by SPI (see {@link #setThreadPriority(int)})</li>
  * <li>IP finder clean frequency (see {@link #setIpFinderCleanFrequency(long)})</li>
  * <li>Statistics print frequency (see {@link #setStatisticsPrintFrequency(long)}</li>
+ * <li>Force server mode (see {@link #setForceServerMode(boolean)}</li>
  * </ul>
  * <h2 class="header">Java Example</h2>
  * <pre name="code" class="java">
@@ -309,7 +312,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi,
T
     protected TcpDiscoveryImpl impl;
 
     /** */
-    private boolean clientMode;
+    private boolean forceSrvMode;
 
     /** {@inheritDoc} */
     @Override public String getSpiState() {
@@ -368,20 +371,30 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi,
T
 
     /** {@inheritDoc} */
     @Override public boolean isClientMode() {
-        return clientMode;
+        if (impl == null)
+            throw new IllegalStateException("TcpDiscoverySpi has not started");
+
+        return impl instanceof ClientImpl;
     }
 
     /**
-     * @param clientMode New client mode.
+     * If {@code true} TcpDiscoverySpi will started in server mode regardless
+     * of {@link IgniteConfiguration#isClientMode()}
+     *
+     * @return forceServerMode flag.
      */
-    @IgniteSpiConfiguration(optional = true)
-    public TcpDiscoverySpi setClientMode(boolean clientMode) {
-        if (impl != null)
-            throw new IllegalStateException("You cannot change mode, TcpDiscoverySpi already
started.");
-
-        this.clientMode = clientMode;
+    public boolean isForceServerMode() {
+        return forceSrvMode;
+    }
 
-        return this;
+    /**
+     * If {@code true} TcpDiscoverySpi will started in server mode regardless
+     * of {@link IgniteConfiguration#isClientMode()}
+     *
+     * @param forceSrvMode forceServerMode flag.
+     */
+    public void setForceServerMode(boolean forceSrvMode) {
+        this.forceSrvMode = forceSrvMode;
     }
 
     /**
@@ -1500,7 +1513,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi,
T
 
     /** {@inheritDoc} */
     @Override public void spiStart(@Nullable String gridName) throws IgniteSpiException {
-        if (clientMode) {
+        if (!forceSrvMode && (Boolean.TRUE.equals(ignite.configuration().isClientMode())))
{
             if (ackTimeout == 0)
                 ackTimeout = DFLT_ACK_TIMEOUT_CLIENT;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
index 95281c3..6f2ea6f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
@@ -274,10 +274,11 @@ public interface TcpDiscoverySpiMBean extends IgniteSpiManagementMBean
{
     public void dumpDebugInfo();
 
     /**
-     * Whether or not discovery is in client mode.
+     * Whether or not discovery is started in client mode.
      *
      * @return {@code true} if node is in client mode.
+     * @throws IllegalStateException If discovery SPI has not started.
      */
     @MXBeanDescription("Client mode.")
-    public boolean isClientMode();
+    public boolean isClientMode() throws IllegalStateException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java
index e6a69cc..79e8905 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java
@@ -57,8 +57,6 @@ public class GridReleaseTypeSelfTest extends GridCommonAbstractTest {
                 }
             };
 
-            discoSpi.setClientMode(true);
-
             cfg.setClientMode(true);
         }
         else {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
index f928f6c..af4dd0f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
@@ -91,10 +91,8 @@ public class GridDiscoveryManagerAliveCacheSelfTest extends GridCommonAbstractTe
 
         TcpDiscoverySpi disc = new TcpDiscoverySpi();
 
-        if (clientMode && ((gridName.charAt(gridName.length() - 1) - '0') & 1)
!= 0) {
-            disc.setClientMode(true);
+        if (clientMode && ((gridName.charAt(gridName.length() - 1) - '0') & 1)
!= 0)
             cfg.setClientMode(true);
-        }
         else
             disc.setMaxMissedClientHeartbeats(50);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
index dbe7d72..e76c615 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
@@ -170,21 +170,20 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends
GridCommonA
      *
      */
     public static class RegularDiscovery extends GridDiscoveryManagerAttributesSelfTest {
-        // No-op.
-    }
-
-    /**
-     *
-     */
-    public static class ClientDiscovery extends GridDiscoveryManagerAttributesSelfTest {
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String gridName) throws
Exception {
             IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-            if (Boolean.TRUE.equals(cfg.isClientMode()))
-                ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setClientMode(true);
+            ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);
 
             return cfg;
         }
     }
+
+    /**
+     *
+     */
+    public static class ClientDiscovery extends GridDiscoveryManagerAttributesSelfTest {
+        // No-op.
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
index 7a4baa8..65aec49 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
@@ -192,21 +192,20 @@ public abstract class GridDiscoveryManagerSelfTest extends GridCommonAbstractTes
      *
      */
     public static class RegularDiscovery extends GridDiscoveryManagerSelfTest {
-        // No-op.
-    }
-
-    /**
-     *
-     */
-    public static class ClientDiscovery extends GridDiscoveryManagerSelfTest {
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String gridName) throws
Exception {
             IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-            if (Boolean.TRUE.equals(cfg.isClientMode()))
-                ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setClientMode(true);
+            ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);
 
             return cfg;
         }
     }
+
+    /**
+     *
+     */
+    public static class ClientDiscovery extends GridDiscoveryManagerSelfTest {
+        // No-op.
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTcpClientDiscoveryMultiThreadedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTcpClientDiscoveryMultiThreadedTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTcpClientDiscoveryMultiThreadedTest.java
index e22bd57..b817f4c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTcpClientDiscoveryMultiThreadedTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTcpClientDiscoveryMultiThreadedTest.java
@@ -78,9 +78,7 @@ public class GridCacheTcpClientDiscoveryMultiThreadedTest extends GridCacheAbstr
 
             clientFinder.setAddresses(addrs);
 
-            cfg.setDiscoverySpi(new TcpDiscoverySpi()
-                .setClientMode(true)
-                .setIpFinder(clientFinder));
+            cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(clientFinder));
 
             cfg.setClientMode(true);
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
index 6aecdad..5a6be8e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
@@ -46,8 +46,8 @@ public abstract class IgniteClientDataStructuresAbstractTest extends GridCommonA
         if (gridName.equals(getTestGridName(NODE_CNT - 1))) {
             cfg.setClientMode(true);
 
-            if (clientDiscovery())
-                ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setClientMode(true);
+            if (!clientDiscovery())
+                ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);
         }
 
         ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
index a665601..f996568 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
@@ -23,6 +23,7 @@ import org.apache.ignite.cache.affinity.rendezvous.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.spi.discovery.tcp.*;
 
 import java.io.*;
 import java.util.concurrent.atomic.*;
@@ -66,6 +67,8 @@ public abstract class GridCacheClientModesAbstractSelfTest extends GridCacheAbst
             nearOnlyGridName = gridName;
         }
 
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);
+
         return cfg;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesTcpClientDiscoveryAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesTcpClientDiscoveryAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesTcpClientDiscoveryAbstractTest.java
index bd20ddc..bbc9144 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesTcpClientDiscoveryAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesTcpClientDiscoveryAbstractTest.java
@@ -37,11 +37,7 @@ public abstract class GridCacheClientModesTcpClientDiscoveryAbstractTest
extends
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        if (cfg.isClientMode() != null && cfg.isClientMode()) {
-            cfg.setDiscoverySpi(new TcpDiscoverySpi()
-                .setClientMode(true)
-                .setIpFinder(ipFinder));
-        }
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(false);
 
         return cfg;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
index e9620ea..016854a 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
@@ -37,21 +37,15 @@ public class TcpClientDiscoveryMarshallerCheckSelfTest extends GridCommonAbstrac
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg =  super.getConfiguration(gridName);
 
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
         if (gridName.endsWith("0"))
             cfg.setMarshaller(new JdkMarshaller());
         else {
-            discoSpi.setClientMode(true);
-
             cfg.setClientMode(true);
 
             cfg.setMarshaller(new OptimizedMarshaller());
         }
 
-        discoSpi.setIpFinder(ipFinder);
-
-        cfg.setDiscoverySpi(discoSpi);
+        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
 
         return cfg;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
index 0d08a0d..be3474d 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
@@ -103,26 +103,16 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest
{
     /** */
     private boolean longSockTimeouts;
 
-    /** */
-    private Boolean cfgClientMode;
-
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        TcpDiscoverySpi disco;
-
-        if (gridName.startsWith("server")) {
-            disco = new TcpDiscoverySpi();
+        TcpDiscoverySpi disco = new TestTcpDiscoverySpi();
 
+        if (gridName.startsWith("server"))
             disco.setIpFinder(IP_FINDER);
-        }
         else if (gridName.startsWith("client")) {
-            disco = new TestTcpDiscoverySpi();
-
-            disco.setClientMode(true);
-
-            cfg.setClientMode(cfgClientMode == null ? true : cfgClientMode);
+            cfg.setClientMode(true);
 
             TcpDiscoveryVmIpFinder ipFinder;
 
@@ -875,25 +865,6 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest
{
     }
 
     /**
-     *
-     */
-    public void testBrokenConfiguration() throws Exception {
-        startServerNodes(1);
-
-        cfgClientMode = false;
-
-        try {
-            startClientNodes(1);
-
-            fail("Configuration is boken, node cannot be started with DiscoverySpi.clientMode
= true and " +
-                "IgniteConfiguration.clientMode = false");
-        }
-        catch (Exception e) {
-            assertTrue(e.getMessage(), e.getMessage().contains("DiscoverySpi is in client
mode"));
-        }
-    }
-
-    /**
      * @param clientIdx Index.
      * @throws Exception In case of error.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java
index c64b5a8..6438268 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java
@@ -44,13 +44,7 @@ public class TcpDiscoveryConcurrentStartTest extends GridCommonAbstractTest
{
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg =  super.getConfiguration(gridName);
 
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-        discoSpi.setClientMode(client);
-
-        discoSpi.setIpFinder(ipFinder);
-
-        cfg.setDiscoverySpi(discoSpi);
+        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
 
         cfg.setCacheConfiguration();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
index 8c287b1..cfefff4 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
@@ -70,20 +70,10 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest
{
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        if (client()) {
+        if (client())
             cfg.setClientMode(true);
 
-            cfg.setDiscoverySpi(new TcpDiscoverySpi()
-                .setClientMode(true)
-                .setIpFinder(ipFinder));
-        }
-        else {
-            TcpDiscoverySpi spi = new TcpDiscoverySpi();
-
-            spi.setIpFinder(ipFinder);
-
-            cfg.setDiscoverySpi(spi);
-        }
+        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
 
         cfg.setCacheConfiguration();
 
@@ -91,8 +81,6 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest
{
 
         cfg.setIncludeProperties();
 
-        cfg.setLocalHost("127.0.0.1");
-
         return cfg;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e90c4b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java
index da9eed9..3e895be 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java
@@ -41,13 +41,5 @@ public class TcpDiscoverySpiConfigSelfTest extends GridSpiAbstractConfigTest<Tcp
         checkNegativeSpiProperty(new TcpDiscoverySpi(), "threadPriority", -1);
         checkNegativeSpiProperty(new TcpDiscoverySpi(), "maxMissedHeartbeats", 0);
         checkNegativeSpiProperty(new TcpDiscoverySpi(), "statisticsPrintFrequency", 0);
-
-        checkNegativeSpiProperty(new TcpDiscoverySpi().setClientMode(true), "ipFinder", null);
-        checkNegativeSpiProperty(new TcpDiscoverySpi().setClientMode(true), "networkTimeout",
0);
-        checkNegativeSpiProperty(new TcpDiscoverySpi().setClientMode(true), "socketTimeout",
0);
-        checkNegativeSpiProperty(new TcpDiscoverySpi().setClientMode(true), "ackTimeout",
0);
-        checkNegativeSpiProperty(new TcpDiscoverySpi().setClientMode(true), "heartbeatFrequency",
0);
-        checkNegativeSpiProperty(new TcpDiscoverySpi().setClientMode(true), "threadPriority",
-1);
-        checkNegativeSpiProperty(new TcpDiscoverySpi().setClientMode(true), "joinTimeout",
-1);
     }
 }


Mime
View raw message