Search in sources :

Example 11 with MutableInodeDirectory

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());
}
Also used : MutableInodeDirectory(alluxio.master.file.meta.MutableInodeDirectory) Test(org.junit.Test)

Example 12 with MutableInodeDirectory

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())));
}
Also used : MutableInodeDirectory(alluxio.master.file.meta.MutableInodeDirectory) MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) MutableInode(alluxio.master.file.meta.MutableInode) Inode(alluxio.master.file.meta.Inode) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

MutableInodeDirectory (alluxio.master.file.meta.MutableInodeDirectory)12 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)4 MutableInodeFile (alluxio.master.file.meta.MutableInodeFile)2 CreateDirectoryContext (alluxio.master.file.contexts.CreateDirectoryContext)1 Inode (alluxio.master.file.meta.Inode)1 MutableInode (alluxio.master.file.meta.MutableInode)1 CheckpointInputStream (alluxio.master.journal.checkpoint.CheckpointInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ExecutorService (java.util.concurrent.ExecutorService)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1