ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [2/2] incubator-ignite git commit: ignite-648: read fake of cache from file
Date Tue, 14 Apr 2015 18:54:48 GMT
ignite-648: read fake of cache from file


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

Branch: refs/heads/ignite-648
Commit: fbcb8275dc38c5be29ef81fdd80c452079e8ff72
Parents: 68bd6d6
Author: Artem Shutak <ashutak@gridgain.com>
Authored: Tue Apr 14 21:54:42 2015 +0300
Committer: Artem Shutak <ashutak@gridgain.com>
Committed: Tue Apr 14 21:54:42 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCacheAbstractFullApiSelfTest.java | 28 +++++-----
 ...CachePartitionedMultiJvmFullApiSelfTest.java | 51 +++++++++++-------
 .../cache/multijvm/IgniteExProxy.java           | 19 +++++--
 .../cache/multijvm/IgniteNodeRunner.java        | 55 +++++++++-----------
 4 files changed, 85 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fbcb8275/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 0adf4c0..472fb8a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -216,27 +216,27 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
 
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
-        IgniteCache<String, Integer> cache = jcache();
-
-        assertEquals(0, cache.localSize());
-        assertEquals(0, cache.size());
-
-        super.beforeTest();
-
-        assertEquals(0, cache.localSize());
-        assertEquals(0, cache.size());
+//        IgniteCache<String, Integer> cache = jcache();
+//
+//        assertEquals(0, cache.localSize());
+//        assertEquals(0, cache.size());
+//
+//        super.beforeTest();
+//
+//        assertEquals(0, cache.localSize());
+//        assertEquals(0, cache.size());
 
         dfltIgnite = grid(0);
     }
 
     /** {@inheritDoc} */
     @Override protected void afterTest() throws Exception {
-        super.afterTest();
-
-        IgniteCache<String, Integer> cache = jcache();
+//        super.afterTest();
 
-        assertEquals(0, cache.localSize());
-        assertEquals(0, cache.size());
+//        IgniteCache<String, Integer> cache = jcache();
+//
+//        assertEquals(0, cache.localSize());
+//        assertEquals(0, cache.size());
 
         dfltIgnite = null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fbcb8275/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 3f3c6ba..2f30e6b 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
@@ -52,13 +52,20 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit
         super.afterTestsStopped();
     }
 
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest(); // TODO: CODE: implement.
+    }
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
-        IgniteConfiguration rmtCfg = IgniteNodeRunner.configuration(null);
+        IgniteConfiguration cfg = IgniteNodeRunner.configuration(null);
         
-        rmtCfg.setGridName(gridName);
+        cfg.setGridName(gridName);
+
+//        cfg.setCacheConfiguration(super.getConfiguration(gridName).getCacheConfiguration());
+        cfg.setCacheConfiguration(new CacheConfiguration());
 
-        return rmtCfg; // TODO: change.
+        return cfg; // TODO: change.
     }
 
     /** {@inheritDoc} */
@@ -89,7 +96,7 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit
         try {
             IgniteConfiguration cfg = optimize(getConfiguration(gridName));
 
-            IgniteExProxy proxy = new IgniteExProxy(cfg, locIgnite);
+            IgniteExProxy proxy = new IgniteExProxy(cfg, log, locIgnite);
 
             ignites.put(gridName, proxy);
 
@@ -127,23 +134,27 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit
         for (int i = 0; i < size; i++)
             putMap.put(i, i * i);
 
-        IgniteEx grid0 = grid(0);
-        
-        IgniteCache<Object, Object> c0 = grid0.cache(null);
-        
-        IgniteEx grid1 = grid(1);
+//        IgniteEx grid0 = grid(0);
+//kill -9 16067
+//        IgniteCache<Object, Object> c0 = grid0.cache(null);
+//
+//        IgniteEx grid1 = grid(1);
+//
+//        IgniteCache<Object, Object> c1 = grid1.cache(null);
+//
+//        c0.putAll(putMap);
+//
+//        atomicClockModeDelay(c0);
+//
+//        c1.removeAll(putMap.keySet());
+//
+//        for (int i = 0; i < size; i++) {
+//            assertNull(c0.get(i));
+//            assertNull(c1.get(i));
+//        }
         
-        IgniteCache<Object, Object> c1 = grid1.cache(null);
-
-        c0.putAll(putMap);
-
-        atomicClockModeDelay(c0);
-
-        c1.removeAll(putMap.keySet());
+        for (IgniteExProxy ignite : ignites.values())
+            ignite.getProcess().kill();
 
-        for (int i = 0; i < size; i++) {
-            assertNull(c0.get(i));
-            assertNull(c1.get(i));
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fbcb8275/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 6f01052..02381c3 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
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.hadoop.*;
 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.plugin.*;
 import org.jetbrains.annotations.*;
@@ -49,12 +50,22 @@ public class IgniteExProxy implements IgniteEx {
     private final IgniteLogger log;
     private final UUID id = UUID.randomUUID();
 
-    public IgniteExProxy(final IgniteConfiguration cfg, final Ignite locJvmGrid) throws Exception
{
+    public IgniteExProxy(final IgniteConfiguration cfg, final IgniteLogger log, final Ignite
locJvmGrid) throws Exception {
         this.cfg = cfg;
         this.locJvmGrid = locJvmGrid;
-        this.log = locJvmGrid.log();
+        this.log = log;
 
         String cfgAsString = IgniteNodeRunner.asParams(id, cfg);
+        IgniteNodeRunner.storeToFile(cfg.getCacheConfiguration()[0]);
+
+        List<String> jvmArgs = U.jvmArgs();
+        
+        List<String> filteredJvmArgs = new ArrayList<>();
+
+        for (String arg : jvmArgs) {
+            if(!arg.toLowerCase().startsWith("-agentlib"))
+                filteredJvmArgs.add(arg);
+        }
         
         proc = GridJavaProcess.exec(
             IgniteNodeRunner.class,
@@ -67,7 +78,7 @@ public class IgniteExProxy implements IgniteEx {
                 }
             },
             null,
-            Collections.<String>emptyList(), // JVM Args.
+            filteredJvmArgs, // JVM Args.
             System.getProperty("surefire.test.class.path")
         );
         
@@ -242,7 +253,7 @@ public class IgniteExProxy implements IgniteEx {
         return locJvmGrid.compute(grp).apply(new C1<Set<String>, IgniteCache<K,V>>()
{
             @Override public IgniteCache<K,V> apply(Set<String> objects) {
                 X.println(">>>>> Cache");
-                
+
                 return Ignition.ignite().cache(name);
             }
         }, Collections.<String>emptySet());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fbcb8275/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 5a75222..0914d70 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
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.processors.cache.multijvm;
 
 import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.*;
@@ -28,12 +27,9 @@ import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.*;
 
+import java.io.*;
 import java.util.*;
 
-import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*;
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
-
 /**
  * Run ignite node. 
  */
@@ -44,6 +40,8 @@ public class IgniteNodeRunner {
     }};
 
     public static final char DELIM = ' ';
+    
+    public static final String CACHE_CONFIGURATION_TMP_FILE = "/tmp/cacheConfiguration.tmp";
 
     public static void main(String[] args) throws Exception {
         try {
@@ -53,7 +51,7 @@ public class IgniteNodeRunner {
 
             IgniteConfiguration cfg = configuration(args);
 
-//            cfg.setCacheConfiguration(cacheConfiguration());
+            cfg.setCacheConfiguration(cacheConfiguration());
 
             Ignite ignite = Ignition.start(cfg);
         }
@@ -68,7 +66,7 @@ public class IgniteNodeRunner {
         return id.toString() + DELIM + cfg.getGridName();
     }
 
-    public static IgniteConfiguration configuration(String[] args) {
+    public static IgniteConfiguration configuration(String[] args) throws Exception {
         IgniteConfiguration cfg = new IgniteConfiguration();
 
         cfg.setLocalHost("127.0.0.1");
@@ -86,29 +84,26 @@ public class IgniteNodeRunner {
         return cfg;
     }
 
-    // TODO implement.
-    private static CacheConfiguration cacheConfiguration() {
-        CacheConfiguration cfg = new CacheConfiguration();
-
-        cfg.setStartSize(1024);
-        cfg.setAtomicWriteOrderMode(PRIMARY);
-        cfg.setAtomicityMode(TRANSACTIONAL);
-        cfg.setNearConfiguration(new NearCacheConfiguration());
-        cfg.setWriteSynchronizationMode(FULL_SYNC);
-        cfg.setEvictionPolicy(null);
-
-//        if (offHeapValues()) {
-//            ccfg.setMemoryMode(CacheMemoryMode.OFFHEAP_VALUES);
-//            ccfg.setOffHeapMaxMemory(0);
-//        }
-
-        cfg.setEvictSynchronized(false);
-
-//        cfg.setAtomicityMode(atomicityMode());
-        cfg.setSwapEnabled(true);
-
-        cfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+    public static void storeToFile(CacheConfiguration cc) throws IOException {
+        // TODO use actual config.
+        cc = new CacheConfiguration();
+        
+        File ccfgTmpFile = new File(CACHE_CONFIGURATION_TMP_FILE);
+
+        ccfgTmpFile.createNewFile();
+//        if (!ccfgTmpFile.createNewFile())
+//            throw new IgniteSpiException("File was not created.");
+        
+        try(ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(ccfgTmpFile)))
{
+            out.writeObject(cc);
+        }
+    }
 
-        return cfg;
+    public static CacheConfiguration cacheConfiguration() throws Exception {
+        File ccfgTmpFile = new File(CACHE_CONFIGURATION_TMP_FILE);
+        
+        try(ObjectInputStream in = new ObjectInputStream(new FileInputStream(ccfgTmpFile)))
{
+            return (CacheConfiguration)in.readObject();
+        }
     }
 }


Mime
View raw message