use of alluxio.master.file.meta.TempInodePathForChild in project alluxio by Alluxio.
the class FileSystemMaster method loadMetadataAndJournal.
/**
* Loads metadata for the object identified by the given path from UFS into Alluxio.
* <p>
* Writes to the journal.
*
* @param inodePath the path for which metadata should be loaded
* @param options the load metadata options
* @param journalContext the journal context
* @throws InvalidPathException if invalid path is encountered
* @throws FileDoesNotExistException if there is no UFS path
* @throws BlockInfoException if an invalid block size is encountered
* @throws FileAlreadyCompletedException if the file is already completed
* @throws InvalidFileSizeException if invalid file size is encountered
* @throws AccessControlException if permission checking fails
* @throws IOException if an I/O error occurs
*/
private void loadMetadataAndJournal(LockedInodePath inodePath, LoadMetadataOptions options, JournalContext journalContext) throws InvalidPathException, FileDoesNotExistException, BlockInfoException, FileAlreadyCompletedException, InvalidFileSizeException, AccessControlException, IOException {
AlluxioURI path = inodePath.getUri();
MountTable.Resolution resolution = mMountTable.resolve(path);
AlluxioURI ufsUri = resolution.getUri();
UnderFileSystem ufs = resolution.getUfs();
try {
if (options.getUnderFileStatus() == null && !ufs.exists(ufsUri.toString())) {
// uri does not exist in ufs
InodeDirectory inode = (InodeDirectory) inodePath.getInode();
inode.setDirectChildrenLoaded(true);
}
boolean isFile;
if (options.getUnderFileStatus() != null) {
isFile = options.getUnderFileStatus().isFile();
} else {
isFile = ufs.isFile(ufsUri.toString());
}
if (isFile) {
loadFileMetadataAndJournal(inodePath, resolution, options, journalContext);
} else {
loadDirectoryMetadataAndJournal(inodePath, options, journalContext);
InodeDirectory inode = (InodeDirectory) inodePath.getInode();
if (options.isLoadDirectChildren()) {
UnderFileStatus[] files = ufs.listStatus(ufsUri.toString());
for (UnderFileStatus file : files) {
if (PathUtils.isTemporaryFileName(file.getName()) || inode.getChild(file.getName()) != null) {
continue;
}
TempInodePathForChild tempInodePath = new TempInodePathForChild(inodePath, file.getName());
LoadMetadataOptions loadMetadataOptions = LoadMetadataOptions.defaults().setLoadDirectChildren(false).setCreateAncestors(false).setUnderFileStatus(file);
loadMetadataAndJournal(tempInodePath, loadMetadataOptions, journalContext);
}
inode.setDirectChildrenLoaded(true);
}
}
} catch (IOException e) {
LOG.error(ExceptionUtils.getStackTrace(e));
throw e;
}
}
Aggregations