From 55d5549087183cb9c8d805e33267acabe9537667 Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Wed, 16 May 2018 10:08:49 -0700 Subject: [PATCH] HDFS-13550.TestDebugAdmin#testComputeMetaCommand fails on Windows. Contributed by Anbang Hu. --- .../apache/hadoop/hdfs/tools/DebugAdmin.java | 30 ++++++++++++------- .../hadoop/hdfs/tools/TestDebugAdmin.java | 2 +- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DebugAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DebugAdmin.java index e2a6b3e3408..2c327f4ebd6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DebugAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DebugAdmin.java @@ -97,15 +97,17 @@ public class DebugAdmin extends Configured implements Tool { VerifyMetaCommand() { super("verifyMeta", "verifyMeta -meta [-block ]", -" Verify HDFS metadata and block files. If a block file is specified, we\n" + -" will verify that the checksums in the metadata file match the block\n" + +" Verify HDFS metadata and block files. If a block file is specified, we" + + System.lineSeparator() + +" will verify that the checksums in the metadata file match the block" + + System.lineSeparator() + " file."); } int run(List args) throws IOException { if (args.size() == 0) { System.out.println(usageText); - System.out.println(helpText + "\n"); + System.out.println(helpText + System.lineSeparator()); return 1; } String blockFile = StringUtils.popOptionWithArgument("-block", args); @@ -212,10 +214,15 @@ public class DebugAdmin extends Configured implements Tool { super("computeMeta", "computeMeta -block -out ", " Compute HDFS metadata from the specified block file, and save it" - + " to\n the specified output metadata file.\n\n" - + "**NOTE: Use at your own risk!\n If the block file is corrupt" - + " and you overwrite it's meta file, \n it will show up" - + " as good in HDFS, but you can't read the data.\n" + + " to" + System.lineSeparator() + + " the specified output metadata file." + + System.lineSeparator() + System.lineSeparator() + + "**NOTE: Use at your own risk!" + System.lineSeparator() + + " If the block file is corrupt" + + " and you overwrite it's meta file, " + System.lineSeparator() + + " it will show up" + + " as good in HDFS, but you can't read the data." + + System.lineSeparator() + " Only use as a last measure, and when you are 100% certain" + " the block file is good."); } @@ -234,7 +241,7 @@ public class DebugAdmin extends Configured implements Tool { int run(List args) throws IOException { if (args.size() == 0) { System.out.println(usageText); - System.out.println(helpText + "\n"); + System.out.println(helpText + System.lineSeparator()); return 1; } final String name = StringUtils.popOptionWithArgument("-block", args); @@ -291,7 +298,8 @@ public class DebugAdmin extends Configured implements Tool { RecoverLeaseCommand() { super("recoverLease", "recoverLease -path [-retries ]", -" Recover the lease on the specified path. The path must reside on an\n" + +" Recover the lease on the specified path. The path must reside on an" + + System.lineSeparator() + " HDFS filesystem. The default number of retries is 1."); } @@ -300,7 +308,7 @@ public class DebugAdmin extends Configured implements Tool { int run(List args) throws IOException { if (args.size() == 0) { System.out.println(usageText); - System.out.println(helpText + "\n"); + System.out.println(helpText + System.lineSeparator()); return 1; } String pathStr = StringUtils.popOptionWithArgument("-path", args); @@ -395,7 +403,7 @@ public class DebugAdmin extends Configured implements Tool { return 0; } System.out.println(command.usageText); - System.out.println(command.helpText + "\n"); + System.out.println(command.helpText + System.lineSeparator()); return 0; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDebugAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDebugAdmin.java index e8ee9e1faa7..5c890a54814 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDebugAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDebugAdmin.java @@ -87,7 +87,7 @@ public class TestDebugAdmin { IOUtils.closeStream(out); } return "ret: " + ret + ", " + - bytes.toString().replaceAll(System.getProperty("line.separator"), ""); + bytes.toString().replaceAll(System.lineSeparator(), ""); } @Test(timeout = 60000)