/** * Verify if this {@link INodesInPath} is a descendant of the * requested {@link INodeDirectory}. * * @param inodeDirectory the ancestor directory * @return true if this INodesInPath is a descendant of inodeDirectory */ public boolean isDescendant(final INodeDirectory inodeDirectory) { final INodesInPath dirIIP = fromINode(inodeDirectory); return isDescendant(dirIIP); }
/** * @param pendingFile open file that needs to be closed * @param storedBlock last block * @throws IOException on error */ @VisibleForTesting void closeFileCommitBlocks(String src, INodeFile pendingFile, BlockInfo storedBlock) throws IOException { final INodesInPath iip = INodesInPath.fromINode(pendingFile); // commit the last block and complete it if it has minimum replicas commitOrCompleteLastBlock(pendingFile, iip, storedBlock); //remove lease, close file int s = Snapshot.findLatestSnapshot(pendingFile, Snapshot.CURRENT_STATE_ID); finalizeINodeFileUnderConstruction(src, pendingFile, s, false); }
@Override public List<INodesInPath> call() { List<INodesInPath> iNodesInPaths = Lists.newArrayList(); for (int idx = startIdx; idx < inodeCount; idx += workerCount) { INode inode = inodes[idx]; if (!inode.isFile()) { continue; } INodesInPath inodesInPath = INodesInPath.fromINode( fsnamesystem.getFSDirectory().getRoot(), inode.asFile()); if (ancestorDir != null && !inodesInPath.isDescendant(ancestorDir)) { continue; } iNodesInPaths.add(inodesInPath); } return iNodesInPaths; } };
public void updateCount(INodesInPath iip, INode.QuotaDelta quotaDelta, boolean check) throws QuotaExceededException { QuotaCounts counts = quotaDelta.getCountsCopy(); updateCount(iip, iip.length() - 1, counts.negation(), check); Map<INode, QuotaCounts> deltaInOtherPaths = quotaDelta.getUpdateMap(); for (Map.Entry<INode, QuotaCounts> entry : deltaInOtherPaths.entrySet()) { INodesInPath path = INodesInPath.fromINode(entry.getKey()); updateCount(path, path.length() - 1, entry.getValue().negation(), check); } for (Map.Entry<INodeDirectory, QuotaCounts> entry : quotaDelta.getQuotaDirMap().entrySet()) { INodeDirectory quotaDir = entry.getKey(); quotaDir.getDirectoryWithQuotaFeature().addSpaceConsumed2Cache( entry.getValue().negation()); } }
static void removeSPSXattr(FSDirectory fsd, INode inode, XAttr spsXAttr) throws IOException { try { fsd.writeLock(); List<XAttr> existingXAttrs = XAttrStorage.readINodeXAttrs(inode); existingXAttrs.remove(spsXAttr); XAttrStorage.updateINodeXAttrs(inode, existingXAttrs, INodesInPath .fromINode(inode).getLatestSnapshotId()); List<XAttr> xAttrs = Lists.newArrayListWithCapacity(1); xAttrs.add(spsXAttr); fsd.getEditLog().logRemoveXAttrs(inode.getFullPathName(), xAttrs, false); } finally { fsd.writeUnlock(); } } }
FileEdekInfo(FSDirectory dir, INodeFile inode) throws IOException { assert dir.hasReadLock(); Preconditions.checkNotNull(inode, "INodeFile is null"); inodeId = inode.getId(); final FileEncryptionInfo fei = FSDirEncryptionZoneOp .getFileEncryptionInfo(dir, INodesInPath.fromINode(inode)); Preconditions.checkNotNull(fei, "FileEncryptionInfo is null for " + inodeId); existingEdek = EncryptedKeyVersion .createForDecryption(fei.getKeyName(), fei.getEzKeyVersionName(), fei.getIV(), fei.getEncryptedDataEncryptionKey()); }
INodesInPath resolvePath(FSPermissionChecker pc, String src, long fileId) throws UnresolvedLinkException, FileNotFoundException, AccessControlException, ParentNotDirectoryException { // Older clients may not have given us an inode ID to work with. // In this case, we have to try to resolve the path and hope it // hasn't changed or been deleted since the file was opened for write. INodesInPath iip; if (fileId == HdfsConstants.GRANDFATHER_INODE_ID) { iip = resolvePath(pc, src, DirOp.WRITE); } else { INode inode = getInode(fileId); if (inode == null) { iip = INodesInPath.fromComponents(INode.getPathComponents(src)); } else { iip = INodesInPath.fromINode(inode); } } return iip; }
dir, INodesInPath.fromINode(inode)); if (feInfo == null) { LOG.warn("File {} skipped re-encryption because it is not encrypted! "
List<XAttr> completeReencryption(final INode zoneNode) throws IOException { assert dir.hasWriteLock(); assert dir.getFSNamesystem().hasWriteLock(); final Long zoneId = zoneNode.getId(); ZoneReencryptionStatus zs = getReencryptionStatus().getZoneStatus(zoneId); assert zs != null; LOG.info("Re-encryption completed on zone {}. Re-encrypted {} files," + " failures encountered: {}.", zoneNode.getFullPathName(), zs.getFilesReencrypted(), zs.getNumReencryptionFailures()); synchronized (this) { submissions.remove(zoneId); } return FSDirEncryptionZoneOp .updateReencryptionFinish(dir, INodesInPath.fromINode(zoneNode), zs); }
for(Long id : leaseINodeIds) { try { INodesInPath iip = INodesInPath.fromINode(fsd.getInode(id)); p = iip.getPath();
FSDirDeleteOp.deleteInternal( FSNamesystem.this, INodesInPath.fromINode((INodeFile) bc), false); changed |= toRemoveBlocks != null; if (toRemoveBlocks != null) {
.getFileEncryptionInfo(dir, INodesInPath.fromINode(inode)); if (!fei.getKeyName().equals(entry.edek.getEncryptionKeyName())) { LOG.debug("Inode {} EZ key changed, skipping re-encryption.", entry.edek.getEncryptedKeyIv(), fei.getKeyName(), entry.edek.getEncryptionKeyVersionName()); final INodesInPath iip = INodesInPath.fromINode(inode); FSDirEncryptionZoneOp .setFileEncryptionInfo(dir, iip, newFei, XAttrSetFlag.REPLACE);
assert fsd.hasWriteLock(); Preconditions.checkNotNull(zoneNode, "Zone node is null"); INodesInPath iip = INodesInPath.fromINode(zoneNode); final ZoneEncryptionInfoProto zoneProto = getZoneEncryptionInfoProto(iip); Preconditions.checkNotNull(zoneProto, "ZoneEncryptionInfoProto is null.");
assert namesystem.hasWriteLock(); INodesInPath iip = inodes != null ? inodes : INodesInPath.fromINode(namesystem.getBlockCollection(completeBlk)); INodeFile fileINode = iip.getLastINode().asFile();
INodesInPath inodesInPath = INodesInPath.fromINode(pendingFile); saveAllocatedBlock(fsn, src, inodesInPath, newBlock, targets, blockType);
/** * @param pendingFile open file that needs to be closed * @param storedBlock last block * @throws IOException on error */ @VisibleForTesting void closeFileCommitBlocks(String src, INodeFile pendingFile, BlockInfoContiguous storedBlock) throws IOException { final INodesInPath iip = INodesInPath.fromINode(pendingFile); // commit the last block and complete it if it has minimum replicas commitOrCompleteLastBlock(pendingFile, iip, storedBlock); //remove lease, close file finalizeINodeFileUnderConstruction(src, pendingFile, Snapshot.findLatestSnapshot(pendingFile, Snapshot.CURRENT_STATE_ID)); }
/** * @param pendingFile open file that needs to be closed * @param storedBlock last block * @throws IOException on error */ @VisibleForTesting void closeFileCommitBlocks(String src, INodeFile pendingFile, BlockInfoContiguous storedBlock) throws IOException { final INodesInPath iip = INodesInPath.fromINode(pendingFile); // commit the last block and complete it if it has minimum replicas commitOrCompleteLastBlock(pendingFile, iip, storedBlock); //remove lease, close file finalizeINodeFileUnderConstruction(src, pendingFile, Snapshot.findLatestSnapshot(pendingFile, Snapshot.CURRENT_STATE_ID)); }
INodesInPath resolvePath(FSPermissionChecker pc, String src, long fileId) throws UnresolvedLinkException, FileNotFoundException, AccessControlException { // Older clients may not have given us an inode ID to work with. // In this case, we have to try to resolve the path and hope it // hasn't changed or been deleted since the file was opened for write. INodesInPath iip; if (fileId == INodeId.GRANDFATHER_INODE_ID) { iip = resolvePath(pc, src); } else { INode inode = getInode(fileId); if (inode == null) { iip = INodesInPath.fromComponents(INode.getPathComponents(src)); } else { iip = INodesInPath.fromINode(inode); } } return iip; }
INodesInPath resolvePath(FSPermissionChecker pc, String src, long fileId) throws UnresolvedLinkException, FileNotFoundException, AccessControlException { // Older clients may not have given us an inode ID to work with. // In this case, we have to try to resolve the path and hope it // hasn't changed or been deleted since the file was opened for write. INodesInPath iip; if (fileId == INodeId.GRANDFATHER_INODE_ID) { iip = resolvePath(pc, src); } else { INode inode = getInode(fileId); if (inode == null) { iip = INodesInPath.fromComponents(INode.getPathComponents(src)); } else { iip = INodesInPath.fromINode(inode); } } return iip; }
/** * Update the cached quota space for a block that is being completed. * Must only be called once, as the block is being completed. * @param completeBlk - Completed block for which to update space * @param inodes - INodes in path to file containing completeBlk; if null * this will be resolved internally */ public void updateSpaceForCompleteBlock(BlockInfoContiguous completeBlk, INodesInPath inodes) throws IOException { assert namesystem.hasWriteLock(); INodesInPath iip = inodes != null ? inodes : INodesInPath.fromINode((INodeFile) completeBlk.getBlockCollection()); INodeFile fileINode = iip.getLastINode().asFile(); // Adjust disk space consumption if required final long diff = fileINode.getPreferredBlockSize() - completeBlk.getNumBytes(); if (diff > 0) { try { updateSpaceConsumed(iip, 0, -diff, fileINode.getFileReplication()); } catch (IOException e) { LOG.warn("Unexpected exception while updating disk space.", e); } } }