@ThreadSafe public interface BlockMetaStore
Modifier and Type | Interface and Description |
---|---|
static class |
BlockMetaStore.Block
Block metadata.
|
static interface |
BlockMetaStore.Factory
Factory for creating block stores.
|
Modifier and Type | Method and Description |
---|---|
void |
addLocation(long id,
Block.BlockLocation location)
Adds a new block location.
|
void |
clear()
Removes all metadata from the block store.
|
void |
close()
Closes the block store and releases all resources.
|
Optional<Block.BlockMeta> |
getBlock(long id) |
CloseableIterator<BlockMetaStore.Block> |
getCloseableIterator()
Gets a
CloseableIterator over the blocks. |
List<Block.BlockLocation> |
getLocations(long id)
Gets locations for a block.
|
void |
putBlock(long id,
Block.BlockMeta meta)
Adds block metadata to the block store.
|
void |
removeBlock(long id)
Removes a block, or does nothing if the block does not exist.
|
void |
removeLocation(long blockId,
long workerId)
Removes a block location.
|
long |
size() |
Optional<Block.BlockMeta> getBlock(long id)
id
- a block idvoid putBlock(long id, Block.BlockMeta meta)
id
- the block idmeta
- the block metadatavoid removeBlock(long id)
id
- a block id to removevoid clear()
List<Block.BlockLocation> getLocations(long id)
id
- a block idvoid addLocation(long id, Block.BlockLocation location)
id
- a block idlocation
- a block locationvoid removeLocation(long blockId, long workerId)
blockId
- a block idworkerId
- a worker idvoid close()
long size()
CloseableIterator<BlockMetaStore.Block> getCloseableIterator()
CloseableIterator
over the blocks.
The iterator must be closed properly.
One option is to follow the below idiom:
try (CloseableIterator<Block> iter =
mBlockStore.getCloseableIterator()) {
while (iter.hasNext()) {
// take the element and perform operations
}
}
If the iterator must be passed to other methods,
it must be closed at the end of operation or on exceptions.
Otherwise there can be a leak!CloseableIterator
over the blocksCopyright © 2023. All Rights Reserved.