ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [01/11] incubator-ignite git commit: # IGNITE-709 Refactoring: extract GridCommonAbstractTest.createClientDiscovery() method.
Date Tue, 19 May 2015 19:39:53 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-23 72d6ea5d1 -> fcf02fef4


# IGNITE-709 Refactoring: extract GridCommonAbstractTest.createClientDiscovery() method.


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

Branch: refs/heads/ignite-23
Commit: 9bbc1fe921482654700137ea6153f2b4206ef9de
Parents: 5c8591c
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Mon May 18 14:17:13 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Mon May 18 14:17:13 2015 +0300

----------------------------------------------------------------------
 .../IgniteClientDataStructuresAbstractTest.java | 19 ++----------
 ...ientModesTcpClientDiscoveryAbstractTest.java | 21 ++-----------
 ...pClientDiscoveryMarshallerCheckSelfTest.java | 18 +-----------
 .../tcp/TcpDiscoveryConcurrentStartTest.java    | 20 ++-----------
 .../junits/common/GridCommonAbstractTest.java   | 31 ++++++++++++++++++++
 5 files changed, 38 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9bbc1fe9/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 8aef0a6..36f1910 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
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.cache.datastructures;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
@@ -28,7 +27,6 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
 
-import java.util.*;
 import java.util.concurrent.*;
 
 /**
@@ -50,21 +48,8 @@ public abstract class IgniteClientDataStructuresAbstractTest extends GridCommonA
         if (gridName.equals(getTestGridName(NODE_CNT - 1))) {
             cfg.setClientMode(true);
 
-            if (clientDiscovery()) {
-                TcpDiscoveryVmIpFinder clientFinder = new TcpDiscoveryVmIpFinder();
-
-                String firstSrvAddr = F.first(ipFinder.getRegisteredAddresses()).toString();
-
-                if (firstSrvAddr.startsWith("/"))
-                    firstSrvAddr = firstSrvAddr.substring(1);
-
-                clientFinder.setAddresses(Collections.singletonList(firstSrvAddr));
-
-                TcpClientDiscoverySpi discoverySpi = new TcpClientDiscoverySpi();
-                discoverySpi.setIpFinder(clientFinder);
-
-                cfg.setDiscoverySpi(discoverySpi);
-            }
+            if (clientDiscovery())
+                cfg.setDiscoverySpi(createClientDiscovery(ipFinder));
         }
 
         cfg.setLocalHost("127.0.0.1");

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9bbc1fe9/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 d24afed..127c150 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
@@ -19,11 +19,7 @@ package org.apache.ignite.internal.processors.cache.distributed;
 
 import org.apache.ignite.cache.*;
 import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-
-import java.util.*;
 
 import static org.apache.ignite.cache.CacheMode.*;
 
@@ -41,21 +37,8 @@ public abstract class GridCacheClientModesTcpClientDiscoveryAbstractTest
extends
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        if (cfg.isClientMode() != null && cfg.isClientMode()) {
-            TcpDiscoveryVmIpFinder clientFinder = new TcpDiscoveryVmIpFinder();
-
-            String firstSrvAddr = F.first(ipFinder.getRegisteredAddresses()).toString();
-
-            if (firstSrvAddr.startsWith("/"))
-                firstSrvAddr = firstSrvAddr.substring(1);
-
-            clientFinder.setAddresses(Collections.singletonList(firstSrvAddr));
-
-            TcpClientDiscoverySpi discoverySpi = new TcpClientDiscoverySpi();
-            discoverySpi.setIpFinder(clientFinder);
-
-            cfg.setDiscoverySpi(discoverySpi);
-        }
+        if (cfg.isClientMode() != null && cfg.isClientMode())
+            cfg.setDiscoverySpi(createClientDiscovery(ipFinder));
 
         cfg.setLocalHost("127.0.0.1");
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9bbc1fe9/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 fa63e3c..78435fd 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
@@ -19,7 +19,6 @@ package org.apache.ignite.spi.discovery.tcp;
 
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.marshaller.jdk.*;
 import org.apache.ignite.marshaller.optimized.*;
 import org.apache.ignite.spi.*;
@@ -27,8 +26,6 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.junits.common.*;
 
-import java.util.*;
-
 /**
  * Test for {@link org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi}.
  */
@@ -52,20 +49,7 @@ public class TcpClientDiscoveryMarshallerCheckSelfTest extends GridCommonAbstrac
             cfg.setMarshaller(new JdkMarshaller());
         }
         else {
-            TcpClientDiscoverySpi disco = new TcpClientDiscoverySpi();
-
-            TcpDiscoveryVmIpFinder clientIpFinder = new TcpDiscoveryVmIpFinder();
-
-            String addr = F.first(ipFinder.getRegisteredAddresses()).toString();
-
-            if (addr.startsWith("/"))
-                addr = addr.substring(1);
-
-            clientIpFinder.setAddresses(Collections.singleton(addr));
-
-            disco.setIpFinder(clientIpFinder);
-
-            cfg.setDiscoverySpi(disco);
+            cfg.setDiscoverySpi(createClientDiscovery(ipFinder));
 
             cfg.setMarshaller(new OptimizedMarshaller());
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9bbc1fe9/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 b5d02f0..f79c24b 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
@@ -22,8 +22,6 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.junits.common.*;
 
-import java.util.*;
-
 /**
  * Test for {@link TcpDiscoverySpi}.
  */
@@ -41,22 +39,8 @@ public class TcpDiscoveryConcurrentStartTest extends GridCommonAbstractTest
{
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg =  super.getConfiguration(gridName);
 
-        if (client) {
-            TcpDiscoveryVmIpFinder clientIpFinder = new TcpDiscoveryVmIpFinder();
-
-            String addr = new ArrayList<>(ipFinder.getRegisteredAddresses()).iterator().next().toString();
-
-            if (addr.startsWith("/"))
-                addr = addr.substring(1);
-
-            clientIpFinder.setAddresses(Arrays.asList(addr));
-
-            TcpClientDiscoverySpi discoSpi = new TcpClientDiscoverySpi();
-
-            discoSpi.setIpFinder(clientIpFinder);
-
-            cfg.setDiscoverySpi(discoSpi);
-        }
+        if (client)
+            cfg.setDiscoverySpi(createClientDiscovery(ipFinder));
         else {
             TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9bbc1fe9/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 3c54efe..c8a256f 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -34,12 +34,16 @@ import org.apache.ignite.internal.processors.cache.local.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.junits.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
 import javax.cache.integration.*;
 import javax.net.ssl.*;
+import java.net.*;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
@@ -849,6 +853,33 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest
{
     }
 
     /**
+     * Create TcpClientDiscoverySpi configured to connect to last started server.
+     *
+     * @param srvIpFinder IpFinder that was provided to servers. Used to obtain addreses
to connect.
+     */
+    protected static TcpClientDiscoverySpi createClientDiscovery(TcpDiscoveryIpFinder srvIpFinder)
{
+        TcpDiscoveryVmIpFinder clientFinder = new TcpDiscoveryVmIpFinder();
+
+        Collection<InetSocketAddress> srvAddrs = srvIpFinder.getRegisteredAddresses();
+
+        if (srvAddrs.isEmpty())
+            throw new IgniteException("Failed to create client IpFinder, no server addresses
registered.");
+
+        String firstSrvAddr = F.first(srvAddrs).toString();
+
+        if (firstSrvAddr.startsWith("/"))
+            firstSrvAddr = firstSrvAddr.substring(1);
+
+        clientFinder.setAddresses(Collections.singletonList(firstSrvAddr));
+
+        TcpClientDiscoverySpi res = new TcpClientDiscoverySpi();
+
+        res.setIpFinder(clientFinder);
+
+        return res;
+    }
+
+    /**
      * In ATOMIC cache with CLOCK mode if key is updated from different nodes at same time
      * only one update wins others are ignored (can happen in test event when updates are
executed from
      * different nodes sequentially), this delay is used to avoid lost updates.


Mime
View raw message