Exemplo n.º 1
0
            /// <summary>Get the next subdirectory within the block pool slice.</summary>
            /// <returns>
            /// The next subdirectory within the block pool slice, or
            /// null if there are no more.
            /// </returns>
            /// <exception cref="System.IO.IOException"/>
            private string GetNextSubDir(string prev, FilePath dir)
            {
                IList <string> children = IOUtils.ListDirectory(dir, FsVolumeImpl.SubdirFilter.Instance
                                                                );

                this.cache   = null;
                this.cacheMs = 0;
                if (children.Count == 0)
                {
                    FsVolumeImpl.Log.Trace("getNextSubDir({}, {}): no subdirectories found in {}", this
                                           ._enclosing.storageID, this.bpid, dir.GetAbsolutePath());
                    return(null);
                }
                children.Sort();
                string nextSubDir = FsVolumeImpl.NextSorted(children, prev);

                if (nextSubDir == null)
                {
                    FsVolumeImpl.Log.Trace("getNextSubDir({}, {}): no more subdirectories found in {}"
                                           , this._enclosing.storageID, this.bpid, dir.GetAbsolutePath());
                }
                else
                {
                    FsVolumeImpl.Log.Trace("getNextSubDir({}, {}): picking next subdirectory {} " + "within {}"
                                           , this._enclosing.storageID, this.bpid, nextSubDir, dir.GetAbsolutePath());
                }
                return(nextSubDir);
            }
Exemplo n.º 2
0
 /// <summary>
 /// Get the next block.<p/>
 /// Each volume has a hierarchical structure.<p/>
 /// <code>
 /// BPID B0
 /// finalized/
 /// subdir0
 /// subdir0
 /// blk_000
 /// blk_001
 /// ...
 /// </summary>
 /// <remarks>
 /// Get the next block.<p/>
 /// Each volume has a hierarchical structure.<p/>
 /// <code>
 /// BPID B0
 /// finalized/
 /// subdir0
 /// subdir0
 /// blk_000
 /// blk_001
 /// ...
 /// subdir1
 /// subdir0
 /// ...
 /// rbw/
 /// </code>
 /// When we run out of entries at one level of the structure, we search
 /// progressively higher levels.  For example, when we run out of blk_
 /// entries in a subdirectory, we search for the next subdirectory.
 /// And so on.
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 public virtual ExtendedBlock NextBlock()
 {
     if (this.state.atEnd)
     {
         return(null);
     }
     try
     {
         while (true)
         {
             IList <string> entries = this.GetSubdirEntries();
             if (entries != null)
             {
                 this.state.curEntry = FsVolumeImpl.NextSorted(entries, this.state.curEntry);
                 if (this.state.curEntry == null)
                 {
                     FsVolumeImpl.Log.Trace("nextBlock({}, {}): advancing from {} to next " + "subdirectory."
                                            , this._enclosing.storageID, this.bpid, this.state.curFinalizedSubDir);
                 }
                 else
                 {
                     ExtendedBlock block = new ExtendedBlock(this.bpid, Block.Filename2id(this.state.curEntry
                                                                                          ));
                     FsVolumeImpl.Log.Trace("nextBlock({}, {}): advancing to {}", this._enclosing.storageID
                                            , this.bpid, block);
                     return(block);
                 }
             }
             this.state.curFinalizedSubDir = this.GetNextFinalizedSubDir();
             if (this.state.curFinalizedSubDir == null)
             {
                 this.state.curFinalizedDir = this.GetNextFinalizedDir();
                 if (this.state.curFinalizedDir == null)
                 {
                     this.state.atEnd = true;
                     return(null);
                 }
             }
         }
     }
     catch (IOException e)
     {
         this.state.atEnd = true;
         FsVolumeImpl.Log.Error("nextBlock({}, {}): I/O error", this._enclosing.storageID,
                                this.bpid, e);
         throw;
     }
 }