Search in sources :

Example 1 with WriteBatch

use of alluxio.master.metastore.InodeStore.WriteBatch in project alluxio by Alluxio.

the class RocksInodeStoreTest method batchWrite.

@Test
public void batchWrite() throws IOException {
    RocksInodeStore store = new RocksInodeStore(mFolder.newFolder().getAbsolutePath());
    WriteBatch batch = store.createWriteBatch();
    for (int i = 1; i < 20; i++) {
        batch.writeInode(MutableInodeDirectory.create(i, 0, "dir" + i, CreateDirectoryContext.defaults()));
    }
    batch.commit();
    for (int i = 1; i < 20; i++) {
        assertEquals("dir" + i, store.get(i).get().getName());
    }
}
Also used : WriteBatch(alluxio.master.metastore.InodeStore.WriteBatch) Test(org.junit.Test)

Example 2 with WriteBatch

use of alluxio.master.metastore.InodeStore.WriteBatch 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

WriteBatch (alluxio.master.metastore.InodeStore.WriteBatch)2 Test (org.junit.Test)2 MutableInodeFile (alluxio.master.file.meta.MutableInodeFile)1