Beispiel #1
0
        public virtual EnumCounters <StorageType> GetTypeSpaces()
        {
            EnumCounters <StorageType> ret = new EnumCounters <StorageType>(typeof(StorageType)
                                                                            );

            ret.Set(tsCounts);
            return(ret);
        }
 // its ok if both counters are zero.
 /// <summary>Adjusts curr and prev number of blocks scheduled every few minutes.</summary>
 private void RollBlocksScheduled(long now)
 {
     if (now - lastBlocksScheduledRollTime > BlocksScheduledRollInterval)
     {
         prevApproxBlocksScheduled.Set(currApproxBlocksScheduled);
         currApproxBlocksScheduled.Reset();
         lastBlocksScheduledRollTime = now;
     }
 }
Beispiel #3
0
            public static INodeDirectory LoadINodeDirectory(FsImageProto.INodeSection.INode n
                                                            , FSImageFormatProtobuf.LoaderContext state)
            {
                System.Diagnostics.Debug.Assert(n.GetType() == FsImageProto.INodeSection.INode.Type
                                                .Directory);
                FsImageProto.INodeSection.INodeDirectory d = n.GetDirectory();
                PermissionStatus permissions = LoadPermission(d.GetPermission(), state.GetStringTable
                                                                  ());
                INodeDirectory dir = new INodeDirectory(n.GetId(), n.GetName().ToByteArray(), permissions
                                                        , d.GetModificationTime());
                long nsQuota = d.GetNsQuota();
                long dsQuota = d.GetDsQuota();

                if (nsQuota >= 0 || dsQuota >= 0)
                {
                    dir.AddDirectoryWithQuotaFeature(new DirectoryWithQuotaFeature.Builder().NameSpaceQuota
                                                         (nsQuota).StorageSpaceQuota(dsQuota).Build());
                }
                EnumCounters <StorageType> typeQuotas = null;

                if (d.HasTypeQuotas())
                {
                    ImmutableList <QuotaByStorageTypeEntry> qes = LoadQuotaByStorageTypeEntries(d.GetTypeQuotas
                                                                                                    ());
                    typeQuotas = new EnumCounters <StorageType>(typeof(StorageType), HdfsConstants.QuotaReset
                                                                );
                    foreach (QuotaByStorageTypeEntry qe in qes)
                    {
                        if (qe.GetQuota() >= 0 && qe.GetStorageType() != null && qe.GetStorageType().SupportTypeQuota
                                ())
                        {
                            typeQuotas.Set(qe.GetStorageType(), qe.GetQuota());
                        }
                    }
                    if (typeQuotas.AnyGreaterOrEqual(0))
                    {
                        DirectoryWithQuotaFeature q = dir.GetDirectoryWithQuotaFeature();
                        if (q == null)
                        {
                            dir.AddDirectoryWithQuotaFeature(new DirectoryWithQuotaFeature.Builder().TypeQuotas
                                                                 (typeQuotas).Build());
                        }
                        else
                        {
                            q.SetQuota(typeQuotas);
                        }
                    }
                }
                if (d.HasAcl())
                {
                    int[] entries = AclEntryStatusFormat.ToInt(LoadAclEntries(d.GetAcl(), state.GetStringTable
                                                                                  ()));
                    dir.AddAclFeature(new AclFeature(entries));
                }
                if (d.HasXAttrs())
                {
                    dir.AddXAttrFeature(new XAttrFeature(LoadXAttrs(d.GetXAttrs(), state.GetStringTable
                                                                        ())));
                }
                return(dir);
            }
Beispiel #4
0
 /// <summary>Load DirectoryDiff list for a directory with snapshot feature</summary>
 /// <exception cref="System.IO.IOException"/>
 private void LoadDirectoryDiffList(InputStream @in, INodeDirectory dir, int size,
                                    IList <INodeReference> refList)
 {
     if (!dir.IsWithSnapshot())
     {
         dir.AddSnapshotFeature(null);
     }
     DirectoryWithSnapshotFeature.DirectoryDiffList diffs = dir.GetDiffs();
     FSImageFormatProtobuf.LoaderContext            state = parent.GetLoaderContext();
     for (int i = 0; i < size; i++)
     {
         // load a directory diff
         FsImageProto.SnapshotDiffSection.DirectoryDiff diffInPb = FsImageProto.SnapshotDiffSection.DirectoryDiff
                                                                   .ParseDelimitedFrom(@in);
         int snapshotId = diffInPb.GetSnapshotId();
         Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot snapshot = snapshotMap[snapshotId
                                                                             ];
         int  childrenSize             = diffInPb.GetChildrenSize();
         bool useRoot                  = diffInPb.GetIsSnapshotRoot();
         INodeDirectoryAttributes copy = null;
         if (useRoot)
         {
             copy = snapshot.GetRoot();
         }
         else
         {
             if (diffInPb.HasSnapshotCopy())
             {
                 FsImageProto.INodeSection.INodeDirectory dirCopyInPb = diffInPb.GetSnapshotCopy();
                 byte[]           name       = diffInPb.GetName().ToByteArray();
                 PermissionStatus permission = FSImageFormatPBINode.Loader.LoadPermission(dirCopyInPb
                                                                                          .GetPermission(), state.GetStringTable());
                 AclFeature acl = null;
                 if (dirCopyInPb.HasAcl())
                 {
                     int[] entries = AclEntryStatusFormat.ToInt(FSImageFormatPBINode.Loader.LoadAclEntries
                                                                    (dirCopyInPb.GetAcl(), state.GetStringTable()));
                     acl = new AclFeature(entries);
                 }
                 XAttrFeature xAttrs = null;
                 if (dirCopyInPb.HasXAttrs())
                 {
                     xAttrs = new XAttrFeature(FSImageFormatPBINode.Loader.LoadXAttrs(dirCopyInPb.GetXAttrs
                                                                                          (), state.GetStringTable()));
                 }
                 long modTime = dirCopyInPb.GetModificationTime();
                 bool noQuota = dirCopyInPb.GetNsQuota() == -1 && dirCopyInPb.GetDsQuota() == -1 &&
                                (!dirCopyInPb.HasTypeQuotas());
                 if (noQuota)
                 {
                     copy = new INodeDirectoryAttributes.SnapshotCopy(name, permission, acl, modTime,
                                                                      xAttrs);
                 }
                 else
                 {
                     EnumCounters <StorageType> typeQuotas = null;
                     if (dirCopyInPb.HasTypeQuotas())
                     {
                         ImmutableList <QuotaByStorageTypeEntry> qes = FSImageFormatPBINode.Loader.LoadQuotaByStorageTypeEntries
                                                                           (dirCopyInPb.GetTypeQuotas());
                         typeQuotas = new EnumCounters <StorageType>(typeof(StorageType), HdfsConstants.QuotaReset
                                                                     );
                         foreach (QuotaByStorageTypeEntry qe in qes)
                         {
                             if (qe.GetQuota() >= 0 && qe.GetStorageType() != null && qe.GetStorageType().SupportTypeQuota
                                     ())
                             {
                                 typeQuotas.Set(qe.GetStorageType(), qe.GetQuota());
                             }
                         }
                     }
                     copy = new INodeDirectoryAttributes.CopyWithQuota(name, permission, acl, modTime,
                                                                       dirCopyInPb.GetNsQuota(), dirCopyInPb.GetDsQuota(), typeQuotas, xAttrs);
                 }
             }
         }
         // load created list
         IList <INode> clist = LoadCreatedList(@in, dir, diffInPb.GetCreatedListSize());
         // load deleted list
         IList <INode> dlist = LoadDeletedList(refList, @in, dir, diffInPb.GetDeletedINodeList
                                                   (), diffInPb.GetDeletedINodeRefList());
         // create the directory diff
         DirectoryWithSnapshotFeature.DirectoryDiff diff = new DirectoryWithSnapshotFeature.DirectoryDiff
                                                               (snapshotId, copy, null, childrenSize, clist, dlist, useRoot);
         diffs.AddFirst(diff);
     }
 }
Beispiel #5
0
 public virtual ContentCounts.Builder File(long file)
 {
     contents.Set(Content.File, file);
     return(this);
 }