List of usage examples for org.apache.hadoop.hdfs DFSUtil bytes2String
public static String bytes2String(byte[] bytes)
From source file:io.hops.common.INodeResolver.java
License:Apache License
public INode next() throws UnresolvedPathException, StorageException, TransactionContextException { boolean lastComp = (count == components.length - 1); if (currentInode.isSymlink() && (!lastComp || (lastComp && resolveLink))) { final String symPath = INodeUtil.constructPath(components, 0, components.length); final String preceding = INodeUtil.constructPath(components, 0, count); final String remainder = INodeUtil.constructPath(components, count + 1, components.length); final String link = DFSUtil.bytes2String(components[count]); final String target = ((INodeSymlink) currentInode).getLinkValue(); if (NameNode.stateChangeLog.isDebugEnabled()) { NameNode.stateChangeLog.debug( "UnresolvedPathException " + " path: " + symPath + " preceding: " + preceding + " count: " + count + " link: " + link + " target: " + target + " remainder: " + remainder); }//ww w . jav a2 s. c om throw new UnresolvedPathException(symPath, preceding, remainder, target); } if (!hasNext()) { throw new NoSuchElementException("Trying to read more components than available"); } currentInode = INodeUtil.getNode(components[++count], currentInode.getId(), transactional); return currentInode; }
From source file:io.hops.common.INodeUtil.java
License:Apache License
public static String constructPath(byte[][] components, int start, int end) { StringBuilder buf = new StringBuilder(); for (int i = start; i < end; i++) { buf.append(DFSUtil.bytes2String(components[i])); if (i < end - 1) { buf.append(Path.SEPARATOR); }//from w w w . j ava2 s .com } return buf.toString(); }
From source file:io.hops.common.INodeUtil.java
License:Apache License
public static INode getNode(byte[] name, int parentId, boolean transactional) throws StorageException, TransactionContextException { String nameString = DFSUtil.bytes2String(name); if (transactional) { return EntityManager.find(INode.Finder.ByNameAndParentId, nameString, parentId); } else {//from w ww.j a v a 2 s.c o m return findINodeWithNoTransaction(nameString, parentId); } }
From source file:io.hops.metadata.adaptor.INodeDALAdaptor.java
License:Apache License
@Override public INode convertHDFStoDAL(org.apache.hadoop.hdfs.server.namenode.INode inode) throws StorageException { INode hopINode = null;// ww w .j av a 2s. com if (inode != null) { hopINode = new INode(); hopINode.setModificationTime(inode.getModificationTime()); hopINode.setAccessTime(inode.getAccessTime()); hopINode.setName(inode.getLocalName()); DataOutputBuffer permissionString = new DataOutputBuffer(); try { inode.getPermissionStatus().write(permissionString); } catch (IOException e) { throw new StorageException(e); } hopINode.setPermission(permissionString.getData()); hopINode.setParentId(inode.getParentId()); hopINode.setId(inode.getId()); if (inode instanceof INodeDirectory) { hopINode.setUnderConstruction(false); hopINode.setDirWithQuota(false); } if (inode instanceof INodeDirectoryWithQuota) { hopINode.setUnderConstruction(false); hopINode.setDirWithQuota(true); } if (inode instanceof INodeFile) { hopINode.setUnderConstruction(inode.isUnderConstruction() ? true : false); hopINode.setDirWithQuota(false); hopINode.setHeader(((INodeFile) inode).getHeader()); if (inode instanceof INodeFileUnderConstruction) { hopINode.setClientName(((INodeFileUnderConstruction) inode).getClientName()); hopINode.setClientMachine(((INodeFileUnderConstruction) inode).getClientMachine()); hopINode.setClientNode(((INodeFileUnderConstruction) inode).getClientNode() == null ? null : ((INodeFileUnderConstruction) inode).getClientNode().getXferAddr()); } hopINode.setGenerationStamp(((INodeFile) inode).getGenerationStamp()); } if (inode instanceof INodeSymlink) { hopINode.setUnderConstruction(false); hopINode.setDirWithQuota(false); String linkValue = DFSUtil.bytes2String(((INodeSymlink) inode).getSymlink()); hopINode.setSymlink(linkValue); } hopINode.setSubtreeLocked(inode.isSubtreeLocked()); hopINode.setSubtreeLockOwner(inode.getSubtreeLockOwner()); } return hopINode; }
From source file:io.hops.transaction.lock.INodeLock.java
License:Apache License
private String buildPath(String path, int size) { StringBuilder builder = new StringBuilder(); byte[][] components = INode.getPathComponents(path); for (int i = 0; i < Math.min(components.length, size); i++) { if (i == 0) { builder.append("/"); } else {// ww w . j a va 2s . c om if (i != 1) { builder.append("/"); } builder.append(DFSUtil.bytes2String(components[i])); } } return builder.toString(); }