예제 #1
0
        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);
        }
예제 #2
0
 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);
 }
예제 #3
0
        /// <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());
        }
예제 #4
0
        /// <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());
        }