From 73746c5da76d5e39df131534a1ec35dfc5d2529b Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Fri, 29 Jun 2018 09:56:13 -0700 Subject: [PATCH] HDFS-13707. [PROVIDED Storage] Fix failing integration tests in ITestProvidedImplementation. Contributed by Virajith Jalaparti. --- .../common/blockaliasmap/impl/TextFileRegionAliasMap.java | 5 +++-- .../hdfs/server/namenode/ITestProvidedImplementation.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/TextFileRegionAliasMap.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/TextFileRegionAliasMap.java index abe92e3edb..4d65142c95 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/TextFileRegionAliasMap.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/TextFileRegionAliasMap.java @@ -28,6 +28,7 @@ import java.io.OutputStreamWriter; import java.nio.charset.Charset; import java.util.ArrayList; +import java.util.Base64; import java.util.Iterator; import java.util.Map; import java.util.Collections; @@ -359,7 +360,7 @@ private FileRegion nextInternal(Iterator i) throws IOException { } byte[] nonce = new byte[0]; if (f.length == 6) { - nonce = f[5].getBytes(Charset.forName("UTF-8")); + nonce = Base64.getDecoder().decode(f[5]); } return new FileRegion(Long.parseLong(f[0]), new Path(f[1]), Long.parseLong(f[2]), Long.parseLong(f[3]), Long.parseLong(f[4]), @@ -451,7 +452,7 @@ public void store(FileRegion token) throws IOException { out.append(Long.toString(block.getGenerationStamp())); if (psl.getNonce().length > 0) { out.append(delim) - .append(new String(psl.getNonce(), Charset.forName("UTF-8"))); + .append(Base64.getEncoder().encodeToString(psl.getNonce())); } out.append("\n"); } diff --git a/hadoop-tools/hadoop-fs2img/src/test/java/org/apache/hadoop/hdfs/server/namenode/ITestProvidedImplementation.java b/hadoop-tools/hadoop-fs2img/src/test/java/org/apache/hadoop/hdfs/server/namenode/ITestProvidedImplementation.java index 49c9bcfc0b..7d3ab0ea8f 100644 --- a/hadoop-tools/hadoop-fs2img/src/test/java/org/apache/hadoop/hdfs/server/namenode/ITestProvidedImplementation.java +++ b/hadoop-tools/hadoop-fs2img/src/test/java/org/apache/hadoop/hdfs/server/namenode/ITestProvidedImplementation.java @@ -132,7 +132,7 @@ public void setSeed() throws Exception { nnDirPath.toString()); conf.set(DFSConfigKeys.DFS_PROVIDED_ALIASMAP_TEXT_READ_FILE, new Path(nnDirPath, fileNameFromBlockPoolID(bpid)).toString()); - conf.set(DFSConfigKeys.DFS_PROVIDED_ALIASMAP_TEXT_DELIMITER, ","); + conf.set(DFSConfigKeys.DFS_PROVIDED_ALIASMAP_TEXT_DELIMITER, "\t"); conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR_PROVIDED, new File(providedPath.toUri()).toString());