diff --git a/hadoop/src/main/java/water/hadoop/h2odriver.java b/hadoop/src/main/java/water/hadoop/h2odriver.java index 81e443dc15..0164084772 100644 --- a/hadoop/src/main/java/water/hadoop/h2odriver.java +++ b/hadoop/src/main/java/water/hadoop/h2odriver.java @@ -768,6 +768,22 @@ private void waitForClusterToShutdown() throws Exception { } } + private String calcHadoopVersion() { + try { + Process p = new ProcessBuilder("hadoop", "version").start(); + p.waitFor(); + BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); + String line = br.readLine(); + if (line == null) { + line = "(unknown)"; + } + return line; + } + catch (Exception e) { + return "(unknown)"; + } + } + private int run2(String[] args) throws Exception { // Parse arguments. // ---------------- @@ -895,6 +911,11 @@ private int run2(String[] args) throws Exception { if (licenseData != null) { conf.set(h2omapper.H2O_LICENSE_DATA_KEY, licenseData); } + String hadoopVersion = calcHadoopVersion(); + conf.set(h2omapper.H2O_HADOOP_VERSION, hadoopVersion); + if((new File(".h2o_no_collect")).exists() || (new File(System.getProperty("user.home")+"/.h2o_no_collect")).exists()) { + conf.set(h2omapper.H2O_GA_OPTOUT, "-ga_optout"); + } // Set up job stuff. // ----------------- diff --git a/hadoop/src/main/java/water/hadoop/h2omapper.java b/hadoop/src/main/java/water/hadoop/h2omapper.java index cfa322ca20..320128bfc1 100644 --- a/hadoop/src/main/java/water/hadoop/h2omapper.java +++ b/hadoop/src/main/java/water/hadoop/h2omapper.java @@ -29,6 +29,8 @@ public class h2omapper extends Mapper { final static public String H2O_NTHREADS_KEY = "h2o.nthreads"; final static public String H2O_BASE_PORT_KEY = "h2o.baseport"; final static public String H2O_LICENSE_DATA_KEY = "h2o.license.data"; + final static public String H2O_HADOOP_VERSION = "h2o.hadoop.version"; + final static public String H2O_GA_OPTOUT = "h2o.ga.optout"; static EmbeddedH2OConfig _embeddedH2OConfig; @@ -363,6 +365,8 @@ private int run2(Context context) throws IOException, InterruptedException { String betaString = conf.get(H2O_BETA_KEY); String randomUdpDropString = conf.get(H2O_RANDOM_UDP_DROP_KEY); String licenseData = conf.get(H2O_LICENSE_DATA_KEY); + String hadoopVersion = conf.get(H2O_HADOOP_VERSION); + String gaOptOut = conf.get(H2O_GA_OPTOUT); ServerSocket ss = new ServerSocket(); InetSocketAddress sa = new InetSocketAddress("127.0.0.1", 0); @@ -427,6 +431,11 @@ private int run2(Context context) throws IOException, InterruptedException { argsList.add(fileName); } } + if (hadoopVersion != null) { + argsList.add("-ga_hdp_ver"); + argsList.add(hadoopVersion); + } + if (gaOptOut != null) argsList.add(gaOptOut); // Options passed through to UserMain for configuring the EmbeddedH2OConfig. argsList.add("-driverip"); diff --git a/src/main/java/water/H2O.java b/src/main/java/water/H2O.java index 8ebcb51351..0a8491f824 100644 --- a/src/main/java/water/H2O.java +++ b/src/main/java/water/H2O.java @@ -716,6 +716,8 @@ public static class OptArgs extends Arguments.Opt { public String beta = null; public String mem_watchdog = null; // For developer debugging public boolean md5skip = false; + public boolean ga_opt_out = false; + public String ga_hdp_ver = null; } public static void printHelp() { @@ -775,6 +777,9 @@ public static void printHelp() { " -license \n" + " Path to license file on local filesystem.\n" + "\n" + + " -ga_opt_out\n" + + " Opt out of sending anonymous usage metrics to Google Analytics.\n" + + "\n" + "Cloud formation behavior:\n" + "\n" + " New H2O nodes join together to form a cloud at startup time.\n" + @@ -889,8 +894,12 @@ public static void main( String[] args ) { START_TIME_MILLIS = System.currentTimeMillis(); GA = new GoogleAnalytics("UA-56665317-2","H2O",H2O.getVersion()); - if((new File(".h2o_no_collect")).exists() || (new File(System.getProperty("user.home")+"/.h2o_no_collect")).exists()) + if((new File(".h2o_no_collect")).exists() + || (new File(System.getProperty("user.home")+"/.h2o_no_collect")).exists() + || OPT_ARGS.ga_opt_out ) { GA.setEnabled(false); + Log.info("Opted out of sending usage metrics."); + } // Parse args Arguments arguments = new Arguments(args); @@ -1995,7 +2004,8 @@ public void run() { } private static void postStartupGAEvents() { - //TODO place an EventHit that records the HDFS version at startup + if (OPT_ARGS.ga_hdp_ver != null) + GA.postAsync(new EventHit("System startup info", "Hadoop version", OPT_ARGS.ga_hdp_ver, 1)); GA.postAsync(new EventHit("System startup info", "Cloud", "Cloud size", CLOUD.size())); } } diff --git a/src/main/java/water/ga/GoogleAnalytics.java b/src/main/java/water/ga/GoogleAnalytics.java index cef098e5b7..3ca6f083f2 100644 --- a/src/main/java/water/ga/GoogleAnalytics.java +++ b/src/main/java/water/ga/GoogleAnalytics.java @@ -154,7 +154,7 @@ public GoogleAnalyticsResponse post(GoogleAnalyticsRequest request) { //Process custom metrics processCustomMetricParameters(request, postParms); - Log.warn("GA Processed all parameters and sending the request " + postParms); + Log.debug("GA Processed all parameters and sending the request " + postParms); HttpPost httpPost = new HttpPost(config.getUrl()); try {