use of alluxio.proto.journal.File.InodeLastModificationTimeEntry 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));
}
}
use of alluxio.proto.journal.File.InodeLastModificationTimeEntry in project alluxio by Alluxio.
the class FileSystemMaster method journalCreatePathResult.
/**
* Journals the {@link InodeTree.CreatePathResult}. This does not flush the journal.
* Synchronization is required outside of this method.
*
* @param createResult the {@link InodeTree.CreatePathResult} to journal
* @param journalContext the journalContext
*/
private void journalCreatePathResult(InodeTree.CreatePathResult createResult, JournalContext journalContext) {
for (Inode<?> inode : createResult.getModified()) {
InodeLastModificationTimeEntry inodeLastModificationTime = InodeLastModificationTimeEntry.newBuilder().setId(inode.getId()).setLastModificationTimeMs(inode.getLastModificationTimeMs()).build();
appendJournalEntry(JournalEntry.newBuilder().setInodeLastModificationTime(inodeLastModificationTime).build(), journalContext);
}
boolean createdDir = false;
for (Inode<?> inode : createResult.getCreated()) {
appendJournalEntry(inode.toJournalEntry(), journalContext);
if (inode.isDirectory()) {
createdDir = true;
}
}
if (createdDir) {
// At least one directory was created, so journal the state of the directory id generator.
appendJournalEntry(mDirectoryIdGenerator.toJournalEntry(), journalContext);
}
for (Inode<?> inode : createResult.getPersisted()) {
PersistDirectoryEntry persistDirectory = PersistDirectoryEntry.newBuilder().setId(inode.getId()).build();
appendJournalEntry(JournalEntry.newBuilder().setPersistDirectory(persistDirectory).build(), journalContext);
}
}
Aggregations