@Override public final boolean isSymlink() { return referred.isSymlink(); }
/** * Get the storage policy ID while computing quota usage * @param parentStoragePolicyId the storage policy ID of the parent directory * @return the storage policy ID of this INode. Note that for an * {@link INodeSymlink} we return {@link HdfsConstants#BLOCK_STORAGE_POLICY_ID_UNSPECIFIED} * instead of throwing Exception */ public byte getStoragePolicyIDForQuota(byte parentStoragePolicyId) { byte localId = isSymlink() ? HdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED : getLocalStoragePolicyID(); return localId != HdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED ? localId : parentStoragePolicyId; }
/** * Count subtree {@link Quota#NAMESPACE} and {@link Quota#STORAGESPACE} usages. * Entry point for FSDirectory where blockStoragePolicyId is given its initial * value. */ public final QuotaCounts computeQuotaUsage(BlockStoragePolicySuite bsps) { final byte storagePolicyId = isSymlink() ? HdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED : getStoragePolicyID(); return computeQuotaUsage(bsps, storagePolicyId, true, Snapshot.CURRENT_STATE_ID); }
public final QuotaCounts computeQuotaUsage(BlockStoragePolicySuite bsps, boolean useCache) { final byte storagePolicyId = isSymlink() ? HdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED : getStoragePolicyID(); return computeQuotaUsage(bsps, storagePolicyId, useCache, Snapshot.CURRENT_STATE_ID); }
private static void validateDestination( String src, String dst, INode srcInode) throws IOException { String error; if (srcInode.isSymlink() && dst.equals(srcInode.asSymlink().getSymlinkString())) { throw new FileAlreadyExistsException("Cannot rename symlink " + src + " to its target " + dst); } // dst cannot be a directory or a file under src if (dst.startsWith(src) && dst.charAt(src.length()) == Path.SEPARATOR_CHAR) { error = "Rename destination " + dst + " is a directory or file under source " + src; NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedRenameTo: " + error); throw new IOException(error); } if (FSDirectory.isExactReservedName(src) || FSDirectory.isExactReservedName(dst)) { error = "Cannot rename to or from /.reserved"; throw new InvalidPathException(error); } }
private static void checkNotSymlink(INode inode, byte[][] components, int i) throws UnresolvedPathException { if (inode != null && inode.isSymlink()) { final int last = components.length - 1; final String path = getPath(components, 0, last); final String preceding = getPath(components, 0, i - 1); final String remainder = getPath(components, i + 1, last); final String target = inode.asSymlink().getSymlinkString(); if (LOG.isDebugEnabled()) { final String link = inode.getLocalName(); LOG.debug("UnresolvedPathException " + " path: " + path + " preceding: " + preceding + " count: " + i + " link: " + link + " target: " + target + " remainder: " + remainder); } throw new UnresolvedPathException(path, preceding, remainder, target); } }
/** Get the file info for a specific file. * @param fsd FSDirectory * @param iip The path to the file, the file is included * @param includeStoragePolicy whether to include storage policy * @param needLocation Include {@link LocatedBlocks} in response * @param needBlockToken Generate block tokens for {@link LocatedBlocks} * @return object containing information regarding the file * or null if file not found */ static HdfsFileStatus getFileInfo(FSDirectory fsd, INodesInPath iip, boolean includeStoragePolicy, boolean needLocation, boolean needBlockToken) throws IOException { fsd.readLock(); try { final INode node = iip.getLastINode(); if (node == null) { return null; } byte policy = (includeStoragePolicy && !node.isSymlink()) ? node.getStoragePolicyID() : HdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED; return createFileStatus(fsd, iip, null, policy, needLocation, needBlockToken); } finally { fsd.readUnlock(); } }
private static XAttr getErasureCodingPolicyXAttrForINode( FSNamesystem fsn, INode inode) throws IOException { // INode can be null if (inode == null) { return null; } FSDirectory fsd = fsn.getFSDirectory(); fsd.readLock(); try { // We don't allow setting EC policies on paths with a symlink. Thus // if a symlink is encountered, the dir shouldn't have EC policy. // TODO: properly support symlinks if (inode.isSymlink()) { return null; } final XAttrFeature xaf = inode.getXAttrFeature(); if (xaf != null) { XAttr xattr = xaf.getXAttr(XATTR_ERASURECODING_POLICY); if (xattr != null) { return xattr; } } } finally { fsd.readUnlock(); } return null; } }
private void save(OutputStream out, INode n) throws IOException { if (n.isDirectory()) { save(out, n.asDirectory()); } else if (n.isFile()) { save(out, n.asFile()); } else if (n.isSymlink()) { save(out, n.asSymlink()); } }
/** * This method is always called with writeLock of FSDirectory held. */ public final void addToInodeMap(INode inode) { if (inode instanceof INodeWithAdditionalFields) { inodeMap.put(inode); if (!inode.isSymlink()) { final XAttrFeature xaf = inode.getXAttrFeature(); addEncryptionZone((INodeWithAdditionalFields) inode, xaf); StoragePolicySatisfyManager spsManager = namesystem.getBlockManager().getSPSManager(); if (spsManager != null && spsManager.isEnabled()) { addStoragePolicySatisfier((INodeWithAdditionalFields) inode, xaf); } } } }
if (inode.isSymlink()) { return null;
/** * Save one inode's attributes to the image. */ public static void saveINode2Image(INode node, DataOutput out, boolean writeUnderConstruction, ReferenceMap referenceMap) throws IOException { if (node.isReference()) { writeINodeReference(node.asReference(), out, writeUnderConstruction, referenceMap); } else if (node.isDirectory()) { writeINodeDirectory(node.asDirectory(), out); } else if (node.isSymlink()) { writeINodeSymlink(node.asSymlink(), out); } else if (node.isFile()) { writeINodeFile(node.asFile(), out, writeUnderConstruction); } }
if (inode.isSymlink()) { return "";
replication = fileNode.getFileReplication(snapshot); blocksize = fileNode.getPreferredBlockSize(); } else if (inode.isSymlink()) { symlink = new Path( DFSUtilClient.bytes2String(inode.asSymlink().getSymlink()));
nodeAttrs.getUserName(), nodeAttrs.getGroupName(), node.isSymlink() ? node.asSymlink().getSymlink() : null, name, node.getId(),
for (int i = 0; i < numOfListing && locationBudget > 0; i++) { INode child = contents.get(startChild+i); byte childStoragePolicy = (includeStoragePolicy && !child.isSymlink()) ? getStoragePolicyID(child.getLocalStoragePolicyID(), parentStoragePolicy)
public final QuotaCounts computeQuotaUsage( BlockStoragePolicySuite bsps, QuotaCounts counts, boolean useCache) { final byte storagePolicyId = isSymlink() ? BlockStoragePolicySuite.ID_UNSPECIFIED : getStoragePolicyID(); return computeQuotaUsage(bsps, storagePolicyId, counts, useCache, Snapshot.CURRENT_STATE_ID); }
public final QuotaCounts computeQuotaUsage( BlockStoragePolicySuite bsps, QuotaCounts counts, boolean useCache) { final byte storagePolicyId = isSymlink() ? BlockStoragePolicySuite.ID_UNSPECIFIED : getStoragePolicyID(); return computeQuotaUsage(bsps, storagePolicyId, counts, useCache, Snapshot.CURRENT_STATE_ID); }
/** * This method is always called with writeLock of FSDirectory held. */ public final void addToInodeMap(INode inode) { if (inode instanceof INodeWithAdditionalFields) { inodeMap.put(inode); if (!inode.isSymlink()) { final XAttrFeature xaf = inode.getXAttrFeature(); addEncryptionZone((INodeWithAdditionalFields) inode, xaf); } } }
/** * Count subtree {@link Quota#NAMESPACE} and {@link Quota#STORAGESPACE} usages. * Entry point for FSDirectory where blockStoragePolicyId is given its initial * value. */ public final QuotaCounts computeQuotaUsage(BlockStoragePolicySuite bsps) { final byte storagePolicyId = isSymlink() ? BlockStoragePolicySuite.ID_UNSPECIFIED : getStoragePolicyID(); return computeQuotaUsage(bsps, storagePolicyId, new QuotaCounts.Builder().build(), true, Snapshot.CURRENT_STATE_ID); }