Class BlockAllocationState

java.lang.Object
org.rostore.entity.BlockAllocationState
All Implemented Interfaces:
BlockAllocation

public class BlockAllocationState extends Object implements BlockAllocation
Materialized object that implements BlockAllocation
  • Method Details

    • init

      public static BlockAllocationState init()
    • init

      public static BlockAllocationState init(long totalLockedSize, long lockedFreeSize, long payloadSize)
      Initializes the state object
      Parameters:
      totalLockedSize - the total size of the locked space
      lockedFreeSize - number of bytes free in the total locked size
      payloadSize - the used bytes number of total locked
      Returns:
      the persistent object
    • store

      public static BlockAllocationState store(BlockAllocation blockAllocation)
      Creates a static copy of the provided BlockAllocation
      Parameters:
      blockAllocation - the object to get data from
      Returns:
      the persistent block allocation
    • minus

      public void minus(BlockAllocation blockAllocation)
      Subtracts the sizes from the provided object to this object
      Parameters:
      blockAllocation - the provided object
    • plus

      public void plus(BlockAllocation blockAllocation)
      Adds the sizes from the provided object to this object
      Parameters:
      blockAllocation - the provided object
    • getPayloadSize

      public long getPayloadSize()
      Get number of bytes used by the data. This data is actively used by some payload.
      Specified by:
      getPayloadSize in interface BlockAllocation
      Returns:
      the size in bytes
    • getTotalLockedSize

      public long getTotalLockedSize()
      Get number of bytes allocated for the data. This data is locked and can't be transferred somewhere. Allocated size = Free size + used size or 0.
      Specified by:
      getTotalLockedSize in interface BlockAllocation
      Returns:
      the size in bytes
    • getLockedFreeSize

      public long getLockedFreeSize()
      Get number of bytes that have been free from the allocated data. This data can be used by the payload, but stays effectively locked unused.
      Specified by:
      getLockedFreeSize in interface BlockAllocation
      Returns:
      the size in bytes
    • toString

      public String toString()
      Overrides:
      toString in class Object