Search in sources :

Example 11 with FileSystemContext

use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.

the class FileSystemReadonlyIntegrationTest method before.

@Before
public void before() throws Exception {
    FileSystemContext fsCtx = FileSystemContext.create(ServerConfiguration.global());
    fsCtx.getClientContext().loadConf(fsCtx.getMasterAddress(), true, true);
    mFileSystem = sLocalAlluxioClusterResource.get().getClient(fsCtx);
}
Also used : FileSystemContext(alluxio.client.file.FileSystemContext) Before(org.junit.Before)

Example 12 with FileSystemContext

use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.

the class FileSystemContextReinitIntegrationTest method blockWorkerClientReinit.

@Test
public void blockWorkerClientReinit() throws Exception {
    FileSystemContext fsContext = FileSystemContext.create(ServerConfiguration.global());
    try (CloseableResource<BlockWorkerClient> client = fsContext.acquireBlockWorkerClient(mLocalAlluxioClusterResource.get().getWorkerAddress())) {
        fsContext.reinit(true, true);
        fsContext.acquireBlockWorkerClient(mLocalAlluxioClusterResource.get().getWorkerAddress()).close();
    }
}
Also used : FileSystemContext(alluxio.client.file.FileSystemContext) BlockWorkerClient(alluxio.client.block.stream.BlockWorkerClient) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 13 with FileSystemContext

use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.

the class ImpersonationIntegrationTest method impersonationArbitraryUserDisallowed.

@Test
@LocalAlluxioClusterResource.Config(confParams = { IMPERSONATION_GROUPS_CONFIG, "*" })
public void impersonationArbitraryUserDisallowed() throws Exception {
    String arbitraryUser = "arbitrary_user";
    ServerConfiguration.set(PropertyKey.SECURITY_LOGIN_IMPERSONATION_USERNAME, arbitraryUser);
    FileSystemContext context = FileSystemContext.create(createHdfsSubject(), ServerConfiguration.global());
    FileSystem fs = mLocalAlluxioClusterResource.get().getClient(context);
    fs.createFile(new AlluxioURI("/impersonation-test")).close();
    List<URIStatus> listing = fs.listStatus(new AlluxioURI("/"));
    Assert.assertEquals(1, listing.size());
    URIStatus status = listing.get(0);
    Assert.assertNotEquals(arbitraryUser, status.getOwner());
}
Also used : FileSystem(alluxio.client.file.FileSystem) FileSystemContext(alluxio.client.file.FileSystemContext) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 14 with FileSystemContext

use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.

the class LineageFileOutStreamTest method persistHandledByMaster.

@Test
public void persistHandledByMaster() throws Exception {
    FileSystemContext context = PowerMockito.mock(FileSystemContext.class);
    FileSystemMasterClient client = PowerMockito.mock(FileSystemMasterClient.class);
    Mockito.when(context.acquireMasterClientResource()).thenReturn(new DummyCloseableResource<>(client));
    LineageFileOutStream stream = new LineageFileOutStream(context, new AlluxioURI("/path"), OutStreamOptions.defaults().setWriteType(WriteType.ASYNC_THROUGH));
    stream.close();
    // The lineage file out stream doesn't manage asynchronous persistence.
    Mockito.verify(client, Mockito.times(0)).scheduleAsyncPersist(new AlluxioURI("/path"));
}
Also used : FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) FileSystemContext(alluxio.client.file.FileSystemContext) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 15 with FileSystemContext

use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.

the class LineageFileSystemTest method before.

/**
   * Sets up all dependencies before running a test.
   */
@Before
public void before() throws Exception {
    mLineageMasterClient = PowerMockito.mock(LineageMasterClient.class);
    mLineageContext = PowerMockito.mock(LineageContext.class);
    FileSystemContext fileSystemContext = PowerMockito.mock(FileSystemContext.class);
    Mockito.when(mLineageContext.acquireMasterClient()).thenReturn(mLineageMasterClient);
    FileSystemMasterClient fileSystemMasterClient = PowerMockito.mock(FileSystemMasterClient.class);
    Mockito.when(fileSystemContext.acquireMasterClient()).thenReturn(fileSystemMasterClient);
    Mockito.when(fileSystemMasterClient.getStatus(Mockito.any(AlluxioURI.class))).thenReturn(new URIStatus(new FileInfo()));
    mAlluxioLineageFileSystem = LineageFileSystem.get(fileSystemContext, mLineageContext);
}
Also used : FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) FileInfo(alluxio.wire.FileInfo) FileSystemContext(alluxio.client.file.FileSystemContext) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Before(org.junit.Before)

Aggregations

FileSystemContext (alluxio.client.file.FileSystemContext)28 AlluxioURI (alluxio.AlluxioURI)11 Test (org.junit.Test)9 URIStatus (alluxio.client.file.URIStatus)8 InstancedConfiguration (alluxio.conf.InstancedConfiguration)8 FileSystem (alluxio.client.file.FileSystem)7 WorkerNetAddress (alluxio.wire.WorkerNetAddress)7 IOException (java.io.IOException)7 Before (org.junit.Before)7 AlluxioBlockStore (alluxio.client.block.AlluxioBlockStore)5 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)5 FileSystemMasterClient (alluxio.client.file.FileSystemMasterClient)5 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)5 BlockInfo (alluxio.wire.BlockInfo)5 FileBlockInfo (alluxio.wire.FileBlockInfo)5 ClientContext (alluxio.ClientContext)4 InStreamOptions (alluxio.client.file.options.InStreamOptions)4 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)4 OpenFilePOptions (alluxio.grpc.OpenFilePOptions)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4