Package org.rostore.v2.media.block
Class MappedPhysicalBlocks
java.lang.Object
org.rostore.v2.media.block.MappedPhysicalBlocks
This is a container of all active physical blocks in the ro-store.
It manages a cache of the blocks, so that different processes would get the access to the same instances of the blocks.
When the blocks are not used by any processes they still be preserved in
the cache until the time provided in MediaProperties.getCloseUnusedBlocksAfterMillis()
is expired.
This passive caching is only applied for the non-data blocks, the blocks which type
is not BlockType.DATA
.
This is a major hub of blocks in the Media
and this class manages the
concurrent access and is internally is thread safe.
A great precaution should be paid to the synchronized blocks in its implementation.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
get
(BlockContainer blockContainer, long index, BlockType blockType) Creates aBlockContainer
privateBlock
.void
remove
(BlockContainer blockContainer, long index) int
size()
The total size of passively cached blocks and the actively used that are currently managed by this instance.
-
Constructor Details
-
MappedPhysicalBlocks
Creates an object- Parameters:
media
- the media it should be used in
-
-
Method Details
-
size
public int size()The total size of passively cached blocks and the actively used that are currently managed by this instance.- Returns:
- a number of blocks currently in the memory
-
get
Creates aBlockContainer
privateBlock
. If the block is not in use or in cache, it is get loaded from the persistence layer.- Parameters:
blockContainer
- the container the block should be associated withindex
- the index of the blockblockType
- the type of the block- Returns:
- a block that can be used in the container
-
remove
-
closeExpired
public void closeExpired() -
closeUnused
public void closeUnused()
-