Search in sources :

Example 1 with MutableInodeFile

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

the class CachingInodeStoreMockedBackingStoreTest method cacheGetChildMany.

@Test
public void cacheGetChildMany() {
    for (long inodeId = 1; inodeId < CACHE_SIZE * 2; inodeId++) {
        MutableInodeFile child = MutableInodeFile.create(0, 0, "child" + inodeId, 0, CreateFileContext.defaults());
        mStore.writeInode(child);
        mStore.addChild(0, child);
    }
    for (int i = 0; i < 1000; i++) {
        for (long inodeId = 1; inodeId < CACHE_SIZE * 2; inodeId++) {
            assertTrue(mStore.getChild(0L, "child" + inodeId).isPresent());
        }
    }
    // The workload is read-only, so we shouldn't need to write each edge to the backing store more
    // than once.
    verify(mBackingStore, atMost((int) CACHE_SIZE * 2)).addChild(anyLong(), any(), anyLong());
}
Also used : MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) Test(org.junit.Test)

Example 2 with MutableInodeFile

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

the class ReplicationCheckerTest method createBlockHelper.

/**
 * Helper to create a file with a single block.
 *
 * @param path Alluxio path of the file
 * @param context context to create the file
 * @param pinLocation
 * @return the block ID
 */
private long createBlockHelper(AlluxioURI path, CreatePathContext<?, ?> context, String pinLocation) throws Exception {
    try (LockedInodePath inodePath = mInodeTree.lockInodePath(path, LockPattern.WRITE_EDGE)) {
        List<Inode> created = mInodeTree.createPath(RpcContext.NOOP, inodePath, context);
        if (!pinLocation.equals("")) {
            mInodeTree.setPinned(RpcContext.NOOP, inodePath, true, ImmutableList.of(pinLocation), 0);
        }
        MutableInodeFile inodeFile = mInodeStore.getMutable(created.get(0).getId()).get().asFile();
        inodeFile.setBlockSizeBytes(1);
        inodeFile.setBlockIds(Arrays.asList(inodeFile.getNewBlockId()));
        inodeFile.setCompleted(true);
        mInodeStore.writeInode(inodeFile);
        return inodeFile.getBlockIdByIndex(0);
    }
}
Also used : LockedInodePath(alluxio.master.file.meta.LockedInodePath) MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) Inode(alluxio.master.file.meta.Inode)

Example 3 with MutableInodeFile

use of alluxio.master.file.meta.MutableInodeFile 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 4 with MutableInodeFile

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

the class InodeStoreTest method getChild.

@Test
public void getChild() {
    MutableInodeFile child = inodeFile(1, 0, "child");
    writeInode(mRoot);
    writeInode(child);
    writeEdge(mRoot, child);
    assertEquals(Inode.wrap(child), mStore.getChild(mRoot, child.getName()).get());
}
Also used : MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) Test(org.junit.Test)

Example 5 with MutableInodeFile

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

the class InodeStoreTest method removeChild.

@Test
public void removeChild() {
    MutableInodeFile child = inodeFile(1, 0, "child");
    writeInode(mRoot);
    writeInode(child);
    writeEdge(mRoot, child);
    removeParentEdge(child);
    assertFalse(mStore.getChild(mRoot, child.getName()).isPresent());
}
Also used : MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) Test(org.junit.Test)

Aggregations

MutableInodeFile (alluxio.master.file.meta.MutableInodeFile)12 Test (org.junit.Test)10 Inode (alluxio.master.file.meta.Inode)4 ArrayList (java.util.ArrayList)4 MutableInode (alluxio.master.file.meta.MutableInode)2 MutableInodeDirectory (alluxio.master.file.meta.MutableInodeDirectory)2 Pair (alluxio.collections.Pair)1 InodeFile (alluxio.master.file.meta.InodeFile)1 LockedInodePath (alluxio.master.file.meta.LockedInodePath)1 WriteBatch (alluxio.master.metastore.InodeStore.WriteBatch)1 ReadOption (alluxio.master.metastore.ReadOption)1 File (alluxio.proto.journal.File)1 Journal (alluxio.proto.journal.Journal)1 HashMap (java.util.HashMap)1