Parcourir la source

HDFS-15523. Fix findbugs warnings from HDFS-15520. (#2218)

Tsz-Wo Nicholas Sze il y a 4 ans
Parent
commit
11cec9ab94

+ 1 - 24
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/visitor/NamespacePrintVisitor.java

@@ -32,10 +32,6 @@ import org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeat
 import org.apache.hadoop.hdfs.server.namenode.snapshot.FileWithSnapshotFeature;
 import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot;
 
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 
@@ -50,17 +46,10 @@ import java.io.StringWriter;
  *            \- file3   (INodeFile@78392d6)
  *          \- z_file4   (INodeFile@45848712)
  */
-public class NamespacePrintVisitor implements NamespaceVisitor {
+public final class NamespacePrintVisitor implements NamespaceVisitor {
   static final String NON_LAST_ITEM = "+-";
   static final String LAST_ITEM = "\\-";
 
-  /** Print the tree from the given root to a {@link File}. */
-  public static void print2File(INode root, File f) throws IOException {
-    try(final PrintWriter out = new PrintWriter(new FileWriter(f), true)) {
-      new NamespacePrintVisitor(out).print(root);
-    }
-  }
-
   /** @return string of the tree in the given {@link FSNamesystem}. */
   public static String print2Sting(FSNamesystem ns) {
     return print2Sting(ns.getFSDirectory().getRoot());
@@ -73,14 +62,6 @@ public class NamespacePrintVisitor implements NamespaceVisitor {
     return out.getBuffer().toString();
   }
 
-  /**
-   * Print the tree in the given {@link FSNamesystem}
-   * to the given {@link PrintStream}.
-   */
-  public static void print(FSNamesystem ns, PrintStream out) {
-    new NamespacePrintVisitor(new PrintWriter(out)).print(ns);
-  }
-
   private final PrintWriter out;
   private final StringBuffer prefix = new StringBuffer();
 
@@ -88,10 +69,6 @@ public class NamespacePrintVisitor implements NamespaceVisitor {
     this.out = out;
   }
 
-  private void print(FSNamesystem namesystem) {
-    print(namesystem.getFSDirectory().getRoot());
-  }
-
   private void print(INode root) {
     root.accept(this, Snapshot.CURRENT_STATE_ID);
   }