HDFS-8038. PBImageDelimitedTextWriter#getEntry output HDFS path in platform-specific format. Contributed by Xiaoyu Yao.
(cherry picked from commit 672ed462965ea7da10ce3df48c02e2a3bd13f0ae) (cherry picked from commit 950dc1b1995191327e6b919ee17a87e59b749264)
This commit is contained in:
parent
2cb9dac9a3
commit
5021f52f7b
|
@ -971,6 +971,9 @@ Release 2.7.0 - UNRELEASED
|
||||||
HDFS-7999. FsDatasetImpl#createTemporary sometimes holds the FSDatasetImpl
|
HDFS-7999. FsDatasetImpl#createTemporary sometimes holds the FSDatasetImpl
|
||||||
lock for a very long time (sinago via cmccabe)
|
lock for a very long time (sinago via cmccabe)
|
||||||
|
|
||||||
|
HDFS-8038. PBImageDelimitedTextWriter#getEntry output HDFS path in
|
||||||
|
platform-specific format. (Xiaoyu Yao via cnauroth)
|
||||||
|
|
||||||
BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS
|
BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS
|
||||||
|
|
||||||
HDFS-7720. Quota by Storage Type API, tools and ClientNameNode
|
HDFS-7720. Quota by Storage Type API, tools and ClientNameNode
|
||||||
|
|
|
@ -17,13 +17,13 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hdfs.tools.offlineImageViewer;
|
package org.apache.hadoop.hdfs.tools.offlineImageViewer;
|
||||||
|
|
||||||
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.permission.PermissionStatus;
|
import org.apache.hadoop.fs.permission.PermissionStatus;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode;
|
import org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INodeDirectory;
|
import org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INodeDirectory;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INodeFile;
|
import org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INodeFile;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INodeSymlink;
|
import org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INodeSymlink;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -79,8 +79,10 @@ public class PBImageDelimitedTextWriter extends PBImageTextWriter {
|
||||||
@Override
|
@Override
|
||||||
public String getEntry(String parent, INode inode) {
|
public String getEntry(String parent, INode inode) {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
String path = new File(parent, inode.getName().toStringUtf8()).toString();
|
String inodeName = inode.getName().toStringUtf8();
|
||||||
buffer.append(path);
|
Path path = new Path(parent.isEmpty() ? "/" : parent,
|
||||||
|
inodeName.isEmpty() ? "/" : inodeName);
|
||||||
|
buffer.append(path.toString());
|
||||||
PermissionStatus p = null;
|
PermissionStatus p = null;
|
||||||
|
|
||||||
switch (inode.getType()) {
|
switch (inode.getType()) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.permission.PermissionStatus;
|
import org.apache.hadoop.fs.permission.PermissionStatus;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatPBINode;
|
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatPBINode;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatProtobuf;
|
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatProtobuf;
|
||||||
|
@ -145,7 +146,8 @@ abstract class PBImageTextWriter implements Closeable {
|
||||||
return "/";
|
return "/";
|
||||||
}
|
}
|
||||||
if (this.path == null) {
|
if (this.path == null) {
|
||||||
this.path = new File(parent.getPath(), name).toString();
|
this.path = new Path(parent.getPath(), name.isEmpty() ? "/" : name).
|
||||||
|
toString();
|
||||||
this.name = null;
|
this.name = null;
|
||||||
}
|
}
|
||||||
return this.path;
|
return this.path;
|
||||||
|
@ -364,7 +366,8 @@ abstract class PBImageTextWriter implements Closeable {
|
||||||
}
|
}
|
||||||
String parentName = toString(bytes);
|
String parentName = toString(bytes);
|
||||||
String parentPath =
|
String parentPath =
|
||||||
new File(getParentPath(parent), parentName).toString();
|
new Path(getParentPath(parent),
|
||||||
|
parentName.isEmpty()? "/" : parentName).toString();
|
||||||
dirPathCache.put(parent, parentPath);
|
dirPathCache.put(parent, parentPath);
|
||||||
}
|
}
|
||||||
return dirPathCache.get(parent);
|
return dirPathCache.get(parent);
|
||||||
|
|
Loading…
Reference in New Issue