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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidflush()Execute a flushing of the current state of the block back to the storage.protected Blockget(BlockContainer blockContainer) Provides all container ids where this physical block is used.longgetIndex()The index of the block in the ro-store.longProvides a timestamp when this block become unused.booleaninUse()Provides an indication if this block is used in at least one active processbooleanisDirty()Provides an indication if this block has been modified in memory, but has not been explicitly flushed to the persistence layer.protected booleanisEmpty()protected voidmarkAsUsed(BlockContainer blockContainer) This marks the block as used (inUse = true)protected voidremove(BlockContainer blockContainer) protected voidsetBlockType(BlockType blockType) protected voidsetDirty()
-
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:
trueif 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:
trueif 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()
-