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

This commit is contained in:
Tsz-Wo Nicholas Sze 2020-08-11 21:41:28 -07:00 committed by GitHub
parent 3fd3aeb621
commit 11cec9ab94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 24 deletions

View File

@ -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);
}