public final class StorageDir extends Object
Modifier and Type | Method and Description |
---|---|
void |
accessBlock(long blockId)
Update the last access time of the block
|
boolean |
cacheBlock(long userId,
long blockId)
Move the cached block file from user temporary folder to data folder
|
boolean |
cancelBlock(long userId,
long blockId)
Cancel a block which is being written
|
void |
cleanUserResources(long userId,
Collection<Long> tempBlockIdList)
Clean resources related to the removed user
|
boolean |
containsBlock(long blockId)
Check whether the StorageDir contains certain block
|
boolean |
copyBlock(long blockId,
StorageDir dstDir)
Copy block file from this StorageDir to another StorageDir, the caller needs to make sure the
block is locked during copying
|
boolean |
deleteBlock(long blockId)
Remove a block from current StorageDir, once calling this method, the block will not be
available any longer
|
List<Long> |
getAddedBlockIdList()
Get Ids of newly added blocks
|
long |
getAvailableBytes()
Get available space size in bytes in current StorageDir
|
ByteBuffer |
getBlockData(long blockId,
long offset,
int length)
Read data into ByteBuffer from some block file, caller needs to make sure the block is locked
during reading
|
String |
getBlockFilePath(long blockId)
Get file path of the block file
|
BlockHandler |
getBlockHandler(long blockId)
Get block handler used to access the block file
|
Set<Long> |
getBlockIds()
Get Ids of the blocks in current StorageDir
|
long |
getBlockSize(long blockId)
Get size of the block in bytes
|
Set<Map.Entry<Long,Long>> |
getBlockSizes()
Get sizes of the blocks in bytes in current StorageDir
|
long |
getCapacityBytes()
Get capacity of current StorageDir in bytes
|
TachyonURI |
getDirDataPath()
Get data path of current StorageDir
|
TachyonURI |
getDirPath()
Get root path of current StorageDir
|
Set<Map.Entry<Long,Long>> |
getLastBlockAccessTimeMs()
Get last access time of blocks in current StorageDir
|
long |
getLockedSizeBytes()
Get size of locked blocks in bytes in current StorageDir
|
long |
getStorageDirId()
Get Id of current StorageDir
|
UnderFileSystem |
getUfs()
Get current StorageDir's under file system
|
Object |
getUfsConf()
Get configuration of current StorageDir's under file system
|
long |
getUsedBytes()
Get used space in bytes in current StorageDir
|
long |
getUserOwnBytes(long userId)
Get temporary space owned by the user in current StorageDir
|
String |
getUserTempFilePath(long userId,
long blockId)
Get temporary file path of block written by some user
|
TachyonURI |
getUserTempPath()
Get root temporary path of users
|
String |
getUserTempPath(long userId)
Get temporary path of some user
|
void |
initailize()
Initialize current StorageDir
|
boolean |
isBlockLocked(long blockId)
Check whether certain block is locked
|
boolean |
lockBlock(long blockId,
long userId)
Lock block by some user
|
boolean |
moveBlock(long blockId,
StorageDir dstDir)
Move a block from its current StorageDir to another StorageDir
|
boolean |
requestSpace(long userId,
long size)
Request space from current StorageDir by some user
|
void |
returnSpace(long userId,
long size)
Return space to current StorageDir by some user
|
boolean |
unlockBlock(long blockId,
long userId)
Unlock block by some user
|
void |
updateTempBlockAllocatedBytes(long userId,
long blockId,
long sizeBytes)
Update allocated space bytes of a temporary block in current StorageDir
|
public void accessBlock(long blockId)
blockId
- Id of the blockpublic boolean cacheBlock(long userId, long blockId) throws IOException
userId
- the id of the userblockId
- the id of the blockIOException
public boolean cancelBlock(long userId, long blockId) throws IOException
userId
- the id of the userblockId
- the id of the block to be cancelledIOException
public void cleanUserResources(long userId, Collection<Long> tempBlockIdList)
userId
- id of the removed usertempBlockIdList
- list of block ids that are being written by the userpublic boolean containsBlock(long blockId)
blockId
- Id of the blockpublic boolean copyBlock(long blockId, StorageDir dstDir) throws IOException
blockId
- Id of the blockdstDir
- destination StorageDirIOException
public boolean deleteBlock(long blockId) throws IOException
blockId
- Id of the block to be removed.IOException
public List<Long> getAddedBlockIdList()
public long getAvailableBytes()
public ByteBuffer getBlockData(long blockId, long offset, int length) throws IOException
blockId
- Id of the blockoffset
- starting position of the block filelength
- length of data to readIOException
public String getBlockFilePath(long blockId)
blockId
- Id of the blockpublic BlockHandler getBlockHandler(long blockId) throws IOException
blockId
- Id of the blockIOException
public Set<Long> getBlockIds()
public long getBlockSize(long blockId)
blockId
- Id of the blockpublic Set<Map.Entry<Long,Long>> getBlockSizes()
public long getCapacityBytes()
public TachyonURI getDirDataPath()
public TachyonURI getDirPath()
public Set<Map.Entry<Long,Long>> getLastBlockAccessTimeMs()
public long getLockedSizeBytes()
public long getStorageDirId()
public UnderFileSystem getUfs()
public Object getUfsConf()
public long getUsedBytes()
public long getUserOwnBytes(long userId)
public String getUserTempFilePath(long userId, long blockId)
userId
- Id of the userblockId
- Id of the blockpublic TachyonURI getUserTempPath()
public String getUserTempPath(long userId)
userId
- Id of the userpublic void initailize() throws IOException
IOException
public boolean isBlockLocked(long blockId)
blockId
- Id of the blockpublic boolean lockBlock(long blockId, long userId)
blockId
- Id of the blockuserId
- Id of the userpublic boolean moveBlock(long blockId, StorageDir dstDir) throws IOException
blockId
- the id of the blockdstDir
- the destination StorageDirIOException
public boolean requestSpace(long userId, long size)
userId
- Id of the usersize
- request size in bytespublic void returnSpace(long userId, long size)
userId
- Id of the usersize
- size to return in bytespublic boolean unlockBlock(long blockId, long userId)
blockId
- Id of the blockuserId
- Id of the userpublic void updateTempBlockAllocatedBytes(long userId, long blockId, long sizeBytes)
userId
- Id of the userblockId
- Id of the blocksizeBytes
- updated space size in bytesCopyright © 2015. All Rights Reserved.