Example #1
0
        /// <summary>Remove the given reference and then return the reference count.</summary>
        /// <remarks>
        /// Remove the given reference and then return the reference count.
        /// If the referred inode is not a WithCount, return -1;
        /// </remarks>
        private static int RemoveReference(Org.Apache.Hadoop.Hdfs.Server.Namenode.INodeReference
                                           @ref)
        {
            INode referred = @ref.GetReferredINode();

            if (!(referred is INodeReference.WithCount))
            {
                return(-1);
            }
            INodeReference.WithCount wc = (INodeReference.WithCount)referred;
            wc.RemoveReference(@ref);
            return(wc.GetReferenceCount());
        }
Example #2
0
 /// <summary>
 /// When destroying a reference node (WithName or DstReference), we call this
 /// method to identify the snapshot which is the latest snapshot before the
 /// reference node's creation.
 /// </summary>
 internal static int GetPriorSnapshot(Org.Apache.Hadoop.Hdfs.Server.Namenode.INodeReference
                                      @ref)
 {
     INodeReference.WithCount wc = (INodeReference.WithCount)@ref.GetReferredINode();
     INodeReference.WithName  wn = null;
     if (@ref is INodeReference.DstReference)
     {
         wn = wc.GetLastWithName();
     }
     else
     {
         if (@ref is INodeReference.WithName)
         {
             wn = wc.GetPriorWithName((INodeReference.WithName)@ref);
         }
     }
     if (wn != null)
     {
         INode referred = wc.GetReferredINode();
         if (referred.IsFile() && referred.AsFile().IsWithSnapshot())
         {
             return(referred.AsFile().GetDiffs().GetPrior(wn.lastSnapshotId));
         }
         else
         {
             if (referred.IsDirectory())
             {
                 DirectoryWithSnapshotFeature sf = referred.AsDirectory().GetDirectoryWithSnapshotFeature
                                                       ();
                 if (sf != null)
                 {
                     return(sf.GetDiffs().GetPrior(wn.lastSnapshotId));
                 }
             }
         }
     }
     return(Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot.NoSnapshotId);
 }