3232import org .apache .hadoop .hdfs .server .namenode .snapshot .FileWithSnapshotFeature ;
3333import org .apache .hadoop .hdfs .server .namenode .snapshot .Snapshot ;
3434
35- import java .io .File ;
36- import java .io .FileWriter ;
37- import java .io .IOException ;
38- import java .io .PrintStream ;
3935import java .io .PrintWriter ;
4036import java .io .StringWriter ;
4137
5046 * \- file3 (INodeFile@78392d6)
5147 * \- z_file4 (INodeFile@45848712)
5248 */
53- public class NamespacePrintVisitor implements NamespaceVisitor {
49+ public final class NamespacePrintVisitor implements NamespaceVisitor {
5450 static final String NON_LAST_ITEM = "+-" ;
5551 static final String LAST_ITEM = "\\ -" ;
5652
57- /** Print the tree from the given root to a {@link File}. */
58- public static void print2File (INode root , File f ) throws IOException {
59- try (final PrintWriter out = new PrintWriter (new FileWriter (f ), true )) {
60- new NamespacePrintVisitor (out ).print (root );
61- }
62- }
63-
6453 /** @return string of the tree in the given {@link FSNamesystem}. */
6554 public static String print2Sting (FSNamesystem ns ) {
6655 return print2Sting (ns .getFSDirectory ().getRoot ());
@@ -73,25 +62,13 @@ public static String print2Sting(INode root) {
7362 return out .getBuffer ().toString ();
7463 }
7564
76- /**
77- * Print the tree in the given {@link FSNamesystem}
78- * to the given {@link PrintStream}.
79- */
80- public static void print (FSNamesystem ns , PrintStream out ) {
81- new NamespacePrintVisitor (new PrintWriter (out )).print (ns );
82- }
83-
8465 private final PrintWriter out ;
8566 private final StringBuffer prefix = new StringBuffer ();
8667
8768 private NamespacePrintVisitor (PrintWriter out ) {
8869 this .out = out ;
8970 }
9071
91- private void print (FSNamesystem namesystem ) {
92- print (namesystem .getFSDirectory ().getRoot ());
93- }
94-
9572 private void print (INode root ) {
9673 root .accept (this , Snapshot .CURRENT_STATE_ID );
9774 }
0 commit comments