[ 
https://issues.apache.org/jira/browse/HDFS-16437?focusedWorklogId=720022&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-720022
 ]

ASF GitHub Bot logged work on HDFS-16437:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Feb/22 11:04
            Start Date: 03/Feb/22 11:04
    Worklog Time Spent: 10m 
      Work Description: singer-bin commented on a change in pull request #3926:
URL: https://github.com/apache/hadoop/pull/3926#discussion_r798451082



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
##########
@@ -1174,6 +1174,42 @@ public void testReverseXmlWrongLayoutVersion() throws 
Throwable {
     }
   }
 
+  /**
+   * Tests that the ReverseXML processor doesn't accept XML files without the 
SnapshotDiffSection.
+   */
+  @Test
+  public void testReverseXmlWithoutSnapshotDiffSection() throws Throwable {
+    File imageWSDS = new File(tempDir, "imageWithoutSnapshotDiffSection.xml");
+    PrintWriter writer = new PrintWriter(imageWSDS, "UTF-8");
+    try {
+      writer.println("<?xml version=\"1.0\"?>");
+      writer.println("<fsimage>");
+      writer.println("<version>");
+      writer.println("<layoutVersion>-67</layoutVersion>");
+      writer.println("<onDiskVersion>1</onDiskVersion>");
+      
writer.println("<oivRevision>545bbef596c06af1c3c8dca1ce29096a64608478</oivRevision>");
+      writer.println("</version>");
+      
writer.println("<FileUnderConstructionSection></FileUnderConstructionSection>");
+      writer.println("<ErasureCodingSection></ErasureCodingSection>");
+      
writer.println("<INodeSection><lastInodeId>91488</lastInodeId><numInodes>0</numInodes></INodeSection>");
+      
writer.println("<SecretManagerSection><currentId>90</currentId><tokenSequenceNumber>35</tokenSequenceNumber><numDelegationKeys>0</numDelegationKeys><numTokens>0</numTokens></SecretManagerSection>");
+      writer.println("<INodeReferenceSection></INodeReferenceSection>");
+      
writer.println("<SnapshotSection><snapshotCounter>0</snapshotCounter><numSnapshots>0</numSnapshots></SnapshotSection>");
+      
writer.println("<NameSection><namespaceId>326384987</namespaceId></NameSection>");
+      
writer.println("<CacheManagerSection><nextDirectiveId>1</nextDirectiveId><numPools>0</numPools><numDirectives>0</numDirectives></CacheManagerSection>");
+      writer.println("<INodeDirectorySection></INodeDirectorySection>");
+      writer.println("</fsimage>");
+    } finally {
+      writer.close();
+    }
+    try {
+      OfflineImageReconstructor.run(imageWSDS.getAbsolutePath(),

Review comment:
       I refer to the following methods in this class to prove that the 
original logic is problematic, so I need to use my patch.
   `  @Test
     public void testReverseXmlWrongLayoutVersion() throws Throwable {
       File imageWrongVersion = new File(tempDir, "imageWrongVersion.xml");
       PrintWriter writer = new PrintWriter(imageWrongVersion, "UTF-8");
       try {
         writer.println("<?xml version=\"1.0\"?>");
         writer.println("<fsimage>");
         writer.println("<version>");
         writer.println(String.format("<layoutVersion>%d</layoutVersion>",
             NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION + 1));
         writer.println("<onDiskVersion>1</onDiskVersion>");
         writer.println("<oivRevision>" +
             "545bbef596c06af1c3c8dca1ce29096a64608478</oivRevision>");
         writer.println("</version>");
         writer.println("</fsimage>");
       } finally {
         writer.close();
       }
       try {
         OfflineImageReconstructor.run(imageWrongVersion.getAbsolutePath(),
             imageWrongVersion.getAbsolutePath() + ".out"); 
         Assert.fail("Expected OfflineImageReconstructor to fail with " +
             "version mismatch.");
       } catch (Throwable t) {
         GenericTestUtils.assertExceptionContains("Layout version mismatch.", 
t);
       }
     }`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 720022)
    Time Spent: 3h 10m  (was: 3h)

> ReverseXML processor doesn't accept XML files without the SnapshotDiffSection.
> ------------------------------------------------------------------------------
>
>                 Key: HDFS-16437
>                 URL: https://issues.apache.org/jira/browse/HDFS-16437
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: hdfs
>    Affects Versions: 3.1.1, 3.3.0
>            Reporter: yanbin.zhang
>            Priority: Critical
>              Labels: pull-request-available
>          Time Spent: 3h 10m
>  Remaining Estimate: 0h
>
> In a cluster environment without snapshot, if you want to convert back to 
> fsimage through the generated xml, an error will be reported.
> {code:java}
> //代码占位符
> [test@test001 ~]$ hdfs oiv -p ReverseXML -i fsimage_0000000000000257220.xml 
> -o fsimage_0000000000000257220
> OfflineImageReconstructor failed: FSImage XML ended prematurely, without 
> including section(s) SnapshotDiffSection
> java.io.IOException: FSImage XML ended prematurely, without including 
> section(s) SnapshotDiffSection
>         at 
> org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageReconstructor.processXml(OfflineImageReconstructor.java:1765)
>         at 
> org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageReconstructor.run(OfflineImageReconstructor.java:1842)
>         at 
> org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewerPB.run(OfflineImageViewerPB.java:211)
>         at 
> org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewerPB.main(OfflineImageViewerPB.java:149)
> 22/01/25 15:56:52 INFO util.ExitUtil: Exiting with status 1: ExitException 
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to