Search in sources :

Example 6 with MutableInodeDirectory

use of alluxio.master.file.meta.MutableInodeDirectory in project alluxio by Alluxio.

the class CachingInodeStoreMockedBackingStoreTest method createInodeDir.

private MutableInodeDirectory createInodeDir(long id, long parentId) {
    MutableInodeDirectory dir = MutableInodeDirectory.create(id, parentId, Long.toString(id), CreateDirectoryContext.defaults());
    mStore.writeNewInode(dir);
    return dir;
}
Also used : MutableInodeDirectory(alluxio.master.file.meta.MutableInodeDirectory)

Example 7 with MutableInodeDirectory

use of alluxio.master.file.meta.MutableInodeDirectory in project alluxio by Alluxio.

the class InodeStoreTest method updateInode.

@Test
public void updateInode() {
    writeInode(mRoot);
    MutableInodeDirectory mutableRoot = mStore.getMutable(mRoot.getId()).get().asDirectory();
    mutableRoot.setLastModificationTimeMs(163, true);
    writeInode(mutableRoot);
    assertEquals(163, mStore.get(mRoot.getId()).get().getLastModificationTimeMs());
}
Also used : MutableInodeDirectory(alluxio.master.file.meta.MutableInodeDirectory) Test(org.junit.Test)

Example 8 with MutableInodeDirectory

use of alluxio.master.file.meta.MutableInodeDirectory in project alluxio by Alluxio.

the class InodeStoreTest method repeatedAddRemoveAndList.

@Test
public void repeatedAddRemoveAndList() {
    MutableInodeFile child = inodeFile(1, 0, "child");
    writeInode(mRoot);
    writeInode(child);
    writeEdge(mRoot, child);
    for (int i = 0; i < 3; i++) {
        removeParentEdge(child);
        writeEdge(mRoot, child);
    }
    List<MutableInodeDirectory> dirs = new ArrayList<>();
    for (int i = 5; i < 5 + CACHE_SIZE; i++) {
        String childName = "child" + i;
        MutableInodeDirectory dir = inodeDir(i, 0, childName);
        dirs.add(dir);
        writeInode(dir);
        writeEdge(mRoot, dir);
        mStore.getChild(mRoot, childName);
    }
    for (MutableInodeDirectory dir : dirs) {
        removeParentEdge(dir);
    }
    assertEquals(1, Iterables.size(mStore.getChildren(mRoot)));
}
Also used : MutableInodeDirectory(alluxio.master.file.meta.MutableInodeDirectory) MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with MutableInodeDirectory

use of alluxio.master.file.meta.MutableInodeDirectory in project alluxio by Alluxio.

the class InodeStoreBench method writeInode.

private static void writeInode() {
    int id = NEXT_INODE_ID.getAndIncrement();
    CreateDirectoryContext createContext = CreateDirectoryContext.defaults();
    MutableInodeDirectory dir = MutableInodeDirectory.create(id, 0, CommonUtils.randomAlphaNumString(30), createContext);
    sStore.writeInode(dir);
}
Also used : MutableInodeDirectory(alluxio.master.file.meta.MutableInodeDirectory) CreateDirectoryContext(alluxio.master.file.contexts.CreateDirectoryContext)

Example 10 with MutableInodeDirectory

use of alluxio.master.file.meta.MutableInodeDirectory in project alluxio by Alluxio.

the class CachingInodeStoreMockedBackingStoreTest method backupRestore.

@Test
public void backupRestore() throws Exception {
    MutableInodeDirectory child = createInodeDir(10, 0);
    mStore.writeNewInode(child);
    mStore.addChild(0, child);
    mStore.writeInode(MutableInodeDirectory.create(1, 1, "blah", CreateDirectoryContext.defaults()));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    mStore.writeToCheckpoint(baos);
    mStore.restoreFromCheckpoint(new CheckpointInputStream(new ByteArrayInputStream(baos.toByteArray())));
    assertEquals(child.getName(), mStore.get(child.getId()).get().getName());
    assertEquals(child.getId(), mStore.getChild(0L, child.getName()).get().getId());
}
Also used : MutableInodeDirectory(alluxio.master.file.meta.MutableInodeDirectory) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CheckpointInputStream(alluxio.master.journal.checkpoint.CheckpointInputStream) 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