public static FsImageProto.INodeSection.INodeDirectory.Builder BuildINodeDirectory (INodeDirectoryAttributes dir, FSImageFormatProtobuf.SaverContext state) { QuotaCounts quota = dir.GetQuotaCounts(); FsImageProto.INodeSection.INodeDirectory.Builder b = FsImageProto.INodeSection.INodeDirectory .NewBuilder().SetModificationTime(dir.GetModificationTime()).SetNsQuota(quota.GetNameSpace ()).SetDsQuota(quota.GetStorageSpace()).SetPermission(BuildPermissionStatus(dir, state.GetStringMap())); if (quota.GetTypeSpaces().AnyGreaterOrEqual(0)) { b.SetTypeQuotas(BuildQuotaByStorageTypeEntries(quota)); } AclFeature f = dir.GetAclFeature(); if (f != null) { b.SetAcl(BuildAclEntries(f, state.GetStringMap())); } XAttrFeature xAttrFeature = dir.GetXAttrFeature(); if (xAttrFeature != null) { b.SetXAttrs(BuildXAttrs(xAttrFeature, state.GetStringMap())); } return(b); }
private void LoadRootINode(FsImageProto.INodeSection.INode p) { INodeDirectory root = LoadINodeDirectory(p, parent.GetLoaderContext()); QuotaCounts q = root.GetQuotaCounts(); long nsQuota = q.GetNameSpace(); long dsQuota = q.GetStorageSpace(); if (nsQuota != -1 || dsQuota != -1) { dir.rootDir.GetDirectoryWithQuotaFeature().SetQuota(nsQuota, dsQuota); } EnumCounters <StorageType> typeQuotas = q.GetTypeSpaces(); if (typeQuotas.AnyGreaterOrEqual(0)) { dir.rootDir.GetDirectoryWithQuotaFeature().SetQuota(typeQuotas); } dir.rootDir.CloneModificationTime(root); dir.rootDir.ClonePermissionStatus(root); AclFeature af = root.GetFeature(typeof(AclFeature)); if (af != null) { dir.rootDir.AddAclFeature(af); } // root dir supports having extended attributes according to POSIX XAttrFeature f = root.GetXAttrFeature(); if (f != null) { dir.rootDir.AddXAttrFeature(f); } dir.AddRootDirToEncryptionZone(f); }
internal override void RemoveXAttrFeature() { XAttrFeature f = GetXAttrFeature(); Preconditions.CheckNotNull(f); RemoveFeature(f); }
internal override void AddXAttrFeature(XAttrFeature f) { XAttrFeature f1 = GetXAttrFeature(); Preconditions.CheckState(f1 == null, "Duplicated XAttrFeature"); AddFeature(f); }
internal Org.Apache.Hadoop.Hdfs.Server.Namenode.INode AddXAttrFeature(XAttrFeature xAttrFeature, int latestSnapshotId) { RecordModification(latestSnapshotId); AddXAttrFeature(xAttrFeature); return(this); }
public CopyWithQuota(byte[] name, PermissionStatus permissions, AclFeature aclFeature , long modificationTime, long nsQuota, long dsQuota, EnumCounters <StorageType> typeQuotas , XAttrFeature xAttrsFeature) : base(name, permissions, aclFeature, modificationTime, xAttrsFeature) { this.quota = new QuotaCounts.Builder().NameSpace(nsQuota).StorageSpace(dsQuota).TypeSpaces (typeQuotas).Build(); }
public SnapshotCopy(byte[] name, PermissionStatus permissions, AclFeature aclFeature , long modificationTime, long accessTime, short replication, long preferredBlockSize , byte storagePolicyID, XAttrFeature xAttrsFeature) : base(name, permissions, aclFeature, modificationTime, accessTime, xAttrsFeature ) { header = INodeFile.HeaderFormat.ToLong(preferredBlockSize, replication, storagePolicyID ); }
internal SnapshotCopy(byte[] name, PermissionStatus permissions, AclFeature aclFeature , long modificationTime, long accessTime, XAttrFeature xAttrFeature) { this.name = name; this.permission = INodeWithAdditionalFields.PermissionStatusFormat.ToLong(permissions ); if (aclFeature != null) { aclFeature = AclStorage.AddAclFeature(aclFeature); } this.aclFeature = aclFeature; this.modificationTime = modificationTime; this.accessTime = accessTime; this.xAttrFeature = xAttrFeature; }
public override XAttrFeature GetXAttrFeature() { XAttrFeature x; if (useDefault) { x = inode.GetXAttrFeature(); } else { x = new XAttrFeature(ImmutableList.CopyOf(Lists.NewArrayList(new XAttr.Builder(). SetName("test").SetValue(new byte[] { 1, 2 }).Build()))); } return(x); }
public override byte GetLocalStoragePolicyID() { XAttrFeature f = GetXAttrFeature(); ImmutableList <XAttr> xattrs = f == null?ImmutableList.Of <XAttr>() : f.GetXAttrs (); foreach (XAttr xattr in xattrs) { if (BlockStoragePolicySuite.IsStoragePolicyXAttr(xattr)) { return((xattr.GetValue())[0]); } } return(BlockStoragePolicySuite.IdUnspecified); }
internal SnapshotCopy(INode inode) { this.name = inode.GetLocalNameBytes(); this.permission = inode.GetPermissionLong(); if (inode.GetAclFeature() != null) { aclFeature = AclStorage.AddAclFeature(inode.GetAclFeature()); } else { aclFeature = null; } this.modificationTime = inode.GetModificationTime(); this.accessTime = inode.GetAccessTime(); this.xAttrFeature = inode.GetXAttrFeature(); }
public static FsImageProto.INodeSection.INodeFile.Builder BuildINodeFile(INodeFileAttributes file, FSImageFormatProtobuf.SaverContext state) { FsImageProto.INodeSection.INodeFile.Builder b = FsImageProto.INodeSection.INodeFile .NewBuilder().SetAccessTime(file.GetAccessTime()).SetModificationTime(file.GetModificationTime ()).SetPermission(BuildPermissionStatus(file, state.GetStringMap())).SetPreferredBlockSize (file.GetPreferredBlockSize()).SetReplication(file.GetFileReplication()).SetStoragePolicyID (file.GetLocalStoragePolicyID()); AclFeature f = file.GetAclFeature(); if (f != null) { b.SetAcl(BuildAclEntries(f, state.GetStringMap())); } XAttrFeature xAttrFeature = file.GetXAttrFeature(); if (xAttrFeature != null) { b.SetXAttrs(BuildXAttrs(xAttrFeature, state.GetStringMap())); } return(b); }
/// <summary>Set <code>XAttrFeature</code></summary> internal abstract void AddXAttrFeature(XAttrFeature xAttrFeature);
internal sealed override void AddXAttrFeature(XAttrFeature xAttrFeature) { referred.AddXAttrFeature(xAttrFeature); }
/// <summary>Reads the existing extended attributes of an inode.</summary> /// <remarks> /// Reads the existing extended attributes of an inode. If the /// inode does not have an <code>XAttr</code>, then this method /// returns an empty list. /// <p/> /// Must be called while holding the FSDirectory read lock. /// </remarks> /// <param name="inode">INode to read</param> /// <param name="snapshotId"/> /// <returns>List<XAttr> <code>XAttr</code> list.</returns> public static IList <XAttr> ReadINodeXAttrs(INode inode, int snapshotId) { XAttrFeature f = inode.GetXAttrFeature(snapshotId); return(f == null?ImmutableList.Of <XAttr>() : f.GetXAttrs()); }
/// <summary>Reads the existing extended attributes of an inode.</summary> /// <remarks> /// Reads the existing extended attributes of an inode. /// <p/> /// Must be called while holding the FSDirectory read lock. /// </remarks> /// <param name="inodeAttr">INodeAttributes to read.</param> /// <returns>List<XAttr> <code>XAttr</code> list.</returns> public static IList <XAttr> ReadINodeXAttrs(INodeAttributes inodeAttr) { XAttrFeature f = inodeAttr.GetXAttrFeature(); return(f == null?ImmutableList.Of <XAttr>() : f.GetXAttrs()); }
private static FsImageProto.INodeSection.XAttrFeatureProto.Builder BuildXAttrs(XAttrFeature f, FSImageFormatProtobuf.SaverContext.DeduplicationMap <string> stringMap) { FsImageProto.INodeSection.XAttrFeatureProto.Builder b = FsImageProto.INodeSection.XAttrFeatureProto .NewBuilder(); foreach (XAttr a in f.GetXAttrs()) { FsImageProto.INodeSection.XAttrCompactProto.Builder xAttrCompactBuilder = FsImageProto.INodeSection.XAttrCompactProto .NewBuilder(); int nsOrd = (int)(a.GetNameSpace()); Preconditions.CheckArgument(nsOrd < 8, "Too many namespaces."); int v = ((nsOrd & XattrNamespaceMask) << XattrNamespaceOffset) | ((stringMap.GetId (a.GetName()) & XattrNameMask) << XattrNameOffset); v |= (((nsOrd >> 2) & XattrNamespaceExtMask) << XattrNamespaceExtOffset); xAttrCompactBuilder.SetName(v); if (a.GetValue() != null) { xAttrCompactBuilder.SetValue(PBHelper.GetByteString(a.GetValue())); } b.AddXAttrs(((FsImageProto.INodeSection.XAttrCompactProto)xAttrCompactBuilder.Build ())); } return(b); }
public SnapshotCopy(byte[] name, PermissionStatus permissions, AclFeature aclFeature , long modificationTime, XAttrFeature xAttrsFeature) : base(name, permissions, aclFeature, modificationTime, 0L, xAttrsFeature) { }
internal override void AddXAttrFeature(XAttrFeature f) { throw new NotSupportedException("XAttrs are not supported on symlinks"); }