Esempio n. 1
0
        internal ContentSummaryComputationContext ComputeContentSummary(INodeDirectory dir
                                                                        , ContentSummaryComputationContext summary)
        {
            long original      = summary.GetCounts().GetStoragespace();
            long oldYieldCount = summary.GetYieldCount();

            dir.ComputeDirectoryContentSummary(summary, Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot
                                               .CurrentStateId);
            // Check only when the content has not changed in the middle.
            if (oldYieldCount == summary.GetYieldCount())
            {
                CheckStoragespace(dir, summary.GetCounts().GetStoragespace() - original);
            }
            return(summary);
        }
 /// <exception cref="System.IO.IOException"/>
 private static ContentSummary GetContentSummaryInt(FSDirectory fsd, INodesInPath
                                                    iip)
 {
     fsd.ReadLock();
     try
     {
         INode targetNode = iip.GetLastINode();
         if (targetNode == null)
         {
             throw new FileNotFoundException("File does not exist: " + iip.GetPath());
         }
         else
         {
             // Make it relinquish locks everytime contentCountLimit entries are
             // processed. 0 means disabled. I.e. blocking for the entire duration.
             ContentSummaryComputationContext cscc = new ContentSummaryComputationContext(fsd,
                                                                                          fsd.GetFSNamesystem(), fsd.GetContentCountLimit(), fsd.GetContentSleepMicroSec()
                                                                                          );
             ContentSummary cs = targetNode.ComputeAndConvertContentSummary(cscc);
             fsd.AddYieldCount(cscc.GetYieldCount());
             return(cs);
         }
     }
     finally
     {
         fsd.ReadUnlock();
     }
 }
Esempio n. 3
0
        protected internal virtual ContentSummaryComputationContext ComputeDirectoryContentSummary
            (ContentSummaryComputationContext summary, int snapshotId)
        {
            ReadOnlyList <INode> childrenList = GetChildrenList(snapshotId);

            // Explicit traversing is done to enable repositioning after relinquishing
            // and reacquiring locks.
            for (int i = 0; i < childrenList.Size(); i++)
            {
                INode  child          = childrenList.Get(i);
                byte[] childName      = child.GetLocalNameBytes();
                long   lastYieldCount = summary.GetYieldCount();
                child.ComputeContentSummary(summary);
                // Check whether the computation was paused in the subtree.
                // The counts may be off, but traversing the rest of children
                // should be made safe.
                if (lastYieldCount == summary.GetYieldCount())
                {
                    continue;
                }
                // The locks were released and reacquired. Check parent first.
                if (GetParent() == null)
                {
                    // Stop further counting and return whatever we have so far.
                    break;
                }
                // Obtain the children list again since it may have been modified.
                childrenList = GetChildrenList(snapshotId);
                // Reposition in case the children list is changed. Decrement by 1
                // since it will be incremented when loops.
                i = NextChild(childrenList, childName) - 1;
            }
            // Increment the directory count for this directory.
            summary.GetCounts().AddContent(Content.Directory, 1);
            // Relinquish and reacquire locks if necessary.
            summary.Yield();
            return(summary);
        }