use of alluxio.underfs.UfsStatus in project alluxio by Alluxio.
the class FileSystemAclIntegrationTest method ossGetPermission.
@Test
public void ossGetPermission() throws Exception {
Assume.assumeTrue(UnderFileSystemUtils.isOss(sUfs));
Path fileA = new Path("/objectfileA");
create(sTFS, fileA);
Assert.assertTrue(sUfs.isFile(PathUtils.concatPath(sUfsRoot, fileA)));
// Verify the owner, group and permission of OSS UFS is not supported and thus returns default
// values.
UfsStatus ufsStatus = sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileA));
Assert.assertNotEquals("", ufsStatus.getOwner());
Assert.assertNotEquals("", ufsStatus.getGroup());
Assert.assertEquals(Constants.DEFAULT_FILE_SYSTEM_MODE, ufsStatus.getMode());
}
use of alluxio.underfs.UfsStatus in project alluxio by Alluxio.
the class FileSystemAclIntegrationTest method changeNonexistentOwnerForHdfs.
/**
* Test for {@link FileSystem#setOwner(Path, String, String)} with HDFS UFS. It will test only
* changing the owner of file using TFS and propagate the change to UFS.
*/
@Test
public void changeNonexistentOwnerForHdfs() throws Exception {
// Skip non-HDFS UFSs.
Assume.assumeTrue(UnderFileSystemUtils.isHdfs(sUfs));
Path fileA = new Path("/chownfileA-hdfs");
final String testOwner = "test-user1";
final String testGroup = "test-group1";
create(sTFS, fileA);
FileStatus fs = sTFS.getFileStatus(fileA);
String defaultOwner = fs.getOwner();
String defaultGroup = fs.getGroup();
Assert.assertEquals(defaultOwner, sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileA)).getOwner());
// Group can different because HDFS user to group mapping can be different from that in Alluxio.
Assert.assertNotEquals(defaultOwner, testOwner);
Assert.assertNotEquals(defaultGroup, testGroup);
// Expect a IOException for not able to setOwner for UFS with invalid owner name.
sTFS.setOwner(fileA, testOwner, null);
fs = sTFS.getFileStatus(fileA);
Assert.assertEquals(testOwner, fs.getOwner());
Assert.assertEquals(defaultGroup, fs.getGroup());
UfsStatus ufsStatus = sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileA));
Assert.assertEquals(testOwner, ufsStatus.getOwner());
Assert.assertEquals(defaultGroup, ufsStatus.getGroup());
}
use of alluxio.underfs.UfsStatus in project alluxio by Alluxio.
the class FileSystemAclIntegrationTest method gcsGetPermission.
@Test
public void gcsGetPermission() throws Exception {
Assume.assumeTrue(UnderFileSystemUtils.isGcs(sUfs));
ServerConfiguration.unset(PropertyKey.UNDERFS_GCS_OWNER_ID_TO_USERNAME_MAPPING);
Path fileA = new Path("/gcsGetPermissionFile");
create(sTFS, fileA);
Assert.assertTrue(sUfs.isFile(PathUtils.concatPath(sUfsRoot, fileA)));
// Without providing "alluxio.underfs.gcs.owner.id.to.username.mapping", the default
// display name of the GCS owner account is empty. The owner will be the GCS account id, which
// is not empty.
UfsStatus ufsStatus = sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileA));
Assert.assertNotEquals("", ufsStatus.getOwner());
Assert.assertNotEquals("", ufsStatus.getGroup());
Assert.assertEquals((short) 0700, ufsStatus.getMode());
}
use of alluxio.underfs.UfsStatus in project alluxio by Alluxio.
the class WebUnderFileSystem method listStatus.
@Override
public UfsStatus[] listStatus(String path) throws IOException {
Document doc;
try {
doc = Jsoup.connect(path).get();
} catch (Exception e) {
LOG.error("Failed to get content from URL {}", path, e);
return null;
}
Elements bodyElements = doc.select("body");
if (bodyElements.size() == 0) {
return null;
}
Element bodyElement = bodyElements.first();
Elements bodyChildNodes = bodyElement.children();
Elements listElements = null;
for (Element bodyChildNode : bodyChildNodes) {
listElements = bodyChildNode.select("a");
if (listElements.size() > 0) {
break;
}
}
if (listElements == null || listElements.size() == 0) {
return null;
}
List<String> parentNames = mUfsConf.getList(PropertyKey.UNDERFS_WEB_PARENT_NAMES, ",");
int flagIndex = -1;
for (int i = 0; flagIndex == -1 && i < listElements.size(); i++) {
for (final String flag : parentNames) {
if (listElements.get(i).text().equalsIgnoreCase(flag)) {
flagIndex = i;
break;
}
}
}
List<UfsStatus> statusList = new ArrayList<>();
for (int i = (flagIndex == -1 ? 0 : flagIndex); i < listElements.size(); i++) {
Element listElement = listElements.get(i);
String href = listElement.attr("href");
String fileName = listElement.text();
if (!new WebUnderFileSystemFactory().supportsPath(href)) {
href = path + "/" + href;
}
try {
UfsStatus ufsStatus = getStatus(href, fileName);
statusList.add(ufsStatus);
} catch (IOException e) {
LOG.error("Failed to get status for url: {}", href, e);
}
}
UfsStatus[] rtn = new UfsStatus[statusList.size()];
return statusList.toArray(rtn);
}
use of alluxio.underfs.UfsStatus in project alluxio by Alluxio.
the class FileSystemAclIntegrationTest method s3GetPermission.
@Test
public void s3GetPermission() throws Exception {
Assume.assumeTrue(UnderFileSystemUtils.isS3(sUfs));
ServerConfiguration.unset(PropertyKey.UNDERFS_S3_OWNER_ID_TO_USERNAME_MAPPING);
Path fileA = new Path("/s3GetPermissionFile");
create(sTFS, fileA);
Assert.assertTrue(sUfs.isFile(PathUtils.concatPath(sUfsRoot, fileA)));
// Without providing "alluxio.underfs.s3.canonical.owner.id.to.username.mapping", the default
// display name of the S3 owner account is NOT empty.
UfsStatus ufsStatus = sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileA));
Assert.assertNotEquals("", ufsStatus.getOwner());
Assert.assertNotEquals("", ufsStatus.getGroup());
Assert.assertEquals((short) 0700, ufsStatus.getMode());
}
Aggregations