Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 73584185B8 for ; Thu, 30 Jul 2015 01:27:32 +0000 (UTC) Received: (qmail 24958 invoked by uid 500); 30 Jul 2015 01:27:32 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 24890 invoked by uid 500); 30 Jul 2015 01:27:32 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 24873 invoked by uid 99); 30 Jul 2015 01:27:32 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jul 2015 01:27:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E6FBCE03FA; Thu, 30 Jul 2015 01:27:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aw@apache.org To: common-commits@hadoop.apache.org Date: Thu, 30 Jul 2015 01:27:31 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [01/14] hadoop git commit: HADOOP-12175. FsShell must load SpanReceierHost to support tracing (Masatake Iwasaki via Colin P. McCabe) Repository: hadoop Updated Branches: refs/heads/HADOOP-12111 03335bb4d -> 42d0c0fac HADOOP-12175. FsShell must load SpanReceierHost to support tracing (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/69b09573 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/69b09573 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/69b09573 Branch: refs/heads/HADOOP-12111 Commit: 69b095730bd87706ddcbabeea6c513290ee4cdf5 Parents: f170934 Author: Colin Patrick Mccabe Authored: Tue Jul 28 12:49:38 2015 -0700 Committer: Colin Patrick Mccabe Committed: Tue Jul 28 12:56:15 2015 -0700 ---------------------------------------------------------------------- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../main/java/org/apache/hadoop/fs/FsShell.java | 11 ++++++++- .../java/org/apache/hadoop/fs/TestFsShell.java | 24 ++++++++++++++++++++ .../apache/hadoop/tracing/SetSpanReceiver.java | 2 +- 4 files changed, 38 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b09573/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 aeaa5b9..84e7076 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -1020,6 +1020,9 @@ Release 2.8.0 - UNRELEASED HADOOP-12245. References to misspelled REMAINING_QUATA in FileSystemShell.md. (Gabor Liptak via aajisaka) + HADOOP-12175. FsShell must load SpanReceierHost to support tracing + (Masatake Iwasaki via Colin P. McCabe) + Release 2.7.2 - UNRELEASED INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b09573/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 24b6339..e9c2f73 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 @@ -32,6 +32,7 @@ import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.shell.Command; import org.apache.hadoop.fs.shell.CommandFactory; 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.Tool; @@ -57,6 +58,9 @@ public class FsShell extends Configured implements Tool { private final String usagePrefix = "Usage: hadoop fs [generic options]"; + private SpanReceiverHost spanReceiverHost; + static final String SEHLL_HTRACE_PREFIX = "dfs.shell.htrace."; + /** * Default ctor with no configuration. Be sure to invoke * {@link #setConf(Configuration)} with a valid configuration prior @@ -97,6 +101,8 @@ public class FsShell extends Configured implements Tool { commandFactory.addObject(new Usage(), "-usage"); registerCommands(commandFactory); } + this.spanReceiverHost = + SpanReceiverHost.get(getConf(), SEHLL_HTRACE_PREFIX); } protected void registerCommands(CommandFactory factory) { @@ -279,7 +285,7 @@ public class FsShell extends Configured implements Tool { // initialize FsShell init(); traceSampler = new SamplerBuilder(TraceUtils. - wrapHadoopConf("dfs.shell.htrace.", getConf())).build(); + wrapHadoopConf(SEHLL_HTRACE_PREFIX, getConf())).build(); int exitCode = -1; if (argv.length < 1) { printUsage(System.err); @@ -335,6 +341,9 @@ public class FsShell extends Configured implements Tool { fs.close(); fs = null; } + if (this.spanReceiverHost != null) { + this.spanReceiverHost.closeReceivers(); + } } /** http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b09573/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 12c8bcf..38e768f 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 @@ -18,6 +18,12 @@ package org.apache.hadoop.fs; import junit.framework.AssertionFailedError; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.tracing.SetSpanReceiver; +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.Test; public class TestFsShell { @@ -39,4 +45,22 @@ public class TestFsShell { } } + @Test + public void testTracing() throws Throwable { + Configuration conf = new Configuration(); + String prefix = FsShell.SEHLL_HTRACE_PREFIX; + conf.set(prefix + SpanReceiverHost.SPAN_RECEIVERS_CONF_SUFFIX, + SetSpanReceiver.class.getName()); + conf.set(prefix + SamplerBuilder.SAMPLER_CONF_KEY, + AlwaysSampler.class.getName()); + conf.setQuietMode(false); + FsShell shell = new FsShell(conf); + int res; + try { + res = ToolRunner.run(shell, new String[]{"-help"}); + } finally { + shell.close(); + } + SetSpanReceiver.assertSpanNamesFound(new String[]{"help"}); + } } http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b09573/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/tracing/SetSpanReceiver.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/tracing/SetSpanReceiver.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/tracing/SetSpanReceiver.java index e242b74..97ca7c4 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/tracing/SetSpanReceiver.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/tracing/SetSpanReceiver.java @@ -86,7 +86,7 @@ public class SetSpanReceiver implements SpanReceiver { } } - static void assertSpanNamesFound(final String[] expectedSpanNames) { + public static void assertSpanNamesFound(final String[] expectedSpanNames) { try { GenericTestUtils.waitFor(new Supplier() { @Override