@NotThreadSafe public final class DefaultStorageDir extends Object implements StorageDir
StorageDirView
, this space will be reflected as:
- committed for user I/Os
- available for internal I/Os.Modifier and Type | Method and 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,
List<Long> tempBlockIds)
Cleans up the temp block metadata for each block id passed in.
|
long |
getAvailableBytes()
Gets the total available capacity of this
StorageDir in bytes. |
List<Long> |
getBlockIds()
Returns the list of block ids in this dir.
|
Optional<BlockMeta> |
getBlockMeta(long blockId)
Gets the
BlockMeta from this storage dir by its block id. |
List<BlockMeta> |
getBlocks()
Returns the list of blocks stored in this dir.
|
long |
getCapacityBytes()
Gets the total capacity of this
StorageDir in bytes, which is a constant once this
StorageDir 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 parent
StorageTier . |
String |
getDirMedium() |
String |
getDirPath() |
StorageTier |
getParentTier()
Returns the
StorageTier containing this StorageDir . |
long |
getReservedBytes() |
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 . |
Optional<TempBlockMeta> |
getTempBlockMeta(long blockId)
Gets the
TempBlockMeta 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.
|
static StorageDir |
newStorageDir(StorageTier tier,
int dirIndex,
long capacityBytes,
long reservedBytes,
String dirPath,
String dirMedium)
Factory method to create
StorageDir . |
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() |
public static StorageDir newStorageDir(StorageTier tier, int dirIndex, long capacityBytes, long reservedBytes, String dirPath, String dirMedium)
StorageDir
.
It will load metadata of existing committed blocks in the dirPath specified. Only files with
directory depth 1 under dirPath and whose file name can be parsed into long
will be
considered as existing committed blocks, these files will be preserved, others files or
directories will be deleted.tier
- the StorageTier
this dir belongs todirIndex
- the index of this dir in its tiercapacityBytes
- the initial capacity of this dir, can not be modified laterreservedBytes
- the amount of reserved space for internal managementdirPath
- filesystem path of this dir for actual storagedirMedium
- the medium type of the storage dirStorageDir
public long getCapacityBytes()
StorageDir
StorageDir
in bytes, which is a constant once this
StorageDir
has been initialized.getCapacityBytes
in interface StorageDir
StorageDir
in bytespublic long getAvailableBytes()
StorageDir
StorageDir
in bytes. This value equals the
total capacity of this StorageDir
, minus the used bytes by committed blocks and temp
blocks.getAvailableBytes
in interface StorageDir
public long getCommittedBytes()
StorageDir
getCommittedBytes
in interface StorageDir
public String getDirPath()
getDirPath
in interface StorageDir
public String getDirMedium()
getDirMedium
in interface StorageDir
public StorageTier getParentTier()
StorageDir
StorageTier
containing this StorageDir
.getParentTier
in interface StorageDir
StorageTier
public int getDirIndex()
StorageDir
StorageTier
.getDirIndex
in interface StorageDir
public List<Long> getBlockIds()
StorageDir
getBlockIds
in interface StorageDir
public List<BlockMeta> getBlocks()
StorageDir
getBlocks
in interface StorageDir
public boolean hasBlockMeta(long blockId)
StorageDir
hasBlockMeta
in interface StorageDir
blockId
- the block idpublic boolean hasTempBlockMeta(long blockId)
StorageDir
hasTempBlockMeta
in interface StorageDir
blockId
- the block idpublic Optional<BlockMeta> getBlockMeta(long blockId)
StorageDir
BlockMeta
from this storage dir by its block id.getBlockMeta
in interface StorageDir
blockId
- the block idBlockMeta
of the given block or emptypublic Optional<TempBlockMeta> getTempBlockMeta(long blockId)
StorageDir
TempBlockMeta
from this storage dir by its block id.getTempBlockMeta
in interface StorageDir
blockId
- the block idTempBlockMeta
of the given block or emptypublic void addBlockMeta(BlockMeta blockMeta)
StorageDir
addBlockMeta
in interface StorageDir
blockMeta
- the metadata of the blockpublic void addTempBlockMeta(TempBlockMeta tempBlockMeta)
StorageDir
addTempBlockMeta
in interface StorageDir
tempBlockMeta
- the metadata of a temp block to addpublic void removeBlockMeta(BlockMeta blockMeta)
StorageDir
removeBlockMeta
in interface StorageDir
blockMeta
- the metadata of the blockpublic void removeTempBlockMeta(TempBlockMeta tempBlockMeta)
StorageDir
removeTempBlockMeta
in interface StorageDir
tempBlockMeta
- the metadata of the temp block to removepublic void resizeTempBlockMeta(TempBlockMeta tempBlockMeta, long newSize)
StorageDir
resizeTempBlockMeta
in interface StorageDir
tempBlockMeta
- the metadata of the temp block to resizenewSize
- the new size after change in bytespublic void cleanupSessionTempBlocks(long sessionId, List<Long> tempBlockIds)
StorageDir
cleanupSessionTempBlocks
in interface StorageDir
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 ignoredpublic List<TempBlockMeta> getSessionTempBlocks(long sessionId)
StorageDir
StorageDir
, an empty list
is returned if the session has no temporary blocks in this StorageDir
.getSessionTempBlocks
in interface StorageDir
sessionId
- the id of the sessionStorageDir
public BlockStoreLocation toBlockStoreLocation()
toBlockStoreLocation
in interface StorageDir
public long getReservedBytes()
getReservedBytes
in interface StorageDir
Copyright © 2023. All Rights Reserved.