private void addStoragePolicySatisfier(INodeWithAdditionalFields inode, XAttrFeature xaf) { if (xaf == null) { return; } XAttr xattr = xaf.getXAttr(XATTR_SATISFY_STORAGE_POLICY); if (xattr == null) { return; } FSDirSatisfyStoragePolicyOp.unprotectedSatisfyStoragePolicy(inode, this); }
/** * Reads the extended attribute of an inode by name with prefix. * <p/> * * @param inode INode to read * @param snapshotId the snapshotId of the requested path * @param prefixedName xAttr name with prefix * @return the xAttr */ public static XAttr readINodeXAttrByPrefixedName(INode inode, int snapshotId, String prefixedName) { XAttrFeature f = inode.getXAttrFeature(snapshotId); return f == null ? null : f.getXAttr(prefixedName); }
private static boolean inodeHasSatisfyXAttr(INode inode) { final XAttrFeature f = inode.getXAttrFeature(); if (inode.isFile() && f != null && f.getXAttr(XATTR_SATISFY_STORAGE_POLICY) != null) { return true; } return false; }
@Override public byte getLocalStoragePolicyID() { XAttrFeature f = getXAttrFeature(); XAttr xattr = f == null ? null : f.getXAttr( BlockStoragePolicySuite.getStoragePolicyXAttrPrefixedName()); if (xattr != null) { return (xattr.getValue())[0]; } return BLOCK_STORAGE_POLICY_ID_UNSPECIFIED; }
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; } }
@Override public void removeXattr(long id, String xattrName) throws IOException { writeLock(); try { final INode inode = dir.getInode(id); if (inode == null) { return; } final XAttrFeature xaf = inode.getXAttrFeature(); if (xaf == null) { return; } final XAttr spsXAttr = xaf.getXAttr(xattrName); if (spsXAttr != null) { FSDirSatisfyStoragePolicyOp.removeSPSXattr(dir, inode, spsXAttr); } } finally { writeUnlock("removeXAttr"); } getEditLog().logSync(); }
XAttr xattr = xaf.getXAttr(XATTR_ERASURECODING_POLICY); if (xattr != null) { ByteArrayInputStream bIn = new ByteArrayInputStream(xattr.getValue());
final XAttrFeature xaf = inode.getXAttrFeature(); if (xaf != null) { XAttr xattr = xaf.getXAttr(XATTR_ERASURECODING_POLICY); if (xattr != null) { ByteArrayInputStream bins =
private void addEncryptionZone(INodeWithAdditionalFields inode, XAttrFeature xaf) { if (xaf == null) { return; } XAttr xattr = xaf.getXAttr(CRYPTO_XATTR_ENCRYPTION_ZONE); if (xattr == null) { return; } try { final HdfsProtos.ZoneEncryptionInfoProto ezProto = HdfsProtos.ZoneEncryptionInfoProto.parseFrom(xattr.getValue()); ezManager.unprotectedAddEncryptionZone(inode.getId(), PBHelperClient.convert(ezProto.getSuite()), PBHelperClient.convert(ezProto.getCryptoProtocolVersion()), ezProto.getKeyName()); if (ezProto.hasReencryptionProto()) { final ReencryptionInfoProto reProto = ezProto.getReencryptionProto(); // inodes parents may not be loaded if this is done during fsimage // loading so cannot set full path now. Pass in null to indicate that. ezManager.getReencryptionStatus() .updateZoneStatus(inode.getId(), null, reProto); } } catch (InvalidProtocolBufferException e) { NameNode.LOG.warn("Error parsing protocol buffer of " + "EZ XAttr " + xattr.getName() + " dir:" + inode.getFullPathName()); } }