Просмотр исходного кода

HDFS-7202. Should be able to omit package name of SpanReceiver on "hadoop trace -add" (iwasakims via cmccabe)
(cherry picked from commit d996235285e5047f731e3d3fc4c6e6214caa10aa)

Colin Patrick Mccabe 10 лет назад
Родитель
Сommit
f1feaae1dd

+ 4 - 4
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<ConfigurationPair> extraConfig) throws IOException {
+    className = className.trim();
+    if (!className.contains(".")) {
+      className = "org.htrace.impl." + className;
+    }
     Class<?> implClass = null;
     SpanReceiver impl;
     try {

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -13,6 +13,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

+ 8 - 0
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();