Search in sources :

Example 6 with MutableInodeFile

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

the class InodeStoreTest method addRemoveAddList.

@Test
public void addRemoveAddList() {
    writeInode(mRoot);
    for (int i = 1; i < 10; i++) {
        MutableInodeFile file = inodeFile(i, 0, "file" + i);
        writeInode(file);
        writeEdge(mRoot, file);
    }
    assertEquals(9, Iterables.size(mStore.getChildren(mRoot)));
    for (Inode child : mStore.getChildren(mRoot)) {
        MutableInode<?> childMut = mStore.getMutable(child.getId()).get();
        removeParentEdge(childMut);
        removeInode(childMut);
    }
    for (int i = 1; i < 10; i++) {
        MutableInodeFile file = inodeFile(i, 0, "file" + i);
        writeInode(file);
        writeEdge(mRoot, file);
    }
    assertEquals(9, Iterables.size(mStore.getChildren(mRoot)));
}
Also used : MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) MutableInode(alluxio.master.file.meta.MutableInode) Inode(alluxio.master.file.meta.Inode) Test(org.junit.Test)

Example 7 with MutableInodeFile

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

the class CachingInodeStoreMockedBackingStoreTest method eviction.

@Test
public void eviction() {
    for (int id = 100; id < 100 + CACHE_SIZE * 2; id++) {
        MutableInodeFile child = MutableInodeFile.create(id, TEST_INODE_ID, "child" + id, 0, CreateFileContext.defaults());
        mStore.writeNewInode(child);
        mStore.addChild(TEST_INODE_ID, child);
    }
    for (int id = 100; id < 100 + CACHE_SIZE * 2; id++) {
        assertTrue(mStore.getChild(TEST_INODE_DIR, "child" + id).isPresent());
    }
    verify(mBackingStore, Mockito.atLeastOnce()).getMutable(anyLong(), any(ReadOption.class));
}
Also used : MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) ReadOption(alluxio.master.metastore.ReadOption) Test(org.junit.Test)

Example 8 with MutableInodeFile

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

the class CachingInodeStoreMockedBackingStoreTest method cacheGetChild.

@Test
public void cacheGetChild() {
    MutableInodeFile child = MutableInodeFile.create(0, TEST_INODE_ID, "child", 0, CreateFileContext.defaults());
    mStore.writeInode(child);
    mStore.addChild(TEST_INODE_ID, child);
    for (int i = 0; i < 10; i++) {
        assertTrue(mStore.getChild(TEST_INODE_DIR, "child").isPresent());
    }
    verifyNoBackingStoreReads();
}
Also used : MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) Test(org.junit.Test)

Example 9 with MutableInodeFile

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

the class CachingInodeStoreMockedBackingStoreTest method cacheGetChildrenInodeLookups.

@Test
public void cacheGetChildrenInodeLookups() {
    List<Inode> children = new ArrayList<>();
    for (int id = 100; id < 110; id++) {
        MutableInodeFile child = MutableInodeFile.create(id, TEST_INODE_ID, "child" + id, 0, CreateFileContext.defaults());
        children.add(Inode.wrap(child));
        mStore.writeNewInode(child);
        mStore.addChild(TEST_INODE_ID, child);
    }
    assertEquals(10, Iterables.size(mStore.getChildren(TEST_INODE_DIR)));
    verifyNoBackingStoreReads();
}
Also used : MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) Inode(alluxio.master.file.meta.Inode) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 10 with MutableInodeFile

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

the class InodeStoreTest method batchWrite.

@Test
public void batchWrite() {
    assumeTrue(mStore.supportsBatchWrite());
    WriteBatch batch = mStore.createWriteBatch();
    MutableInodeFile child = inodeFile(1, 0, "child");
    batch.writeInode(child);
    batch.addChild(mRoot.getId(), child.getName(), child.getId());
    batch.commit();
    assertEquals(Inode.wrap(child), mStore.get(child.getId()).get());
    assertEquals(Inode.wrap(child), mStore.getChild(mRoot.getId(), child.getName()).get());
    batch = mStore.createWriteBatch();
    batch.removeInode(child.getId());
    batch.removeChild(mRoot.getId(), child.getName());
    batch.commit();
    assertEquals(Optional.empty(), mStore.get(child.getId()));
    assertEquals(Optional.empty(), mStore.getChild(mRoot.getId(), child.getName()));
}
Also used : MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) WriteBatch(alluxio.master.metastore.InodeStore.WriteBatch) 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