Package org.rostore.v2.media.block
Class MappedPhysicalBlock
java.lang.Object
org.rostore.v2.media.block.MappedPhysicalBlock
Represents the mapped to the memory the physical block of the storage.
It should not be modified explicitly, instead the user processes
should retrieve the Block
, which will contain the data of this
block, but provide an independent pointer to the block, so it can
be modified independently.
This object holds all the references to the Block
it was duplicated to
as well as the information regaring the BlockContainer
these duplicates are opened with.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
flush()
Execute a flushing of the current state of the block back to the storage.protected Block
get
(BlockContainer blockContainer) Provides all container ids where this physical block is used.long
getIndex()
The index of the block in the ro-store.long
Provides a timestamp when this block become unused.boolean
inUse()
Provides an indication if this block is used in at least one active processboolean
isDirty()
Provides an indication if this block has been modified in memory, but has not been explicitly flushed to the persistence layer.protected boolean
isEmpty()
protected void
markAsUsed
(BlockContainer blockContainer) This marks the block as used (inUse = true)protected void
remove
(BlockContainer blockContainer) protected void
setBlockType
(BlockType blockType) protected void
setDirty()
-
Constructor Details
-
MappedPhysicalBlock
-
-
Method Details
-
getAllContainerIds
Provides all container ids where this physical block is used.- Returns:
- a set of container ids
-
getUnusedSince
public long getUnusedSince()Provides a timestamp when this block become unused.- Returns:
- a unix epoch timestamp in milliseconds
-
inUse
public boolean inUse()Provides an indication if this block is used in at least one active process- Returns:
true
if the block is still in use
-
isDirty
public boolean isDirty()Provides an indication if this block has been modified in memory, but has not been explicitly flushed to the persistence layer.This is a weak indicator, the operation of flushing might be executed by the underlying processes in the operating system, which do not have a feedback loop to the Ro-Store.
- Returns:
true
if the block is marked by the ro-store as dirty
-
getIndex
public long getIndex()The index of the block in the ro-store.- Returns:
- the index of the block
-
flush
public void flush()Execute a flushing of the current state of the block back to the storage.The dirty flag will be reset.
-
markAsUsed
This marks the block as used (inUse = true)- Parameters:
blockContainer
-
-
setBlockType
-
getBlockType
-
get
-
setDirty
protected void setDirty() -
remove
-
isEmpty
protected boolean isEmpty()
-