use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class JournalIntegrationTest method loadMetadata.
/**
* Tests loading metadata.
*/
@Test
public void loadMetadata() throws Exception {
String ufsRoot = PathUtils.concatPath(Configuration.get(PropertyKey.UNDERFS_ADDRESS));
UnderFileSystem ufs = UnderFileSystem.Factory.get(ufsRoot);
ufs.create(ufsRoot + "/xyz").close();
mFileSystem.loadMetadata(new AlluxioURI("/xyz"));
URIStatus status = mFileSystem.getStatus(new AlluxioURI("/xyz"));
mLocalAlluxioCluster.stopFS();
loadMetadataTestUtil(status);
deleteFsMasterJournalLogs();
loadMetadataTestUtil(status);
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class JournalIntegrationTest method loadMetadataTestUtil.
private void loadMetadataTestUtil(URIStatus status) throws AccessControlException, IOException, InvalidPathException, FileDoesNotExistException {
FileSystemMaster fsMaster = createFsMasterFromJournal();
long rootId = fsMaster.getFileId(mRootUri);
Assert.assertTrue(rootId != IdUtils.INVALID_FILE_ID);
Assert.assertEquals(1, fsMaster.listStatus(mRootUri, ListStatusOptions.defaults().setLoadMetadataType(LoadMetadataType.Never)).size());
Assert.assertTrue(fsMaster.getFileId(new AlluxioURI("/xyz")) != IdUtils.INVALID_FILE_ID);
FileInfo fsMasterInfo = fsMaster.getFileInfo(fsMaster.getFileId(new AlluxioURI("/xyz")));
Assert.assertEquals(status, new URIStatus(fsMasterInfo));
fsMaster.stop();
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class JournalIntegrationTest method file.
/**
* Tests file creation.
*/
@Test
public void file() throws Exception {
CreateFileOptions option = CreateFileOptions.defaults().setBlockSizeBytes(64);
AlluxioURI filePath = new AlluxioURI("/xyz");
mFileSystem.createFile(filePath, option).close();
URIStatus status = mFileSystem.getStatus(filePath);
mLocalAlluxioCluster.stopFS();
fileTestUtil(status);
deleteFsMasterJournalLogs();
fileTestUtil(status);
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class JournalIntegrationTest method directoryTestUtil.
private void directoryTestUtil(URIStatus status) throws AccessControlException, IOException, InvalidPathException, FileDoesNotExistException {
FileSystemMaster fsMaster = createFsMasterFromJournal();
long rootId = fsMaster.getFileId(mRootUri);
Assert.assertTrue(rootId != IdUtils.INVALID_FILE_ID);
Assert.assertEquals(1, fsMaster.listStatus(mRootUri, ListStatusOptions.defaults().setLoadMetadataType(LoadMetadataType.Never)).size());
long fileId = fsMaster.getFileId(new AlluxioURI("/xyz"));
Assert.assertTrue(fileId != IdUtils.INVALID_FILE_ID);
Assert.assertEquals(status, new URIStatus(fsMaster.getFileInfo(fileId)));
fsMaster.stop();
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class AbstractFileSystem method listStatus.
@Override
public FileStatus[] listStatus(Path path) throws IOException {
LOG.debug("listStatus({})", path);
if (mStatistics != null) {
mStatistics.incrementReadOps(1);
}
AlluxioURI uri = new AlluxioURI(HadoopUtils.getPathWithoutScheme(path));
List<URIStatus> statuses;
try {
statuses = mFileSystem.listStatus(uri);
} catch (FileDoesNotExistException e) {
throw new FileNotFoundException(HadoopUtils.getPathWithoutScheme(path));
} catch (AlluxioException e) {
throw new IOException(e);
}
FileStatus[] ret = new FileStatus[statuses.size()];
for (int k = 0; k < statuses.size(); k++) {
URIStatus status = statuses.get(k);
ret[k] = new FileStatus(status.getLength(), status.isFolder(), BLOCK_REPLICATION_CONSTANT, status.getBlockSizeBytes(), status.getLastModificationTimeMs(), status.getCreationTimeMs(), new FsPermission((short) status.getMode()), status.getOwner(), status.getGroup(), new Path(mAlluxioHeader + status.getPath()));
}
return ret;
}
Aggregations