use of alluxio.proto.journal.File.InodeFileEntry in project alluxio by Alluxio.
the class FileSystemMaster method processJournalEntry.
@Override
public void processJournalEntry(JournalEntry entry) throws IOException {
if (entry.hasInodeFile()) {
mInodeTree.addInodeFileFromJournal(entry.getInodeFile());
// Add the file to TTL buckets, the insert automatically rejects files w/ Constants.NO_TTL
InodeFileEntry inodeFileEntry = entry.getInodeFile();
if (inodeFileEntry.hasTtl()) {
mTtlBuckets.insert(InodeFile.fromJournalEntry(inodeFileEntry));
}
} else if (entry.hasInodeDirectory()) {
try {
// Add the directory to TTL buckets, the insert automatically rejects directory
// w/ Constants.NO_TTL
InodeDirectoryEntry inodeDirectoryEntry = entry.getInodeDirectory();
if (inodeDirectoryEntry.hasTtl()) {
mTtlBuckets.insert(InodeDirectory.fromJournalEntry(inodeDirectoryEntry));
}
mInodeTree.addInodeDirectoryFromJournal(entry.getInodeDirectory());
} catch (AccessControlException e) {
throw new RuntimeException(e);
}
} else if (entry.hasInodeLastModificationTime()) {
InodeLastModificationTimeEntry modTimeEntry = entry.getInodeLastModificationTime();
try (LockedInodePath inodePath = mInodeTree.lockFullInodePath(modTimeEntry.getId(), InodeTree.LockMode.WRITE)) {
inodePath.getInode().setLastModificationTimeMs(modTimeEntry.getLastModificationTimeMs(), true);
} catch (FileDoesNotExistException e) {
throw new RuntimeException(e);
}
} else if (entry.hasPersistDirectory()) {
PersistDirectoryEntry typedEntry = entry.getPersistDirectory();
try (LockedInodePath inodePath = mInodeTree.lockFullInodePath(typedEntry.getId(), InodeTree.LockMode.WRITE)) {
inodePath.getInode().setPersistenceState(PersistenceState.PERSISTED);
} catch (FileDoesNotExistException e) {
throw new RuntimeException(e);
}
} else if (entry.hasCompleteFile()) {
try {
completeFileFromEntry(entry.getCompleteFile());
} catch (InvalidPathException | InvalidFileSizeException | FileAlreadyCompletedException e) {
throw new RuntimeException(e);
}
} else if (entry.hasSetAttribute()) {
try {
setAttributeFromEntry(entry.getSetAttribute());
} catch (AccessControlException | FileDoesNotExistException | InvalidPathException e) {
throw new RuntimeException(e);
}
} else if (entry.hasDeleteFile()) {
deleteFromEntry(entry.getDeleteFile());
} else if (entry.hasRename()) {
renameFromEntry(entry.getRename());
} else if (entry.hasInodeDirectoryIdGenerator()) {
mDirectoryIdGenerator.initFromJournalEntry(entry.getInodeDirectoryIdGenerator());
} else if (entry.hasReinitializeFile()) {
resetBlockFileFromEntry(entry.getReinitializeFile());
} else if (entry.hasAddMountPoint()) {
try {
mountFromEntry(entry.getAddMountPoint());
} catch (FileAlreadyExistsException | InvalidPathException e) {
throw new RuntimeException(e);
}
} else if (entry.hasDeleteMountPoint()) {
try {
unmountFromEntry(entry.getDeleteMountPoint());
} catch (InvalidPathException e) {
throw new RuntimeException(e);
}
} else if (entry.hasAsyncPersistRequest()) {
try {
long fileId = (entry.getAsyncPersistRequest()).getFileId();
try (LockedInodePath inodePath = mInodeTree.lockFullInodePath(fileId, InodeTree.LockMode.WRITE)) {
scheduleAsyncPersistenceInternal(inodePath);
}
// NOTE: persistence is asynchronous so there is no guarantee the path will still exist
mAsyncPersistHandler.scheduleAsyncPersistence(getPath(fileId));
} catch (AlluxioException e) {
// It's possible that rescheduling the async persist calls fails, because the blocks may no
// longer be in the memory
LOG.error(e.getMessage());
}
} else {
throw new IOException(ExceptionMessage.UNEXPECTED_JOURNAL_ENTRY.getMessage(entry));
}
}
Aggregations