Search in sources :

Example 1 with NoopUfsAbsentPathCache

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);
}
Also used : NoopUfsAbsentPathCache(alluxio.master.file.meta.NoopUfsAbsentPathCache) LocalUnderFileSystem(alluxio.underfs.local.LocalUnderFileSystem) MountInfo(alluxio.master.file.meta.options.MountInfo) MountTable(alluxio.master.file.meta.MountTable) AlluxioURI(alluxio.AlluxioURI) Before(org.junit.Before)

Example 2 with NoopUfsAbsentPathCache

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()));
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) NoopUfsAbsentPathCache(alluxio.master.file.meta.NoopUfsAbsentPathCache) ExecutorService(java.util.concurrent.ExecutorService) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) MountTable(alluxio.master.file.meta.MountTable) ReentrantLock(java.util.concurrent.locks.ReentrantLock) Lock(java.util.concurrent.locks.Lock) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 3 with NoopUfsAbsentPathCache

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));
}
Also used : NoopUfsAbsentPathCache(alluxio.master.file.meta.NoopUfsAbsentPathCache) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

AlluxioURI (alluxio.AlluxioURI)3 NoopUfsAbsentPathCache (alluxio.master.file.meta.NoopUfsAbsentPathCache)3 MountTable (alluxio.master.file.meta.MountTable)2 Test (org.junit.Test)2 MountInfo (alluxio.master.file.meta.options.MountInfo)1 LocalUnderFileSystem (alluxio.underfs.local.LocalUnderFileSystem)1 ExecutorService (java.util.concurrent.ExecutorService)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 Lock (java.util.concurrent.locks.Lock)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 Before (org.junit.Before)1