hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jia...@apache.org
Subject [24/47] hadoop git commit: HADOOP-12183. Annotate the HTrace span created by FsShell with the command-line arguments passed by the user (Masatake Iwasaki via Colin P. McCabe)
Date Wed, 05 Aug 2015 22:23:37 GMT
HADOOP-12183. Annotate the HTrace span created by FsShell with the command-line arguments passed
by the user (Masatake Iwasaki via Colin P.  McCabe)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/454da959
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/454da959
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/454da959

Branch: refs/heads/YARN-1197
Commit: 454da959c726528ac98dbca1b935a83ed4b9e235
Parents: 21d10cc
Author: Colin Patrick Mccabe <cmccabe@cloudera.com>
Authored: Fri Jul 31 14:59:42 2015 -0700
Committer: Colin Patrick Mccabe <cmccabe@cloudera.com>
Committed: Fri Jul 31 15:14:18 2015 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt              | 4 ++++
 .../src/main/java/org/apache/hadoop/fs/FsShell.java          | 8 ++++++++
 .../src/test/java/org/apache/hadoop/fs/TestFsShell.java      | 6 +++++-
 3 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/454da959/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 675902d..1412fb8 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -739,6 +739,10 @@ Release 2.8.0 - UNRELEASED
 
     HADOOP-11807. add a lint mode to releasedocmaker (ramtin via aw)
 
+    HADOOP-12183. Annotate the HTrace span created by FsShell with the
+    command-line arguments passed by the user (Masatake Iwasaki via Colin P.
+    McCabe)
+
   OPTIMIZATIONS
 
     HADOOP-11785. Reduce the number of listStatus operation in distcp

http://git-wip-us.apache.org/repos/asf/hadoop/blob/454da959/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
index e9c2f73..a0510be 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.fs.shell.FsCommand;
 import org.apache.hadoop.tracing.SpanReceiverHost;
 import org.apache.hadoop.tools.TableListing;
 import org.apache.hadoop.tracing.TraceUtils;
+import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.Tool;
 import org.apache.hadoop.util.ToolRunner;
 import org.apache.htrace.Sampler;
@@ -298,6 +299,13 @@ public class FsShell extends Configured implements Tool {
           throw new UnknownCommandException();
         }
         TraceScope scope = Trace.startSpan(instance.getCommandName(), traceSampler);
+        if (scope.getSpan() != null) {
+          String args = StringUtils.join(" ", argv);
+          if (args.length() > 2048) {
+            args = args.substring(0, 2048);
+          }
+          scope.getSpan().addKVAnnotation("args", args);
+        }
         try {
           exitCode = instance.run(Arrays.copyOfRange(argv, 1, argv.length));
         } finally {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/454da959/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
index 38e768f..59fcbe5 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
@@ -24,6 +24,7 @@ import org.apache.hadoop.tracing.SpanReceiverHost;
 import org.apache.hadoop.util.ToolRunner;
 import org.apache.htrace.SamplerBuilder;
 import org.apache.htrace.impl.AlwaysSampler;
+import org.junit.Assert;
 import org.junit.Test;
 
 public class TestFsShell {
@@ -57,10 +58,13 @@ public class TestFsShell {
     FsShell shell = new FsShell(conf);
     int res;
     try {
-      res = ToolRunner.run(shell, new String[]{"-help"});
+      res = ToolRunner.run(shell, new String[]{"-help", "ls", "cat"});
     } finally {
       shell.close();
     }
     SetSpanReceiver.assertSpanNamesFound(new String[]{"help"});
+    Assert.assertEquals("-help ls cat",
+        SetSpanReceiver.getMap()
+            .get("help").get(0).getKVAnnotations().get("args"));
   }
 }


Mime
View raw message