Java Code Examples for org.apache.hadoop.hdfs.DFSUtil#bytes2String()
The following examples show how to use
org.apache.hadoop.hdfs.DFSUtil#bytes2String() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnapshotFSImageFormat.java From big-c with Apache License 2.0 | 6 votes |
/** * 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; }
Example 2
Source File: FSDirectory.java From big-c with Apache License 2.0 | 6 votes |
/** * 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); } } }
Example 3
Source File: SnapshotFSImageFormat.java From hadoop with Apache License 2.0 | 6 votes |
/** * 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; }
Example 4
Source File: FSDirectory.java From big-c with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: SnapshotDiffReport.java From hadoop with Apache License 2.0 | 5 votes |
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; } }
Example 6
Source File: FSImageSerialization.java From RDFS with Apache License 2.0 | 5 votes |
static INodeFileUnderConstruction readINodeUnderConstruction( DataInputStream in) throws IOException { byte[] name = readBytes(in); String path = DFSUtil.bytes2String(name); short blockReplication = in.readShort(); long modificationTime = in.readLong(); long preferredBlockSize = in.readLong(); int numBlocks = in.readInt(); BlockInfo[] blocks = new BlockInfo[numBlocks]; Block blk = new Block(); for (int i = 0; i < numBlocks; i++) { blk.readFields(in); blocks[i] = new BlockInfo(blk, blockReplication); } PermissionStatus perm = PermissionStatus.read(in); String clientName = readString(in); String clientMachine = readString(in); // These locations are not used at all int numLocs = in.readInt(); DatanodeDescriptor[] locations = new DatanodeDescriptor[numLocs]; for (int i = 0; i < numLocs; i++) { locations[i] = new DatanodeDescriptor(); locations[i].readFields(in); } return new INodeFileUnderConstruction(name, blockReplication, modificationTime, preferredBlockSize, blocks, perm, clientName, clientMachine, null); }
Example 7
Source File: FSDirectory.java From big-c with Apache License 2.0 | 5 votes |
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); }
Example 8
Source File: FSDirectory.java From hadoop with Apache License 2.0 | 5 votes |
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); }
Example 9
Source File: FSDirectory.java From hadoop with Apache License 2.0 | 5 votes |
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; }
Example 10
Source File: SnapshottableDirectoryStatus.java From big-c with Apache License 2.0 | 5 votes |
/** * @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()); } }
Example 11
Source File: SnapshotDiffReport.java From big-c with Apache License 2.0 | 5 votes |
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; } }
Example 12
Source File: INode.java From hadoop with Apache License 2.0 | 4 votes |
/** * @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); }
Example 13
Source File: INodeSymlink.java From big-c with Apache License 2.0 | 4 votes |
public String getSymlinkString() { return DFSUtil.bytes2String(symlink); }
Example 14
Source File: INode.java From big-c with Apache License 2.0 | 4 votes |
/** * @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); }
Example 15
Source File: INodeSymlink.java From hadoop with Apache License 2.0 | 4 votes |
public String getSymlinkString() { return DFSUtil.bytes2String(symlink); }
Example 16
Source File: HdfsFileStatus.java From big-c with Apache License 2.0 | 2 votes |
/** * Get the string representation of the local name * @return the local name in string */ public final String getLocalName() { return DFSUtil.bytes2String(path); }
Example 17
Source File: INode.java From RDFS with Apache License 2.0 | 2 votes |
/** * Get local file name * @return local file name */ String getLocalName() { return DFSUtil.bytes2String(name); }
Example 18
Source File: HdfsFileStatus.java From hadoop with Apache License 2.0 | 2 votes |
/** * Get the string representation of the local name * @return the local name in string */ public final String getLocalName() { return DFSUtil.bytes2String(path); }
Example 19
Source File: HdfsFileStatus.java From RDFS with Apache License 2.0 | 2 votes |
/** * Get the string representation of the local name * @return the local name in string */ final public String getLocalName() { return DFSUtil.bytes2String(path); }
Example 20
Source File: HdfsFileStatus.java From hadoop with Apache License 2.0 | 2 votes |
/** * Get the string representation of the symlink. * @return the symlink as a string. */ public final String getSymlink() { return DFSUtil.bytes2String(symlink); }