public static interface FsVolumeSpi.BlockIterator extends Closeable
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.
Modifier and Type | Method and Description |
---|---|
boolean |
atEnd()
Returns true if we got to the end of the block pool.
|
String |
getBlockPoolId()
Get the id of the block pool which this iterator traverses.
|
long |
getIterStartMs()
Get the wall-clock time, measured in milliseconds since the Epoch,
when this iterator was created.
|
long |
getLastSavedMs()
Get the wall-clock time, measured in milliseconds since the Epoch,
when this iterator was last saved.
|
org.apache.hadoop.hdfs.protocol.ExtendedBlock |
nextBlock()
Get the next block.
|
void |
rewind()
Repositions the iterator at the beginning of the block pool.
|
void |
save()
Save this block iterator to the underlying volume.
|
void |
setMaxStalenessMs(long maxStalenessMs)
Set the maximum staleness of entries that we will return.
|
org.apache.hadoop.hdfs.protocol.ExtendedBlock nextBlock() throws IOException
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.
IOException
- If there was an error getting the next block in
this volume. In this case, EOF will be set on
the iterator.boolean atEnd()
void rewind()
void save() throws IOException
IOException
- If there was an error when saving the block
iterator.void setMaxStalenessMs(long maxStalenessMs)
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.
long getIterStartMs()
long getLastSavedMs()
String getBlockPoolId()
Copyright © 2008–2021 Apache Software Foundation. All rights reserved.