Interface FsVolumeSpi.BlockIterator
- All Superinterfaces:
AutoCloseable,Closeable
- Enclosing interface:
- FsVolumeSpi
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 TypeMethodDescriptionbooleanatEnd()Returns true if we got to the end of the block pool.Get the id of the block pool which this iterator traverses.longGet the wall-clock time, measured in milliseconds since the Epoch, when this iterator was created.longGet the wall-clock time, measured in milliseconds since the Epoch, when this iterator was last saved.org.apache.hadoop.hdfs.protocol.ExtendedBlockGet the next block.voidrewind()Repositions the iterator at the beginning of the block pool.voidsave()Save this block iterator to the underlying volume.voidsetMaxStalenessMs(long maxStalenessMs) Set the maximum staleness of entries that we will return.
-
Method Details
-
nextBlock
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
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.
-