Author: wheat9 Date: Thu Mar 27 23:11:02 2014 New Revision: 1582533 URL: http://svn.apache.org/r1582533 Log: HDFS-6164. Remove lsr in OfflineImageViewer. Contributed by Haohui Mai.
Removed: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/LsrPBImage.java Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageViewerPB.java hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1582533&r1=1582532&r2=1582533&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Thu Mar 27 23:11:02 2014 @@ -271,6 +271,8 @@ Release 2.5.0 - UNRELEASED HDFS-5978. Create a tool to take fsimage and expose read-only WebHDFS API. (Akira Ajisaka via wheat9) + HDFS-6164. Remove lsr in OfflineImageViewer. (wheat9) + OPTIMIZATIONS BUG FIXES Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageViewerPB.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageViewerPB.java?rev=1582533&r1=1582532&r2=1582533&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageViewerPB.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageViewerPB.java Thu Mar 27 23:11:02 2014 @@ -57,11 +57,6 @@ public class OfflineImageViewerPB { + "order to process an image file.\n" + "\n" + "The following image processors are available:\n" - + " * Ls: The default image processor generates an lsr-style listing\n" - + " of the files in the namespace, with the same fields in the same\n" - + " order. Note that in order to correctly determine file sizes,\n" - + " this formatter cannot skip blocks and will override the\n" - + " -skipBlocks option.\n" + " * XML: This processor creates an XML document with all elements of\n" + " the fsimage enumerated, suitable for further analysis by XML\n" + " tools.\n" @@ -169,8 +164,6 @@ public class OfflineImageViewerPB { String addr = cmd.getOptionValue("addr", "localhost:5978"); new WebImageViewer(NetUtils.createSocketAddr(addr)) .initServerAndWait(inputFile); - } else { - new LsrPBImage(conf, out).visit(new RandomAccessFile(inputFile, "r")); } return 0; } catch (EOFException e) { Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java?rev=1582533&r1=1582532&r2=1582533&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java Thu Mar 27 23:11:02 2014 @@ -79,16 +79,6 @@ public class TestOfflineImageViewer { private static final String TEST_RENEWER = "JobTracker"; private static File originalFsimage = null; - // Elements of lines of ls-file output to be compared to FileStatus instance - private static final class LsElements { - private String perms; - private int replication; - private String username; - private String groupname; - private long filesize; - private boolean isDir; - } - // namespace as written to dfs, to be compared with viewer's output final static HashMap<String, FileStatus> writtenFiles = Maps.newHashMap(); @@ -176,37 +166,6 @@ public class TestOfflineImageViewer { return hdfs.getFileStatus(new Path(file)); } - // Verify that we can correctly generate an ls-style output for a valid - // fsimage - @Test - public void outputOfLSVisitor() throws IOException { - StringWriter output = new StringWriter(); - PrintWriter out = new PrintWriter(output); - LsrPBImage v = new LsrPBImage(new Configuration(), out); - v.visit(new RandomAccessFile(originalFsimage, "r")); - out.close(); - Pattern pattern = Pattern - .compile("([d\\-])([rwx\\-]{9})\\s*(-|\\d+)\\s*(\\w+)\\s*(\\w+)\\s*(\\d+)\\s*(\\d+)\\s*([\b/]+)"); - int count = 0; - for (String s : output.toString().split("\n")) { - Matcher m = pattern.matcher(s); - assertTrue(m.find()); - LsElements e = new LsElements(); - e.isDir = m.group(1).equals("d"); - e.perms = m.group(2); - e.replication = m.group(3).equals("-") ? 0 : Integer.parseInt(m.group(3)); - e.username = m.group(4); - e.groupname = m.group(5); - e.filesize = Long.parseLong(m.group(7)); - String path = m.group(8); - if (!path.equals("/")) { - compareFiles(writtenFiles.get(path), e); - } - ++count; - } - assertEquals(writtenFiles.size() + 1, count); - } - @Test(expected = IOException.class) public void testTruncatedFSImage() throws IOException { File truncatedFile = folder.newFile(); @@ -216,18 +175,6 @@ public class TestOfflineImageViewer { output)).visit(new RandomAccessFile(truncatedFile, "r")); } - // Compare two files as listed in the original namespace FileStatus and - // the output of the ls file from the image processor - private void compareFiles(FileStatus fs, LsElements elements) { - assertEquals("directory listed as such", fs.isDirectory(), elements.isDir); - assertEquals("perms string equal", fs.getPermission().toString(), - elements.perms); - assertEquals("replication equal", fs.getReplication(), elements.replication); - assertEquals("owner equal", fs.getOwner(), elements.username); - assertEquals("group equal", fs.getGroup(), elements.groupname); - assertEquals("lengths equal", fs.getLen(), elements.filesize); - } - private void copyPartOfFile(File src, File dest) throws IOException { FileInputStream in = null; FileOutputStream out = null;