From d996235285e5047f731e3d3fc4c6e6214caa10aa Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Wed, 8 Oct 2014 17:55:46 -0700 Subject: [PATCH] HDFS-7202. Should be able to omit package name of SpanReceiver on "hadoop trace -add" (iwasakims via cmccabe) --- .../java/org/apache/hadoop/tracing/SpanReceiverHost.java | 8 ++++---- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../java/org/apache/hadoop/tracing/TestTraceAdmin.java | 8 ++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/SpanReceiverHost.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/SpanReceiverHost.java index 82f099e4e11..13c92ac5b05 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/SpanReceiverHost.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/SpanReceiverHost.java @@ -137,10 +137,6 @@ public class SpanReceiverHost implements TraceAdminProtocol { getUniqueLocalTraceFileName()); } for (String className : receiverNames) { - className = className.trim(); - if (!className.contains(".")) { - className = "org.htrace.impl." + className; - } try { SpanReceiver rcvr = loadInstance(className, EMPTY); Trace.addReceiver(rcvr); @@ -154,6 +150,10 @@ public class SpanReceiverHost implements TraceAdminProtocol { private synchronized SpanReceiver loadInstance(String className, List extraConfig) throws IOException { + className = className.trim(); + if (!className.contains(".")) { + className = "org.htrace.impl." + className; + } Class implClass = null; SpanReceiver impl; try { diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 1ad59b2b14c..e2c278e9818 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -373,6 +373,9 @@ Release 2.7.0 - UNRELEASED HDFS-7186. Document the "hadoop trace" command. (Masatake Iwasaki via Colin P. McCabe) + HDFS-7202. Should be able to omit package name of SpanReceiver on "hadoop + trace -add" (iwasakims via cmccabe) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tracing/TestTraceAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tracing/TestTraceAdmin.java index 455e64fcb42..79a1f396330 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tracing/TestTraceAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tracing/TestTraceAdmin.java @@ -82,6 +82,14 @@ public class TestTraceAdmin { getHostPortForNN(cluster))); Assert.assertEquals("ret:0, [no span receivers found]\n", runTraceCommand(trace, "-list", "-host", getHostPortForNN(cluster))); + Assert.assertEquals("ret:0, Added trace span receiver 2 with " + + "configuration local-file-span-receiver.path = " + tracePath + "\n", + runTraceCommand(trace, "-add", "-host", getHostPortForNN(cluster), + "-class", "LocalFileSpanReceiver", + "-Clocal-file-span-receiver.path=" + tracePath)); + Assert.assertEquals("ret:0, Removed trace span receiver 2\n", + runTraceCommand(trace, "-remove", "2", "-host", + getHostPortForNN(cluster))); } finally { cluster.shutdown(); tempDir.close();