incubator-giraph-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r1302081 - in /incubator/giraph/trunk: CHANGELOG src/main/java/org/apache/giraph/GiraphRunner.java
Date Sun, 18 Mar 2012 07:31:45 GMT
Author: ssc
Date: Sun Mar 18 07:31:45 2012
New Revision: 1302081

URL: http://svn.apache.org/viewvc?rev=1302081&view=rev
Log:
GIRAPH-156 Users should be able to set simple 'custom arguments' via org.apache.giraph.GiraphRunner

Modified:
    incubator/giraph/trunk/CHANGELOG
    incubator/giraph/trunk/src/main/java/org/apache/giraph/GiraphRunner.java

Modified: incubator/giraph/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/CHANGELOG?rev=1302081&r1=1302080&r2=1302081&view=diff
==============================================================================
--- incubator/giraph/trunk/CHANGELOG (original)
+++ incubator/giraph/trunk/CHANGELOG Sun Mar 18 07:31:45 2012
@@ -2,6 +2,9 @@ Giraph Change Log
 
 Release 0.2.0 - unreleased
 
+  GIRAPH-156: Users should be able to set simple 'custom arguments'
+  via org.apache.giraph.GiraphRunner (ssc)
+
   GIRAPH-154: Worker ports are not synched properly with its peers
   (Zhiwei Gu via aching).
 

Modified: incubator/giraph/trunk/src/main/java/org/apache/giraph/GiraphRunner.java
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/src/main/java/org/apache/giraph/GiraphRunner.java?rev=1302081&r1=1302080&r2=1302081&view=diff
==============================================================================
--- incubator/giraph/trunk/src/main/java/org/apache/giraph/GiraphRunner.java (original)
+++ incubator/giraph/trunk/src/main/java/org/apache/giraph/GiraphRunner.java Sun Mar 18 07:31:45
2012
@@ -17,6 +17,8 @@
  */
 package org.apache.giraph;
 
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
 import org.apache.commons.cli.BasicParser;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
@@ -69,6 +71,9 @@ public class GiraphRunner implements Too
     options.addOption("c", "combiner", true, "VertexCombiner class");
     options.addOption("wc", "workerContext", true, "WorkerContext class");
     options.addOption("aw", "aggregatorWriter", true, "AggregatorWriter class");
+    options.addOption("ca", "customArguments", true, "provide custom" +
+        " arguments for the job configuration in the form:" +
+        " <param1>=<value1>,<param2>=<value2> etc.");
     return options;
   }
 
@@ -102,7 +107,9 @@ public class GiraphRunner implements Too
     // Verify all the options have been provided
     for (String[] requiredOption : requiredOptions) {
       if (!cmd.hasOption(requiredOption[0])) {
-        LOG.info(requiredOption[1]);
+        if (LOG.isInfoEnabled()) {
+          LOG.info(requiredOption[1]);
+        }
         return -1;
       }
     }
@@ -116,15 +123,19 @@ public class GiraphRunner implements Too
     if (cmd.hasOption("ip")) {
       FileInputFormat.addInputPath(job, new Path(cmd.getOptionValue("ip")));
     } else {
-      LOG.info("No input path specified. Ensure your InputFormat does not " +
-          "require one.");
+      if (LOG.isInfoEnabled()) {
+        LOG.info("No input path specified. Ensure your InputFormat does" +
+            " not require one.");
+      }
     }
 
     if (cmd.hasOption("op")) {
       FileOutputFormat.setOutputPath(job, new Path(cmd.getOptionValue("op")));
     } else {
-      LOG.info("No output path specified. Ensure your OutputFormat does not " +
-          "require one.");
+      if (LOG.isInfoEnabled()) {
+        LOG.info("No output path specified. Ensure your OutputFormat does" +
+            " not require one.");
+      }
     }
 
     if (cmd.hasOption("c")) {
@@ -139,6 +150,20 @@ public class GiraphRunner implements Too
       job.setAggregatorWriterClass(Class.forName(cmd.getOptionValue("aw")));
     }
 
+    if (cmd.hasOption("ca")) {
+      Configuration conf = job.getConfiguration();
+      for (String paramValue : Splitter.on(',').split(cmd.getOptionValue("ca"))) {
+        String[] parts = Iterables.toArray(Splitter.on('=').split(paramValue), String.class);
+        if (parts.length != 2) {
+          throw new IllegalArgumentException("Unable to parse custom argument: " + paramValue);
+        }
+        if (LOG.isInfoEnabled()) {
+          LOG.info("Setting custom argument [" + parts[0] + "] to [" + parts[1] + "]");
+        }
+        conf.set(parts[0], parts[1]);
+      }
+    }
+
     job.setWorkerConfiguration(workers, workers, 100.0f);
 
     boolean isQuiet = !cmd.hasOption('q');



Mime
View raw message