Package alluxio.worker.block.meta
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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addBlockMeta(BlockMeta blockMeta)
Adds the metadata of a new block into this storage dir.void
addTempBlockMeta(TempBlockMeta tempBlockMeta)
Adds the metadata of a new block into this storage dir.void
cleanupSessionTempBlocks(long sessionId, java.util.List<java.lang.Long> tempBlockIds)
Cleans up the temp block metadata for each block id passed in.long
getAvailableBytes()
Gets the total available capacity of thisStorageDir
in bytes.java.util.List<java.lang.Long>
getBlockIds()
Returns the list of block ids in this dir.java.util.Optional<BlockMeta>
getBlockMeta(long blockId)
Gets theBlockMeta
from this storage dir by its block id.java.util.List<BlockMeta>
getBlocks()
Returns the list of blocks stored in this dir.long
getCapacityBytes()
Gets the total capacity of thisStorageDir
in bytes, which is a constant once thisStorageDir
has been initialized.long
getCommittedBytes()
Gets the total size of committed blocks in this StorageDir in bytes.int
getDirIndex()
Returns the zero-based index of this dir in its parentStorageTier
.java.lang.String
getDirMedium()
java.lang.String
getDirPath()
StorageTier
getParentTier()
Returns theStorageTier
containing thisStorageDir
.long
getReservedBytes()
java.util.List<TempBlockMeta>
getSessionTempBlocks(long sessionId)
Gets the temporary blocks associated with a session in thisStorageDir
, an empty list is returned if the session has no temporary blocks in thisStorageDir
.java.util.Optional<TempBlockMeta>
getTempBlockMeta(long blockId)
Gets theTempBlockMeta
from this storage dir by its block id.boolean
hasBlockMeta(long blockId)
Checks if a block is in this storage dir.boolean
hasTempBlockMeta(long blockId)
Checks if a temp block is in this storage dir.void
removeBlockMeta(BlockMeta blockMeta)
Removes a block from this storage dir.void
removeTempBlockMeta(TempBlockMeta tempBlockMeta)
Removes a temp block from this storage dir.void
resizeTempBlockMeta(TempBlockMeta tempBlockMeta, long newSize)
Changes the size of a temp block.BlockStoreLocation
toBlockStoreLocation()
-
-
-
Method Detail
-
getCapacityBytes
long getCapacityBytes()
Gets the total capacity of thisStorageDir
in bytes, which is a constant once thisStorageDir
has been initialized.- Returns:
- the total capacity of this
StorageDir
in bytes
-
getAvailableBytes
long getAvailableBytes()
Gets the total available capacity of thisStorageDir
in bytes. This value equals the total capacity of thisStorageDir
, 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
-
getParentTier
StorageTier getParentTier()
Returns theStorageTier
containing thisStorageDir
.- Returns:
StorageTier
-
getDirIndex
int getDirIndex()
Returns the zero-based index of this dir in its parentStorageTier
.- 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 theBlockMeta
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 theTempBlockMeta
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 resizenewSize
- 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 blockstempBlockIds
- 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 thisStorageDir
, an empty list is returned if the session has no temporary blocks in thisStorageDir
.- 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
-
-