use of alluxio.master.file.FileSystemMaster in project alluxio by Alluxio.
the class JournalIntegrationTest method pinTestUtil.
private void pinTestUtil(URIStatus directory, URIStatus file0, URIStatus file1) throws AccessControlException, IOException, InvalidPathException, FileDoesNotExistException {
FileSystemMaster fsMaster = createFsMasterFromJournal();
FileInfo info = fsMaster.getFileInfo(fsMaster.getFileId(new AlluxioURI("/myFolder")));
Assert.assertEquals(directory, new URIStatus(info));
Assert.assertTrue(info.isPinned());
info = fsMaster.getFileInfo(fsMaster.getFileId(new AlluxioURI("/myFolder/file0")));
Assert.assertEquals(file0, new URIStatus(info));
Assert.assertFalse(info.isPinned());
info = fsMaster.getFileInfo(fsMaster.getFileId(new AlluxioURI("/myFolder/file1")));
Assert.assertEquals(file1, new URIStatus(info));
Assert.assertTrue(info.isPinned());
fsMaster.stop();
}
use of alluxio.master.file.FileSystemMaster in project alluxio by Alluxio.
the class JournalIntegrationTest method emptyImage.
@Test
public void emptyImage() throws Exception {
Assert.assertEquals(0, mFileSystem.listStatus(mRootUri).size());
mLocalAlluxioCluster.stopFS();
FileSystemMaster fsMaster = createFsMasterFromJournal();
long rootId = fsMaster.getFileId(mRootUri);
Assert.assertTrue(rootId != IdUtils.INVALID_FILE_ID);
Assert.assertEquals(0, fsMaster.listStatus(mRootUri, ListStatusOptions.defaults().setLoadMetadataType(LoadMetadataType.Never)).size());
fsMaster.stop();
}
use of alluxio.master.file.FileSystemMaster in project alluxio by Alluxio.
the class KeyValueMasterFactory method create.
@Override
public KeyValueMaster create(List<? extends Master> masters, JournalFactory journalFactory) {
if (!isEnabled()) {
return null;
}
Preconditions.checkArgument(journalFactory != null, "journal factory may not be null");
LOG.info("Creating {} ", KeyValueMaster.class.getName());
Journal journal = journalFactory.get(getName());
for (Master master : masters) {
if (master instanceof FileSystemMaster) {
LOG.info("{} is created", KeyValueMaster.class.getName());
return new KeyValueMaster((FileSystemMaster) master, journal);
}
}
LOG.error("Fail to create {} due to missing {}", KeyValueMaster.class.getName(), FileSystemMaster.class.getName());
return null;
}
use of alluxio.master.file.FileSystemMaster in project alluxio by Alluxio.
the class ClusterInitializationTest 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();
LoginUserTestUtils.resetLoginUser(SUPER_USER);
// user alluxio can recover master from journal
FileSystemMaster fileSystemMaster = MasterTestUtils.createLeaderFileSystemMasterFromJournal();
AuthenticatedClientUser.set(SUPER_USER);
Assert.assertEquals(SUPER_USER, fileSystemMaster.getFileInfo(new AlluxioURI("/testFile")).getOwner());
}
use of alluxio.master.file.FileSystemMaster in project alluxio by Alluxio.
the class AlluxioMasterRestServiceHandlerTest method isMounted.
@Test
public void isMounted() {
String s3Uri = "s3a://test/dir_1/dir-2";
String hdfsUri = "hdfs://test";
Map<String, MountPointInfo> mountTable = new HashMap<>();
mountTable.put("/s3", new MountPointInfo().setUfsUri(s3Uri));
FileSystemMaster mockMaster = mock(FileSystemMaster.class);
when(mockMaster.getMountPointInfoSummary(false)).thenReturn(mountTable);
AlluxioMasterProcess masterProcess = mock(AlluxioMasterProcess.class);
when(masterProcess.getMaster(FileSystemMaster.class)).thenReturn(mockMaster);
ServletContext context = mock(ServletContext.class);
when(context.getAttribute(MasterWebServer.ALLUXIO_MASTER_SERVLET_RESOURCE_KEY)).thenReturn(masterProcess);
AlluxioMasterRestServiceHandler handler = new AlluxioMasterRestServiceHandler(context);
assertFalse(handler.isMounted(s3Uri));
assertTrue(handler.isMounted(MetricsSystem.escape(new AlluxioURI(s3Uri))));
assertTrue(handler.isMounted(MetricsSystem.escape(new AlluxioURI(s3Uri + "/"))));
assertFalse(handler.isMounted(hdfsUri));
assertFalse(handler.isMounted(MetricsSystem.escape(new AlluxioURI(hdfsUri))));
}
Aggregations