Interface FsVolumeSpi.BlockIterator

All Superinterfaces:
AutoCloseable, Closeable
Enclosing interface:
FsVolumeSpi

public static interface FsVolumeSpi.BlockIterator extends Closeable
BlockIterator will return ExtendedBlock entries from a block pool in this volume. The entries will be returned in sorted order.

BlockIterator objects themselves do not always have internal synchronization, so they can only safely be used by a single thread at a time.

Closing the iterator does not save it. You must call save to save it.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if we got to the end of the block pool.
    Get the id of the block pool which this iterator traverses.
    long
    Get the wall-clock time, measured in milliseconds since the Epoch, when this iterator was created.
    long
    Get the wall-clock time, measured in milliseconds since the Epoch, when this iterator was last saved.
    org.apache.hadoop.hdfs.protocol.ExtendedBlock
    Get the next block.
    void
    Repositions the iterator at the beginning of the block pool.
    void
    Save this block iterator to the underlying volume.
    void
    setMaxStalenessMs(long maxStalenessMs)
    Set the maximum staleness of entries that we will return.

    Methods inherited from interface java.io.Closeable

    close
  • Method Details

    • nextBlock

      org.apache.hadoop.hdfs.protocol.ExtendedBlock nextBlock() throws IOException
      Get the next block.

      Note that this block may be removed in between the time we list it, and the time the caller tries to use it, or it may represent a stale entry. Callers should handle the case where the returned block no longer exists.

      Returns:
      The next block, or null if there are no more blocks. Null if there was an error determining the next block.
      Throws:
      IOException - If there was an error getting the next block in this volume. In this case, EOF will be set on the iterator.
    • atEnd

      boolean atEnd()
      Returns true if we got to the end of the block pool.
    • rewind

      void rewind()
      Repositions the iterator at the beginning of the block pool.
    • save

      void save() throws IOException
      Save this block iterator to the underlying volume. Any existing saved block iterator with this name will be overwritten. maxStalenessMs will not be saved.
      Throws:
      IOException - If there was an error when saving the block iterator.
    • setMaxStalenessMs

      void setMaxStalenessMs(long maxStalenessMs)
      Set the maximum staleness of entries that we will return.

      A maximum staleness of 0 means we will never return stale entries; a larger value will allow us to reduce resource consumption in exchange for returning more potentially stale entries. Even with staleness set to 0, consumers of this API must handle race conditions where block disappear before they can be processed.

    • getIterStartMs

      long getIterStartMs()
      Get the wall-clock time, measured in milliseconds since the Epoch, when this iterator was created.
    • getLastSavedMs

      long getLastSavedMs()
      Get the wall-clock time, measured in milliseconds since the Epoch, when this iterator was last saved. Returns iterStartMs if the iterator was never saved.
    • getBlockPoolId

      String getBlockPoolId()
      Get the id of the block pool which this iterator traverses.