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());
}
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);
}
}
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)));
}
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());
}
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());
}
Aggregations