Search in sources :

Example 6 with Key

use of alluxio.client.file.FileSystemCache.Key in project alluxio by Alluxio.

the class FileSystemCacheTest method getThenClose.

@Test
public void getThenClose() throws IOException {
    Key key1 = createTestFSKey("user1");
    FileSystem fs1 = mFileSystemCache.get(key1);
    fs1.close();
    FileSystem fs2 = mFileSystemCache.get(key1);
    assertNotSame(getDelegatedFileSystem(fs1), getDelegatedFileSystem(fs2));
    assertTrue(fs1.isClosed());
    assertFalse(fs2.isClosed());
}
Also used : Key(alluxio.client.file.FileSystemCache.Key) Test(org.junit.Test)

Example 7 with Key

use of alluxio.client.file.FileSystemCache.Key in project alluxio by Alluxio.

the class FileSystemCacheTest method listStatusClosed.

@Test
public void listStatusClosed() throws IOException, AlluxioException {
    Exception e = assertThrows(IOException.class, () -> {
        Key key1 = createTestFSKey("user1");
        FileSystem fs1 = mFileSystemCache.get(key1);
        fs1.close();
        assertTrue(fs1.isClosed());
        fs1.listStatus(new AlluxioURI("/"));
    });
    assertTrue(e.getMessage().contains(FileSystemCache.InstanceCachingFileSystem.CLOSED_FS_ERROR_MESSAGE));
}
Also used : AlluxioException(alluxio.exception.AlluxioException) IOException(java.io.IOException) Key(alluxio.client.file.FileSystemCache.Key) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 8 with Key

use of alluxio.client.file.FileSystemCache.Key in project alluxio by Alluxio.

the class FileSystemCacheTest method getTwiceThenClose2.

@Test
public void getTwiceThenClose2() throws IOException {
    Key key1 = createTestFSKey("user1");
    FileSystem fs1 = mFileSystemCache.get(key1);
    FileSystem fs2 = mFileSystemCache.get(key1);
    assertSame(getDelegatedFileSystem(fs1), getDelegatedFileSystem(fs2));
    fs1.close();
    assertTrue(fs1.isClosed());
    assertFalse(fs2.isClosed());
    fs2.close();
    assertTrue(fs1.isClosed());
    assertTrue(fs2.isClosed());
}
Also used : Key(alluxio.client.file.FileSystemCache.Key) Test(org.junit.Test)

Aggregations

Key (alluxio.client.file.FileSystemCache.Key)8 Test (org.junit.Test)7 AlluxioURI (alluxio.AlluxioURI)1 InstancedConfiguration (alluxio.conf.InstancedConfiguration)1 AlluxioException (alluxio.exception.AlluxioException)1 User (alluxio.security.User)1 IOException (java.io.IOException)1 Principal (java.security.Principal)1 HashSet (java.util.HashSet)1 Subject (javax.security.auth.Subject)1