Search in sources :

Example 1 with Key

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

the class FileSystemCacheTest method createTestFSKey.

private Key createTestFSKey(String username) {
    User user = new User(username);
    Set<Principal> principals = new HashSet<>();
    principals.add(user);
    return new FileSystemCache.Key(new Subject(false, principals, new HashSet<>(), new HashSet<>()), new InstancedConfiguration(ConfigurationUtils.defaults()));
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) User(alluxio.security.User) Principal(java.security.Principal) Key(alluxio.client.file.FileSystemCache.Key) Subject(javax.security.auth.Subject) HashSet(java.util.HashSet)

Example 2 with Key

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

the class FileSystemCacheTest method getSameKey.

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

Example 3 with Key

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

the class FileSystemCacheTest method getTwiceThenClose.

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

Example 4 with Key

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

the class FileSystemCacheTest method doubleClose.

@Test
public void doubleClose() 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());
    fs1.close();
    assertTrue(fs1.isClosed());
    assertFalse(fs2.isClosed());
}
Also used : Key(alluxio.client.file.FileSystemCache.Key) Test(org.junit.Test)

Example 5 with Key

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

the class FileSystemCacheTest method getDifferentKeys.

@Test
public void getDifferentKeys() {
    Key key1 = createTestFSKey("user1");
    Key key2 = createTestFSKey("user2");
    FileSystem fs1 = mFileSystemCache.get(key1);
    FileSystem fs2 = mFileSystemCache.get(key2);
    assertNotSame(getDelegatedFileSystem(fs1), getDelegatedFileSystem(fs2));
    assertFalse(fs1.isClosed());
    assertFalse(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