Interface StorageDir


  • public interface StorageDir
    Represents a directory in a storage tier. It has a fixed capacity allocated to it on instantiation. It contains the set of blocks currently in the storage directory.
    • Method Detail

      • getCapacityBytes

        long getCapacityBytes()
        Gets the total capacity of this StorageDir in bytes, which is a constant once this StorageDir has been initialized.
        Returns:
        the total capacity of this StorageDir in bytes
      • getAvailableBytes

        long getAvailableBytes()
        Gets the total available capacity of this StorageDir in bytes. This value equals the total capacity of this StorageDir, minus the used bytes by committed blocks and temp blocks.
        Returns:
        available capacity in bytes
      • getCommittedBytes

        long getCommittedBytes()
        Gets the total size of committed blocks in this StorageDir in bytes.
        Returns:
        number of committed bytes
      • getDirPath

        java.lang.String getDirPath()
        Returns:
        the path of the directory
      • getDirMedium

        java.lang.String getDirMedium()
        Returns:
        the medium of the storage dir
      • getDirIndex

        int getDirIndex()
        Returns the zero-based index of this dir in its parent StorageTier.
        Returns:
        index
      • getBlockIds

        java.util.List<java.lang.Long> getBlockIds()
        Returns the list of block ids in this dir.
        Returns:
        a list of block ids
      • getBlocks

        java.util.List<BlockMeta> getBlocks()
        Returns the list of blocks stored in this dir.
        Returns:
        a list of blocks
      • hasBlockMeta

        boolean hasBlockMeta​(long blockId)
        Checks if a block is in this storage dir.
        Parameters:
        blockId - the block id
        Returns:
        true if the block is in this storage dir, false otherwise
      • hasTempBlockMeta

        boolean hasTempBlockMeta​(long blockId)
        Checks if a temp block is in this storage dir.
        Parameters:
        blockId - the block id
        Returns:
        true if the block is in this storage dir, false otherwise
      • getBlockMeta

        java.util.Optional<BlockMeta> getBlockMeta​(long blockId)
        Gets the BlockMeta from this storage dir by its block id.
        Parameters:
        blockId - the block id
        Returns:
        BlockMeta of the given block or empty
      • getTempBlockMeta

        java.util.Optional<TempBlockMeta> getTempBlockMeta​(long blockId)
        Gets the TempBlockMeta from this storage dir by its block id.
        Parameters:
        blockId - the block id
        Returns:
        TempBlockMeta of the given block or empty
      • addBlockMeta

        void addBlockMeta​(BlockMeta blockMeta)
        Adds the metadata of a new block into this storage dir.
        Parameters:
        blockMeta - the metadata of the block
      • addTempBlockMeta

        void addTempBlockMeta​(TempBlockMeta tempBlockMeta)
        Adds the metadata of a new block into this storage dir.
        Parameters:
        tempBlockMeta - the metadata of a temp block to add
      • removeBlockMeta

        void removeBlockMeta​(BlockMeta blockMeta)
        Removes a block from this storage dir.
        Parameters:
        blockMeta - the metadata of the block
      • removeTempBlockMeta

        void removeTempBlockMeta​(TempBlockMeta tempBlockMeta)
        Removes a temp block from this storage dir.
        Parameters:
        tempBlockMeta - the metadata of the temp block to remove
      • resizeTempBlockMeta

        void resizeTempBlockMeta​(TempBlockMeta tempBlockMeta,
                                 long newSize)
        Changes the size of a temp block.
        Parameters:
        tempBlockMeta - the metadata of the temp block to resize
        newSize - the new size after change in bytes
      • cleanupSessionTempBlocks

        void cleanupSessionTempBlocks​(long sessionId,
                                      java.util.List<java.lang.Long> tempBlockIds)
        Cleans up the temp block metadata for each block id passed in.
        Parameters:
        sessionId - the id of the client associated with the temporary blocks
        tempBlockIds - the list of temporary blocks to clean up, non temporary blocks or nonexistent blocks will be ignored
      • getSessionTempBlocks

        java.util.List<TempBlockMeta> getSessionTempBlocks​(long sessionId)
        Gets the temporary blocks associated with a session in this StorageDir, an empty list is returned if the session has no temporary blocks in this StorageDir.
        Parameters:
        sessionId - the id of the session
        Returns:
        A list of temporary blocks the session is associated with in this StorageDir
      • toBlockStoreLocation

        BlockStoreLocation toBlockStoreLocation()
        Returns:
        the block store location of this directory
      • getReservedBytes

        long getReservedBytes()
        Returns:
        amount of reserved bytes for this dir