You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/05/13 15:20:57 UTC

incubator-ignite git commit: ignite-648: cfgs in different files

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-648 cf26ffb78 -> aac6b03b6


ignite-648: cfgs in different files


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

Branch: refs/heads/ignite-648
Commit: aac6b03b67877b8bdec9f5c14e13923db58d055f
Parents: cf26ffb
Author: Artem Shutak <as...@gridgain.com>
Authored: Wed May 13 16:21:23 2015 +0300
Committer: Artem Shutak <as...@gridgain.com>
Committed: Wed May 13 16:21:23 2015 +0300

----------------------------------------------------------------------
 .../framework/IgniteExProcessProxy.java         |  4 +--
 .../multijvm/framework/IgniteNodeRunner.java    | 33 +++++++++-----------
 2 files changed, 17 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aac6b03b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/framework/IgniteExProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/framework/IgniteExProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/framework/IgniteExProcessProxy.java
index 034d32c..d6fef47 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/framework/IgniteExProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/framework/IgniteExProcessProxy.java
@@ -72,7 +72,7 @@ public class IgniteExProcessProxy implements IgniteEx {
         this.locJvmGrid = locJvmGrid;
         this.log = log.getLogger("jvm-" + id.toString().substring(0, id.toString().indexOf('-')));
 
-        IgniteNodeRunner.storeToFile(cfg.setNodeId(id));
+        String cfgFileName = IgniteNodeRunner.storeToFile(cfg.setNodeId(id));
 
         List<String> jvmArgs = U.jvmArgs();
 
@@ -85,7 +85,7 @@ public class IgniteExProcessProxy implements IgniteEx {
 
         proc = GridJavaProcess.exec(
             IgniteNodeRunner.class,
-            IgniteNodeRunner.asParams(id, cfg), // Params.
+            cfgFileName, // Params.
             this.log,
             // Optional closure to be called each time wrapped process prints line to system.out or system.err.
             new IgniteInClosure<String>() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aac6b03b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/framework/IgniteNodeRunner.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/framework/IgniteNodeRunner.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/framework/IgniteNodeRunner.java
index d927fc0..480b803 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/framework/IgniteNodeRunner.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/framework/IgniteNodeRunner.java
@@ -36,7 +36,7 @@ import java.util.*;
 public class IgniteNodeRunner {
     /** */
     private static final String IGNITE_CONFIGURATION_FILE = System.getProperty("java.io.tmpdir") +
-        File.separator + "igniteConfiguration.tmp";
+        File.separator + "igniteConfiguration.tmp_";
 
     /**
      * Starts {@link Ignite} instance accorging to given arguments.
@@ -50,7 +50,7 @@ public class IgniteNodeRunner {
 
             X.println("Starting Ignite Node... Args" + Arrays.toString(args));
 
-            IgniteConfiguration cfg = readFromFile();
+            IgniteConfiguration cfg = readCfgFromFileAndDeleteFile(args[0]);
 
             Ignition.start(cfg);
         }
@@ -61,37 +61,34 @@ public class IgniteNodeRunner {
         }
     }
 
-    /**
-     * @param id Grid id.
-     * @param cfg Configuration.
-     * @return Given paramethers as command line string arguments.
-     */
-    public static String asParams(UUID id, IgniteConfiguration cfg) {
-        return id.toString() + ' ' + cfg.getGridName();
-    }
+    public static String storeToFile(IgniteConfiguration cfg) throws IOException {
+        String fileName = IGNITE_CONFIGURATION_FILE + cfg.getNodeId();
 
-    public static void storeToFile(IgniteConfiguration cfg) throws IOException {
-        try(OutputStream out = new BufferedOutputStream(new FileOutputStream(IGNITE_CONFIGURATION_FILE))) {
+        try(OutputStream out = new BufferedOutputStream(new FileOutputStream(fileName))) {
             cfg.setMBeanServer(null);
             cfg.setMarshaller(null);
             cfg.setDiscoverySpi(null);
 
             new XStream().toXML(cfg, out);
         }
+
+        return fileName;
     }
 
-    private static IgniteConfiguration readFromFile() throws FileNotFoundException {
-        BufferedReader cfgReader = new BufferedReader(new FileReader(IGNITE_CONFIGURATION_FILE));
-        
+    private static IgniteConfiguration readCfgFromFileAndDeleteFile(String fileName) throws FileNotFoundException {
+        BufferedReader cfgReader = new BufferedReader(new FileReader(fileName));
+
         IgniteConfiguration cfg = (IgniteConfiguration)new XStream().fromXML(cfgReader);
-        
+
         cfg.setMarshaller(new OptimizedMarshaller(false));
 
         TcpDiscoverySpi disco = new TcpDiscoverySpi();
         disco.setIpFinder(new TcpDiscoveryMulticastIpFinder());
-        
+
         cfg.setDiscoverySpi(disco);
-        
+
+        new File(fileName).delete();
+
         return cfg;
     }
 }