use of alluxio.master.file.meta.MutableInodeDirectory in project alluxio by Alluxio.
the class CachingInodeStoreMockedBackingStoreTest method reflectWrite.
@Test
public void reflectWrite() {
MutableInodeDirectory updated = MutableInodeDirectory.create(TEST_INODE_ID, 10, "newName", CreateDirectoryContext.defaults());
mStore.writeInode(updated);
assertEquals("newName", mStore.get(TEST_INODE_ID).get().getName());
}
use of alluxio.master.file.meta.MutableInodeDirectory in project alluxio by Alluxio.
the class InodeStoreTest method manyOperations.
@Test
public void manyOperations() {
writeInode(mRoot);
MutableInodeDirectory curr = mRoot;
List<Long> fileIds = new ArrayList<>();
long numDirs = 100;
// Create 100 nested directories, each containing a file.
for (int i = 1; i < numDirs; i++) {
MutableInodeDirectory dir = inodeDir(i, curr.getId(), "dir" + i);
MutableInodeFile file = inodeFile(i + 1000, i, "file" + i);
fileIds.add(file.getId());
writeInode(dir);
writeInode(file);
writeEdge(curr, dir);
writeEdge(dir, file);
curr = dir;
}
// Check presence and delete files.
for (int i = 0; i < numDirs; i++) {
assertTrue(mStore.get(i).isPresent());
}
for (Long i : fileIds) {
assertTrue(mStore.get(i).isPresent());
Inode inode = mStore.get(i).get();
removeInode(inode);
removeParentEdge(inode);
assertFalse(mStore.get(i).isPresent());
assertFalse(mStore.getChild(inode.getParentId(), inode.getName()).isPresent());
}
long middleDir = numDirs / 2;
// Rename a directory
MutableInodeDirectory dir = mStore.getMutable(middleDir).get().asDirectory();
removeParentEdge(dir);
writeEdge(mRoot, dir);
dir.setParentId(mRoot.getId());
writeInode(dir);
Optional<Inode> renamed = mStore.getChild(mRoot, dir.getName());
assertTrue(renamed.isPresent());
assertTrue(mStore.getChild(renamed.get().asDirectory(), "dir" + (middleDir + 1)).isPresent());
assertEquals(0, Iterables.size(mStore.getChildren(mStore.get(middleDir - 1).get().asDirectory())));
}
Aggregations