public class InodeFile extends Inode
Constructor and Description |
---|
InodeFile(String name,
int id,
int parentId,
long blockSizeByte,
long creationTimeMs)
Create a new InodeFile.
|
Modifier and Type | Method and Description |
---|---|
void |
addBlock(BlockInfo blockInfo)
Add a block to the file.It will check the legality.
|
void |
addLocation(int blockIndex,
long workerId,
NetAddress workerAddress,
long storageDirId)
Add a location information of the file.
|
ClientFileInfo |
generateClientFileInfo(String path)
Generate a ClientFileInfo of the file or folder.
|
long |
getBlockIdBasedOnOffset(long offset)
Get the id of the specified block by the offset of the file.
|
List<Long> |
getBlockIds()
Get all the blocks of the file.
|
List<Pair<Long,Long>> |
getBlockIdWorkerIdPairs()
The pairs of the blocks and workers.
|
List<BlockInfo> |
getBlockList()
Get the block list of the file, which is not a duplication.
|
List<NetAddress> |
getBlockLocations(int blockIndex)
Get the locations of the specified block.
|
long |
getBlockSizeByte()
Get the block size of the file
|
ClientBlockInfo |
getClientBlockInfo(int blockIndex)
Get a ClientBlockInfo of the specified block.
|
List<ClientBlockInfo> |
getClientBlockInfos()
Get file's all blocks' ClientBlockInfo information.
|
int |
getDependencyId()
Get the dependency id of the file
|
long |
getLength()
Get the length of the file
|
long |
getNewBlockId()
Get the id of a new block of the file.
|
int |
getNumberOfBlocks()
Get the number of the blocks of the file
|
String |
getUfsPath()
Get the path of the file in under file system
|
boolean |
hasCheckpointed()
Return whether the file has checkpointed or not.
|
boolean |
isCache()
Return whether the file is cacheable or not.
|
boolean |
isComplete()
Return whether the file is complete or not.
|
boolean |
isFullyInMemory()
Return whether the file is fully in memory or not.
|
void |
removeLocation(int blockIndex,
long workerId)
Remove a location of a block.
|
void |
setCache(boolean cache)
Set whether the file is cacheable or not.
|
void |
setComplete()
The file is complete.
|
void |
setComplete(boolean complete)
Set the complete flag of the file
|
void |
setDependencyId(int dependencyId)
Set the dependency id of the file
|
void |
setLength(long length)
Set the length of the file.
|
void |
setUfsPath(String ufsPath)
Set the path of the file in under file system.
|
String |
toString() |
void |
writeImage(com.fasterxml.jackson.databind.ObjectWriter objWriter,
DataOutputStream dos)
Write image to the specified DataOutputStream.
|
compareTo, equals, getCreationTimeMs, getId, getLastModificationTimeMs, getName, getParentId, hashCode, isDirectory, isFile, isPinned, reverseId, setLastModificationTimeMs, setName, setParentId, setPinned
writeElement
public InodeFile(String name, int id, int parentId, long blockSizeByte, long creationTimeMs)
name
- The name of the fileid
- The id of the fileparentId
- The id of the parent of the fileblockSizeByte
- The block size of the file, in bytescreationTimeMs
- The creation time of the file, in millisecondspublic void addBlock(BlockInfo blockInfo) throws BlockInfoException
blockInfo
- The block to be addedBlockInfoException
public void addLocation(int blockIndex, long workerId, NetAddress workerAddress, long storageDirId) throws BlockInfoException
blockIndex
- The index of the block in the fileworkerId
- The id of the workerworkerAddress
- The net address of the workerstorageDirId
- The id of the StorageDir which block is located inBlockInfoException
public ClientFileInfo generateClientFileInfo(String path)
Inode
generateClientFileInfo
in class Inode
path
- The path of the filepublic long getBlockIdBasedOnOffset(long offset)
offset
- The offset of the filepublic List<Long> getBlockIds()
public List<Pair<Long,Long>> getBlockIdWorkerIdPairs()
public List<BlockInfo> getBlockList()
public List<NetAddress> getBlockLocations(int blockIndex) throws BlockInfoException
blockIndex
- The index of the block in the fileBlockInfoException
public long getBlockSizeByte()
public String getUfsPath()
public ClientBlockInfo getClientBlockInfo(int blockIndex) throws BlockInfoException
blockIndex
- The index of the block in the fileBlockInfoException
public List<ClientBlockInfo> getClientBlockInfos()
public int getDependencyId()
public long getLength()
public long getNewBlockId()
public int getNumberOfBlocks()
public boolean hasCheckpointed()
public boolean isCache()
public boolean isComplete()
public boolean isFullyInMemory()
public void removeLocation(int blockIndex, long workerId) throws BlockInfoException
blockIndex
- The index of the block in the fileworkerId
- The id of the removed location workerBlockInfoException
public void setCache(boolean cache)
cache
- If true, the file is cacheablepublic void setUfsPath(String ufsPath)
ufsPath
- The new path of the file in under file systempublic void setComplete()
public void setComplete(boolean complete)
complete
- If true, the file is completepublic void setDependencyId(int dependencyId)
dependencyId
- The new dependency id of the filepublic void setLength(long length) throws SuspectedFileSizeException, BlockInfoException
length
- The new length of the file, cannot be negativeSuspectedFileSizeException
BlockInfoException
public void writeImage(com.fasterxml.jackson.databind.ObjectWriter objWriter, DataOutputStream dos) throws IOException
ImageWriter
objWriter
- The used object writerdos
- The target data output streamIOException
Copyright © 2015. All Rights Reserved.