use of alluxio.master.file.meta.NoopUfsAbsentPathCache in project alluxio by Alluxio.
the class UfsStatusCacheTest method before.
@Before
public void before() throws Exception {
mUfsUri = mTempDir.newFolder().getAbsolutePath();
mUfs = new LocalUnderFileSystem(new AlluxioURI(mUfsUri), UnderFileSystemConfiguration.defaults(ServerConfiguration.global()));
mService = Executors.newSingleThreadExecutor();
mCache = new UfsStatusCache(mService, new NoopUfsAbsentPathCache(), UfsAbsentPathCache.ALWAYS);
MountInfo rootMountInfo = new MountInfo(new AlluxioURI(MountTable.ROOT), new AlluxioURI(mUfsUri), IdUtils.ROOT_MOUNT_ID, MountPOptions.newBuilder().setReadOnly(false).setShared(false).build());
MasterUfsManager manager = new MasterUfsManager();
// add root mount
manager.getRoot();
mMountTable = new MountTable(manager, rootMountInfo);
}
use of alluxio.master.file.meta.NoopUfsAbsentPathCache in project alluxio by Alluxio.
the class UfsStatusCacheTest method testRejectedExecution.
@Test
public void testRejectedExecution() throws Exception {
createUfsDirs("dir0/dir1");
ExecutorService executor = new ThreadPoolExecutor(1, 1, 1, TimeUnit.MINUTES, new SynchronousQueue<>());
mCache = new UfsStatusCache(executor, new NoopUfsAbsentPathCache(), UfsAbsentPathCache.ALWAYS);
mCache = Mockito.spy(mCache);
Lock l = new ReentrantLock();
l.lock();
doAnswer((invocation) -> {
try {
l.lock();
return invocation.callRealMethod();
} finally {
l.unlock();
}
}).when(mCache).getChildrenIfAbsent(any(AlluxioURI.class), any(MountTable.class));
assertNotNull(mCache.prefetchChildren(new AlluxioURI("/dir0"), mMountTable));
// rejected
assertNull(mCache.prefetchChildren(new AlluxioURI("/dir0"), mMountTable));
// rejected
assertNull(mCache.prefetchChildren(new AlluxioURI("/dir0"), mMountTable));
// rejected
assertNull(mCache.prefetchChildren(new AlluxioURI("/dir0"), mMountTable));
// rejected
assertNull(mCache.prefetchChildren(new AlluxioURI("/dir0"), mMountTable));
l.unlock();
Collection<UfsStatus> statuses = mCache.fetchChildrenIfAbsent(null, new AlluxioURI("/dir0"), mMountTable, false);
assertEquals(1, statuses.size());
statuses.forEach(s -> assertEquals("dir1", s.getName()));
}
use of alluxio.master.file.meta.NoopUfsAbsentPathCache in project alluxio by Alluxio.
the class UfsStatusCacheTest method testNullExecutor.
@Test
public void testNullExecutor() throws Exception {
createUfsDirs("dir0/dir0");
mCache = new UfsStatusCache(null, new NoopUfsAbsentPathCache(), UfsAbsentPathCache.ALWAYS);
mCache.prefetchChildren(new AlluxioURI("/dir0"), mMountTable);
assertNull(mCache.fetchChildrenIfAbsent(null, new AlluxioURI("/dir0"), mMountTable, false));
}
Aggregations