Class MappedPhysicalBlock

java.lang.Object
org.rostore.v2.media.block.MappedPhysicalBlock

public class MappedPhysicalBlock extends Object
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 Details

    • MappedPhysicalBlock

      protected MappedPhysicalBlock(long index, BlockType blockType)
  • Method Details

    • getAllContainerIds

      public Set<Integer> 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

      protected void markAsUsed(BlockContainer blockContainer)
      This marks the block as used (inUse = true)
      Parameters:
      blockContainer -
    • setBlockType

      protected void setBlockType(BlockType blockType)
    • getBlockType

      public BlockType getBlockType()
    • get

      protected Block get(BlockContainer blockContainer)
    • setDirty

      protected void setDirty()
    • remove

      protected void remove(BlockContainer blockContainer)
    • isEmpty

      protected boolean isEmpty()