本文整理汇总了Java中org.apache.hadoop.hdfs.DFSUtil.bytes2String方法的典型用法代码示例。如果您正苦于以下问题:Java DFSUtil.bytes2String方法的具体用法?Java DFSUtil.bytes2String怎么用?Java DFSUtil.bytes2String使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hdfs.DFSUtil
的用法示例。
在下文中一共展示了DFSUtil.bytes2String方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPathString
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
static String getPathString(byte[] path) {
String pathStr = DFSUtil.bytes2String(path);
if (pathStr.isEmpty()) {
return Path.CUR_DIR;
} else {
return Path.CUR_DIR + Path.SEPARATOR + pathStr;
}
}
示例2: verifyMaxComponentLength
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
/**
* Verify child's name for fs limit.
*
* @param childName byte[] containing new child name
* @param parentPath String containing parent path
* @throws PathComponentTooLongException child's name is too long.
*/
void verifyMaxComponentLength(byte[] childName, String parentPath)
throws PathComponentTooLongException {
if (maxComponentLength == 0) {
return;
}
final int length = childName.length;
if (length > maxComponentLength) {
final PathComponentTooLongException e = new PathComponentTooLongException(
maxComponentLength, length, parentPath,
DFSUtil.bytes2String(childName));
if (namesystem.isImageLoaded()) {
throw e;
} else {
// Do not throw if edits log is still being processed
NameNode.LOG.error("ERROR in FSDirectory.verifyINodeName", e);
}
}
}
示例3: resolveDotInodesPath
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
private static String resolveDotInodesPath(String src,
byte[][] pathComponents, FSDirectory fsd)
throws FileNotFoundException {
final String inodeId = DFSUtil.bytes2String(pathComponents[3]);
final long id;
try {
id = Long.parseLong(inodeId);
} catch (NumberFormatException e) {
throw new FileNotFoundException("Invalid inode path: " + src);
}
if (id == INodeId.ROOT_INODE_ID && pathComponents.length == 4) {
return Path.SEPARATOR;
}
INode inode = fsd.getInode(id);
if (inode == null) {
throw new FileNotFoundException(
"File for given inode path does not exist: " + src);
}
// Handle single ".." for NFS lookup support.
if ((pathComponents.length > 4)
&& DFSUtil.bytes2String(pathComponents[4]).equals("..")) {
INode parent = inode.getParent();
if (parent == null || parent.getId() == INodeId.ROOT_INODE_ID) {
// inode is root, or its parent is root.
return Path.SEPARATOR;
} else {
return parent.getFullPathName();
}
}
String path = "";
if (id != INodeId.ROOT_INODE_ID) {
path = inode.getFullPathName();
}
return constructRemainingPath(path, pathComponents, 4);
}
示例4: loadCreated
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
/**
* Load a node stored in the created list from fsimage.
* @param createdNodeName The name of the created node.
* @param parent The directory that the created list belongs to.
* @return The created node.
*/
public static INode loadCreated(byte[] createdNodeName,
INodeDirectory parent) throws IOException {
// the INode in the created list should be a reference to another INode
// in posterior SnapshotDiffs or one of the current children
for (DirectoryDiff postDiff : parent.getDiffs()) {
final INode d = postDiff.getChildrenDiff().search(ListType.DELETED,
createdNodeName);
if (d != null) {
return d;
} // else go to the next SnapshotDiff
}
// use the current child
INode currentChild = parent.getChild(createdNodeName,
Snapshot.CURRENT_STATE_ID);
if (currentChild == null) {
throw new IOException("Cannot find an INode associated with the INode "
+ DFSUtil.bytes2String(createdNodeName)
+ " in created list while loading FSImage.");
}
return currentChild;
}
示例5: getFullPath
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
/**
* @return Full path of the file
*/
public Path getFullPath() {
String parentFullPathStr =
(parentFullPath == null || parentFullPath.length == 0) ?
null : DFSUtil.bytes2String(parentFullPath);
if (parentFullPathStr == null
&& dirStatus.getLocalNameInBytes().length == 0) {
// root
return new Path("/");
} else {
return parentFullPathStr == null ? new Path(dirStatus.getLocalName())
: new Path(parentFullPathStr, dirStatus.getLocalName());
}
}
示例6: getINodeAttrs
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
private INodeAttributes getINodeAttrs(byte[][] pathByNameArr, int pathIdx,
INode inode, int snapshotId) {
INodeAttributes inodeAttrs = inode.getSnapshotINode(snapshotId);
if (getAttributesProvider() != null) {
String[] elements = new String[pathIdx + 1];
for (int i = 0; i < elements.length; i++) {
elements[i] = DFSUtil.bytes2String(pathByNameArr[i]);
}
inodeAttrs = getAttributesProvider().getAttributes(elements, inodeAttrs);
}
return inodeAttrs;
}
示例7: getAttributes
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
INodeAttributes getAttributes(String fullPath, byte[] path,
INode node, int snapshot) {
INodeAttributes nodeAttrs = node;
if (attributeProvider != null) {
nodeAttrs = node.getSnapshotINode(snapshot);
fullPath = fullPath + (fullPath.endsWith(Path.SEPARATOR) ? ""
: Path.SEPARATOR)
+ DFSUtil.bytes2String(path);
nodeAttrs = attributeProvider.getAttributes(fullPath, nodeAttrs);
} else {
nodeAttrs = node.getSnapshotINode(snapshot);
}
return nodeAttrs;
}
示例8: getSymlinkString
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
public String getSymlinkString() {
return DFSUtil.bytes2String(symlink);
}
示例9: getLocalName
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
/**
* @return null if the local name is null; otherwise, return the local name.
*/
public final String getLocalName() {
final byte[] name = getLocalNameBytes();
return name == null? null: DFSUtil.bytes2String(name);
}
示例10: getLocalName
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
/**
* Get the string representation of the local name
* @return the local name in string
*/
public final String getLocalName() {
return DFSUtil.bytes2String(path);
}
示例11: getSymlink
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
/**
* Get the string representation of the symlink.
* @return the symlink as a string.
*/
public final String getSymlink() {
return DFSUtil.bytes2String(symlink);
}