Search in sources :

Example 16 with FileSystemMaster

use of alluxio.master.file.FileSystemMaster in project alluxio by Alluxio.

the class ClusterInitializationIntegrationTest method recoverClusterSuccess.

/**
 * When a user starts a cluster with journal logs, which are generated by previous running
 * cluster owned by the same user, it should succeed.
 */
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.SECURITY_LOGIN_USERNAME, SUPER_USER })
public void recoverClusterSuccess() throws Exception {
    FileSystem fs = mLocalAlluxioClusterResource.get().getClient();
    fs.createFile(new AlluxioURI("/testFile")).close();
    mLocalAlluxioClusterResource.get().stopFS();
    // user alluxio can recover master from journal
    try (FsMasterResource masterResource = MasterTestUtils.createLeaderFileSystemMasterFromJournal()) {
        FileSystemMaster fileSystemMaster = masterResource.getRegistry().get(FileSystemMaster.class);
        AuthenticatedClientUser.set(SUPER_USER);
        assertEquals(SUPER_USER, fileSystemMaster.getFileInfo(new AlluxioURI("/testFile"), GetStatusContext.defaults()).getOwner());
    }
}
Also used : FileSystem(alluxio.client.file.FileSystem) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest)

Example 17 with FileSystemMaster

use of alluxio.master.file.FileSystemMaster in project alluxio by Alluxio.

the class UfsJournalIntegrationTest method aclTestUtil.

private void aclTestUtil(URIStatus status, String user) throws Exception {
    try (FsMasterResource masterResource = createFsMasterFromJournal()) {
        FileSystemMaster fsMaster = masterResource.getRegistry().get(FileSystemMaster.class);
        AuthenticatedClientUser.set(user);
        FileInfo info = fsMaster.getFileInfo(new AlluxioURI("/file"), GetStatusContext.defaults());
        Assert.assertEquals(status, new URIStatus(info.setMountId(status.getMountId())));
    }
}
Also used : FileInfo(alluxio.wire.FileInfo) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI)

Example 18 with FileSystemMaster

use of alluxio.master.file.FileSystemMaster in project alluxio by Alluxio.

the class UfsJournalIntegrationTest method multiEditLogTestUtil.

private void multiEditLogTestUtil() throws Exception {
    try (FsMasterResource masterResource = createFsMasterFromJournal()) {
        FileSystemMaster fsMaster = masterResource.getRegistry().get(FileSystemMaster.class);
        long rootId = fsMaster.getFileId(mRootUri);
        Assert.assertTrue(rootId != IdUtils.INVALID_FILE_ID);
        Assert.assertEquals(124, fsMaster.listStatus(mRootUri, ListStatusContext.mergeFrom(ListStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER))).size());
        for (int k = 0; k < 124; k++) {
            Assert.assertTrue(fsMaster.getFileId(new AlluxioURI("/a" + k)) != IdUtils.INVALID_FILE_ID);
        }
    }
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) AlluxioURI(alluxio.AlluxioURI)

Example 19 with FileSystemMaster

use of alluxio.master.file.FileSystemMaster in project alluxio by Alluxio.

the class UfsJournalIntegrationTest method pinTestUtil.

private void pinTestUtil(URIStatus directory, URIStatus file0, URIStatus file1) throws Exception {
    try (FsMasterResource masterResource = createFsMasterFromJournal()) {
        FileSystemMaster fsMaster = masterResource.getRegistry().get(FileSystemMaster.class);
        FileInfo info = fsMaster.getFileInfo(fsMaster.getFileId(new AlluxioURI("/myFolder")));
        Assert.assertEquals(directory, new URIStatus(info.setMountId(directory.getMountId())));
        Assert.assertTrue(info.isPinned());
        info = fsMaster.getFileInfo(fsMaster.getFileId(new AlluxioURI("/myFolder/file0")));
        Assert.assertEquals(file0, new URIStatus(info.setMountId(file0.getMountId())));
        Assert.assertFalse(info.isPinned());
        info = fsMaster.getFileInfo(fsMaster.getFileId(new AlluxioURI("/myFolder/file1")));
        Assert.assertEquals(file1, new URIStatus(info.setMountId(file1.getMountId())));
        Assert.assertTrue(info.isPinned());
    }
}
Also used : FileInfo(alluxio.wire.FileInfo) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI)

Example 20 with FileSystemMaster

use of alluxio.master.file.FileSystemMaster in project alluxio by Alluxio.

the class UfsJournalIntegrationTest method fileDirectoryTestUtil.

private void fileDirectoryTestUtil() throws Exception {
    try (FsMasterResource masterResource = createFsMasterFromJournal()) {
        FileSystemMaster fsMaster = masterResource.getRegistry().get(FileSystemMaster.class);
        long rootId = fsMaster.getFileId(mRootUri);
        Assert.assertTrue(rootId != IdUtils.INVALID_FILE_ID);
        Assert.assertEquals(10, fsMaster.listStatus(mRootUri, ListStatusContext.mergeFrom(ListStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER))).size());
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                Assert.assertTrue(fsMaster.getFileId(new AlluxioURI("/i" + i + "/j" + j)) != IdUtils.INVALID_FILE_ID);
            }
        }
    }
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) AlluxioURI(alluxio.AlluxioURI)

Aggregations

FileSystemMaster (alluxio.master.file.FileSystemMaster)61 AlluxioURI (alluxio.AlluxioURI)43 Test (org.junit.Test)27 FsMasterResource (alluxio.testutils.master.FsMasterResource)22 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)16 FileInfo (alluxio.wire.FileInfo)13 URIStatus (alluxio.client.file.URIStatus)10 OperationId (alluxio.wire.OperationId)5 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)4 UnderFileSystemSpy (alluxio.UnderFileSystemSpy)3 BlockMaster (alluxio.master.block.BlockMaster)3 MountPointInfo (alluxio.wire.MountPointInfo)3 FileSystem (alluxio.client.file.FileSystem)2 AccessControlException (alluxio.exception.AccessControlException)2 DefaultFileSystemMaster (alluxio.master.file.DefaultFileSystemMaster)2 PersistJob (alluxio.master.file.PersistJob)2 DeleteContext (alluxio.master.file.contexts.DeleteContext)2 JournalFactory (alluxio.master.journal.JournalFactory)2 Mode (alluxio.security.authorization.Mode)2 ExponentialTimer (alluxio.time.ExponentialTimer)2