public class MasterInfo extends ImageWriter
Modifier and Type | Class and Description |
---|---|
class |
MasterInfo.MasterInfoHeartbeatExecutor
Master info periodical status check.
|
class |
MasterInfo.RecomputationScheduler |
Constructor and Description |
---|
MasterInfo(InetSocketAddress address,
Journal journal) |
Modifier and Type | Method and Description |
---|---|
ClientRawTableInfo |
_getClientRawTableInfo(String path,
Inode inode)
Get the raw table info associated with the given id.
|
boolean |
_rename(int fileId,
String dstPath)
Rename a file to the given path, inner method.
|
boolean |
addCheckpoint(long workerId,
int fileId,
long length,
String checkpointPath)
Add a checkpoint to a file.
|
int |
cacheBlock(long workerId,
long workerUsedBytes,
long blockId,
long length)
A worker cache a block in its memory.
|
void |
completeFile(int fileId)
Completes the checkpointing of a file.
|
int |
createDependency(List<String> parents,
List<String> children,
String commandPrefix,
List<ByteBuffer> data,
String comment,
String framework,
String frameworkVersion,
DependencyType dependencyType) |
int |
createFile(boolean recursive,
String path,
boolean directory,
long blockSizeByte)
Create a file.
|
int |
createFile(String path,
long blockSizeByte) |
long |
createNewBlock(int fileId)
Creates a new block for the given file.
|
int |
createRawTable(String path,
int columns,
ByteBuffer metadata)
Creates a raw table.
|
boolean |
delete(int fileId,
boolean recursive)
Delete a file based on the file's ID.
|
boolean |
delete(String path,
boolean recursive)
Delete files based on the path.
|
long |
getBlockIdBasedOnOffset(int fileId,
long offset) |
List<BlockInfo> |
getBlockList(String path)
Get the list of blocks of an InodeFile determined by path.
|
long |
getCapacityBytes()
Get the capacity of the whole system.
|
ClientBlockInfo |
getClientBlockInfo(long blockId)
Get the block info associated with the given id.
|
ClientDependencyInfo |
getClientDependencyInfo(int dependencyId)
Get the dependency info associated with the given id.
|
ClientFileInfo |
getClientFileInfo(int fid)
Get the file info associated with the given id.
|
ClientFileInfo |
getClientFileInfo(String path)
Get the file info for the file at the given path
|
ClientRawTableInfo |
getClientRawTableInfo(int id)
Get the raw table info associated with the given id.
|
ClientRawTableInfo |
getClientRawTableInfo(String path)
Get the raw table info for the table at the given path
|
int |
getFileId(String path)
Get the file id of the file.
|
List<ClientBlockInfo> |
getFileLocations(int fileId)
Get the block infos of a file with the given id.
|
List<ClientBlockInfo> |
getFileLocations(String path)
Get the block infos of a file with the given path.
|
List<ClientFileInfo> |
getFilesInfo(String path)
If the
path is a directory, return all the direct entries in
it. |
List<String> |
getInMemoryFiles()
Get absolute paths of all in memory files.
|
Journal |
getJournal()
Get Journal instance for MasterInfo for Unit test only
|
InetSocketAddress |
getMasterAddress()
Get the master address.
|
long |
getNewUserId()
Get a new user id
|
int |
getNumberOfFiles(String path)
Get the number of files at a given path.
|
String |
getPath(int fileId)
Get the path of a file with the given id
|
List<Integer> |
getPinIdList()
Get a list of the pin id's.
|
List<Integer> |
getPriorityDependencyList()
Creates a list of high priority dependencies, which don't yet have checkpoints.
|
int |
getRawTableId(String path)
Get the id of the table at the given path.
|
long |
getStarttimeMs()
Get the master start time in milliseconds.
|
long |
getUnderFsCapacityBytes()
Get the capacity of the under file system.
|
long |
getUnderFsFreeBytes()
Get the amount of free space in the under file system.
|
long |
getUnderFsUsedBytes()
Get the amount of space used in the under file system.
|
long |
getUsedBytes()
Get the amount of space used by the workers.
|
List<String> |
getWhiteList()
Get the white list.
|
NetAddress |
getWorker(boolean random,
String host)
Get the address of a worker.
|
int |
getWorkerCount()
Get the number of workers.
|
List<ClientWorkerInfo> |
getWorkersInfo()
Get info about all the workers.
|
void |
init() |
List<Integer> |
listFiles(String path,
boolean recursive)
Get the id of the file at the given path.
|
void |
loadImage(com.fasterxml.jackson.core.JsonParser parser,
String path)
Load the image from
parser , which is created based on the path . |
List<String> |
ls(String path,
boolean recursive)
Get the names of the sub-directories at the given path.
|
boolean |
mkdir(String path)
Create a directory at the given path.
|
long |
registerWorker(NetAddress workerNetAddress,
long totalBytes,
long usedBytes,
List<Long> currentBlockIds)
Register a worker at the given address, setting it up and associating it with a given list of
blocks.
|
boolean |
rename(int fileId,
String dstPath)
Rename a file to the given path.
|
boolean |
rename(String srcPath,
String dstPath)
Rename a file to the given path.
|
void |
reportLostFile(int fileId)
Logs a lost file and sets it to be recovered.
|
void |
requestFilesInDependency(int depId)
Request that the files for the given dependency be recomputed.
|
void |
setPinned(int fileId,
boolean pinned)
Sets the isPinned flag on the given inode and all of its children.
|
void |
stop()
Stops the heartbeat thread.
|
void |
updateRawTableMetadata(int tableId,
ByteBuffer metadata)
Update the metadata of a table.
|
Command |
workerHeartbeat(long workerId,
long usedBytes,
List<Long> removedBlockIds)
The heartbeat of the worker.
|
void |
writeImage(com.fasterxml.jackson.databind.ObjectWriter objWriter,
DataOutputStream dos)
Create an image of the dependencies and filesystem tree.
|
writeElement
public static final String COL
public MasterInfo(InetSocketAddress address, Journal journal) throws IOException
IOException
public ClientRawTableInfo _getClientRawTableInfo(String path, Inode inode) throws TableDoesNotExistException
path
- The path of the tableinode
- The inode at the pathTableDoesNotExistException
public boolean _rename(int fileId, String dstPath) throws FileDoesNotExistException, InvalidPathException
fileId
- The id of the file to renamedstPath
- The new path of the fileFileDoesNotExistException
- If the id doesn't point to an inodeInvalidPathException
- if the source path is a prefix of the destinationpublic boolean addCheckpoint(long workerId, int fileId, long length, String checkpointPath) throws FileNotFoundException, SuspectedFileSizeException, BlockInfoException
workerId
- The worker which submitted the request. -1 if the request is not from a worker.fileId
- The file to add the checkpoint.length
- The length of the checkpoint.checkpointPath
- The path of the checkpoint.FileNotFoundException
SuspectedFileSizeException
BlockInfoException
public int cacheBlock(long workerId, long workerUsedBytes, long blockId, long length) throws FileDoesNotExistException, SuspectedFileSizeException, BlockInfoException
workerId
- workerUsedBytes
- blockId
- length
- FileDoesNotExistException
SuspectedFileSizeException
BlockInfoException
public void completeFile(int fileId) throws FileDoesNotExistException
fileId
- The id of the fileFileDoesNotExistException
public int createDependency(List<String> parents, List<String> children, String commandPrefix, List<ByteBuffer> data, String comment, String framework, String frameworkVersion, DependencyType dependencyType) throws InvalidPathException, FileDoesNotExistException
public int createFile(boolean recursive, String path, boolean directory, long blockSizeByte) throws FileAlreadyExistException, InvalidPathException, BlockInfoException, TachyonException
public int createFile(String path, long blockSizeByte) throws FileAlreadyExistException, InvalidPathException, BlockInfoException, TachyonException
public long createNewBlock(int fileId) throws FileDoesNotExistException
fileId
- The id of the fileFileDoesNotExistException
public int createRawTable(String path, int columns, ByteBuffer metadata) throws FileAlreadyExistException, InvalidPathException, TableColumnException, TachyonException
path
- The path to place the table atcolumns
- The number of columns in the tablemetadata
- Additional metadata about the tableFileAlreadyExistException
InvalidPathException
TableColumnException
TachyonException
public boolean delete(int fileId, boolean recursive) throws TachyonException
fileId
- the file to be deleted.recursive
- whether delete the file recursively or not.TachyonException
public boolean delete(String path, boolean recursive) throws TachyonException
path
- The file to be deleted.recursive
- whether delete the file recursively or not.TachyonException
public long getBlockIdBasedOnOffset(int fileId, long offset) throws FileDoesNotExistException
FileDoesNotExistException
public List<BlockInfo> getBlockList(String path) throws InvalidPathException, FileDoesNotExistException
path
- The file.InvalidPathException
FileDoesNotExistException
public long getCapacityBytes()
public ClientBlockInfo getClientBlockInfo(long blockId) throws FileDoesNotExistException, IOException, BlockInfoException
blockId
- The id of the block returnFileDoesNotExistException
IOException
BlockInfoException
public ClientDependencyInfo getClientDependencyInfo(int dependencyId) throws DependencyDoesNotExistException
dependencyId
- The id of the dependencyDependencyDoesNotExistException
public ClientFileInfo getClientFileInfo(int fid) throws FileDoesNotExistException, InvalidPathException
fid
- The id of the fileFileDoesNotExistException
InvalidPathException
public ClientFileInfo getClientFileInfo(String path) throws FileDoesNotExistException, InvalidPathException
path
- The path of the fileFileDoesNotExistException
InvalidPathException
public ClientRawTableInfo getClientRawTableInfo(int id) throws TableDoesNotExistException
id
- The id of the tableTableDoesNotExistException
public ClientRawTableInfo getClientRawTableInfo(String path) throws TableDoesNotExistException, InvalidPathException
path
- The path of the tableTableDoesNotExistException
InvalidPathException
public int getFileId(String path) throws InvalidPathException
path
- The path of the fileInvalidPathException
public List<ClientBlockInfo> getFileLocations(int fileId) throws FileDoesNotExistException, IOException
fileId
- The id of the file to look upFileDoesNotExistException
IOException
public List<ClientBlockInfo> getFileLocations(String path) throws FileDoesNotExistException, InvalidPathException, IOException
path
- The path of the file to look upFileDoesNotExistException
InvalidPathException
IOException
public List<ClientFileInfo> getFilesInfo(String path) throws FileDoesNotExistException, InvalidPathException
path
is a directory, return all the direct entries in
it. If the path
is a file, return its ClientFileInfo.path
- the target directory/file pathFileDoesNotExistException
InvalidPathException
public List<String> getInMemoryFiles()
public Journal getJournal()
public InetSocketAddress getMasterAddress()
public long getNewUserId()
public int getNumberOfFiles(String path) throws InvalidPathException, FileDoesNotExistException
path
- The path to look atInvalidPathException
FileDoesNotExistException
public String getPath(int fileId) throws FileDoesNotExistException
fileId
- The id of the file to look upFileDoesNotExistException
- raise if the file does not exist.public List<Integer> getPinIdList()
public List<Integer> getPriorityDependencyList()
public int getRawTableId(String path) throws InvalidPathException, TableDoesNotExistException
path
- The path of the tableInvalidPathException
TableDoesNotExistException
public long getStarttimeMs()
public long getUnderFsCapacityBytes() throws IOException
IOException
public long getUnderFsFreeBytes() throws IOException
IOException
public long getUnderFsUsedBytes() throws IOException
IOException
public long getUsedBytes()
public NetAddress getWorker(boolean random, String host)
random
- If true, select a random workerhost
- If random
is false, select a worker on this hostpublic int getWorkerCount()
public List<ClientWorkerInfo> getWorkersInfo()
public void init() throws IOException
IOException
public List<Integer> listFiles(String path, boolean recursive) throws InvalidPathException, FileDoesNotExistException
path
- The path to start looking atrecursive
- If true, recursively scan the subdirectories at the given path as wellInvalidPathException
FileDoesNotExistException
public void loadImage(com.fasterxml.jackson.core.JsonParser parser, String path) throws IOException
parser
, which is created based on the path
.
Assume this blocks the whole MasterInfo.parser
- the JsonParser to load the imagepath
- the file to load the imageIOException
public List<String> ls(String path, boolean recursive) throws InvalidPathException, FileDoesNotExistException
path
- The path to look atrecursive
- If true, recursively add the paths of the sub-directoriesInvalidPathException
FileDoesNotExistException
public boolean mkdir(String path) throws FileAlreadyExistException, InvalidPathException, TachyonException
path
- The path to create a directory atFileAlreadyExistException
InvalidPathException
TachyonException
public long registerWorker(NetAddress workerNetAddress, long totalBytes, long usedBytes, List<Long> currentBlockIds) throws BlockInfoException
workerNetAddress
- The address of the worker to registertotalBytes
- The capacity of the worker in bytesusedBytes
- The number of bytes already used in the workercurrentBlockIds
- The id's of the blocks held by the workerBlockInfoException
public boolean rename(int fileId, String dstPath) throws FileDoesNotExistException, InvalidPathException
fileId
- The id of the file to renamedstPath
- The new path of the fileFileDoesNotExistException
InvalidPathException
public boolean rename(String srcPath, String dstPath) throws FileDoesNotExistException, InvalidPathException
srcPath
- The path of the file to renamedstPath
- The new path of the fileFileDoesNotExistException
InvalidPathException
public void reportLostFile(int fileId)
fileId
- The id of the file to be recoveredpublic void requestFilesInDependency(int depId)
depId
- The dependency whose files are to be recomputedpublic void stop()
public void setPinned(int fileId, boolean pinned) throws FileDoesNotExistException
FileDoesNotExistException
public void updateRawTableMetadata(int tableId, ByteBuffer metadata) throws TableDoesNotExistException, TachyonException
tableId
- The id of the table to updatemetadata
- The new metadata to update the table withTableDoesNotExistException
TachyonException
public Command workerHeartbeat(long workerId, long usedBytes, List<Long> removedBlockIds) throws BlockInfoException
workerId
- The id of the worker to deal withusedBytes
- The number of bytes used in the workerremovedBlockIds
- The id's of the blocks that have been removedBlockInfoException
public void writeImage(com.fasterxml.jackson.databind.ObjectWriter objWriter, DataOutputStream dos) throws IOException
os
- The output stream to write the image toIOException
Copyright © 2014. All rights reserved.