ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [49/50] incubator-ignite git commit: # ignite-648: add worked tests
Date Tue, 21 Apr 2015 11:01:52 GMT
# ignite-648: add worked tests


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

Branch: refs/heads/ignite-648
Commit: ae06c33f147e98d3f91755182d9630d2404d0158
Parents: dcb70b0
Author: Artem Shutak <ashutak@gridgain.com>
Authored: Tue Apr 21 13:22:15 2015 +0300
Committer: Artem Shutak <ashutak@gridgain.com>
Committed: Tue Apr 21 13:22:15 2015 +0300

----------------------------------------------------------------------
 ...CachePartitionedMultiJvmFullApiSelfTest.java | 99 +++++++++++++++++---
 .../cache/multijvm/IgniteExProxy.java           | 17 ++--
 .../cache/multijvm/IgniteNodeRunner.java        | 32 ++++++-
 3 files changed, 126 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ae06c33f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCachePartitionedMultiJvmFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCachePartitionedMultiJvmFullApiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCachePartitionedMultiJvmFullApiSelfTest.java
index fad9921..4f40122 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCachePartitionedMultiJvmFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCachePartitionedMultiJvmFullApiSelfTest.java
@@ -22,7 +22,8 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
 import org.apache.ignite.internal.processors.resource.*;
-import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.lang.*;
 
 import java.util.*;
 
@@ -66,11 +67,13 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit
 
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-        
-        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IgniteNodeRunner.ipFinder);
+//        IgniteConfiguration cfg = super.getConfiguration(gridName);
+//
+//        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IgniteNodeRunner.ipFinder);
+//
+//        return cfg;
         
-        return cfg;
+        return IgniteNodeRunner.theSameConf(gridName);
     }
 
     /** {@inheritDoc} */
@@ -90,11 +93,7 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit
 
     /** {@inheritDoc} */
     protected Ignite startGrid(String gridName, GridSpringResourceContext ctx) throws Exception
{
-        if (
-            gridName.endsWith("0")
-//            ||
-//            gridName.endsWith("1")
-            ) {
+        if (!isMultiJvm() || gridName.endsWith("0")) {
             locIgnite = super.startGrid(gridName, ctx);
 
             return locIgnite;
@@ -118,11 +117,7 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit
 
     /** {@inheritDoc} */
     @Override protected IgniteEx grid(int idx) {
-        if (
-            idx == 0
-//            ||
-//            idx == 1
-            )
+        if (!isMultiJvm() || idx == 0)
             return super.grid(idx);
 
         String name = getTestGridName(idx);
@@ -169,4 +164,78 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit
 //        for (IgniteExProxy ignite : ignites.values())
 //            ignite.getProcess().kill();
     }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testBroadcast() throws Exception {
+        IgniteEx grid0 = grid(0);
+        IgniteEx grid1 = grid(1);
+
+        Thread.sleep(10_000);
+
+//        ClusterGroup grp = grid0.cluster().forNode(grid1.localNode());
+
+        grid0.compute().broadcast(new IgniteRunnable() {
+            @Override public void run() {
+                System.out.println(">>>>> trololo");
+            }
+        });
+        
+        Thread.sleep(10_000);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSimpleBroadcast_worked() throws Exception {
+        Ignite rmt = null;
+
+        try(Ignite ignite = Ignition.start(IgniteNodeRunner.theSameConf("SomeLocGrid")))
{
+            Thread.sleep(5_000);
+
+            rmt = new IgniteExProxy(IgniteNodeRunner.theSameConf("remoteNode"), ignite.log(),
ignite);
+
+            Thread.sleep(5_000);
+
+            ignite.compute().broadcast(new IgniteRunnable() {
+                @Override public void run() {
+                    System.out.println(">>>>> trololo");
+                }
+            });
+
+            Collection<String> res = ignite.compute().broadcast(new C1<Integer,
String>() {
+                @Override public String apply(Integer integer) {
+                    return String.valueOf(integer + 12);
+                }
+            }, 100500);
+
+            System.out.println(">>>>> " + res);
+        }
+        finally {
+            rmt.close();
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRmt2RmtBroadcast_worked() throws Exception {
+        Ignite rmt1 = null;
+        Ignite rmt2 = null;
+
+        try {
+            rmt1 = new IgniteExProxy(IgniteNodeRunner.theSameConf("remoteNode1"), log, null);
+
+            Thread.sleep(5_000);
+
+            rmt2 = new IgniteExProxy(IgniteNodeRunner.theSameConf("remoteNode2"), log, null);
+
+            Thread.sleep(5_000);
+        }
+        finally {
+            rmt1.close();
+            rmt2.close();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ae06c33f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProxy.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProxy.java
index d642d9d..8a273b6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProxy.java
@@ -250,11 +250,11 @@ public class IgniteExProxy implements IgniteEx {
     @Override public <K, V> IgniteCache<K, V> cache(@Nullable final String name)
{
         ClusterGroup grp = locJvmGrid.cluster().forNodeId(id);
 
-//        locJvmGrid.compute().broadcast(new IgniteRunnable() {
-//            @Override public void run() {
-//                System.out.println(">>>>> trololo");
-//            }
-//        });
+        locJvmGrid.compute(grp).broadcast(new IgniteRunnable() {
+            @Override public void run() {
+                System.out.println(">>>>> trololo");
+            }
+        });
         
 //        locJvmGrid.compute(grp).run(new IgniteRunnable() {
 //            @Override public void run() {
@@ -328,7 +328,12 @@ public class IgniteExProxy implements IgniteEx {
     }
 
     @Override public void close() throws IgniteException {
-        // TODO: CODE: implement.
+        try {
+            getProcess().kill();
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     @Override public <K> Affinity<K> affinity(String cacheName) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ae06c33f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteNodeRunner.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteNodeRunner.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteNodeRunner.java
index 9976cd7..be200a6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteNodeRunner.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteNodeRunner.java
@@ -22,6 +22,7 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
 import org.apache.ignite.marshaller.optimized.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
@@ -51,6 +52,14 @@ public class IgniteNodeRunner {
             IgniteConfiguration cfg = configuration(args);
 
             Ignite ignite = Ignition.start(cfg);
+            
+            Thread.sleep(2_000);
+
+            ignite.compute().broadcast(new IgniteRunnable() {
+                @Override public void run() {
+                    System.out.println(">>>>> [rmt] trololo");
+                }
+            });
         }
         catch (Throwable e) {
             e.printStackTrace();
@@ -102,7 +111,8 @@ public class IgniteNodeRunner {
 
         cfg.setNodeId(nodeId);
 
-        return cfg;
+//        return cfg;
+        return theSameConf(gridName);
     }
 
     private static boolean isDebug() {
@@ -132,4 +142,24 @@ public class IgniteNodeRunner {
 //        }
         return new CacheConfiguration();
     }
+
+    public static IgniteConfiguration theSameConf(String gridName) {
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+        disco.setIpFinder(ipFinder);
+        cfg.setDiscoverySpi(disco);
+
+        cfg.setMarshaller(new OptimizedMarshaller(false));
+        
+        cfg.setCacheConfiguration(new CacheConfiguration());
+        
+        cfg.setGridName(gridName);
+
+        cfg.setLocalHost("127.0.0.1");
+
+        cfg.setIncludeProperties();
+
+        return cfg;
+    }
 }


Mime
View raw message